diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 778df922e8..ecab46d133 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,7 +115,8 @@ jobs: - draft_release if: github.event_name == 'push' && github.ref == 'refs/heads/main' name: build-release - runs-on: ${{ matrix.os }} + runs-on: + - ${{ matrix.os }} permissions: contents: write pull-requests: write @@ -125,12 +126,12 @@ jobs: - binary_name: forge-x86_64-unknown-linux-musl binary_path: target/x86_64-unknown-linux-musl/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: x86_64-unknown-linux-musl - binary_name: forge-aarch64-unknown-linux-musl binary_path: target/aarch64-unknown-linux-musl/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: aarch64-unknown-linux-musl - binary_name: forge-x86_64-unknown-linux-gnu binary_path: target/x86_64-unknown-linux-gnu/release/forge @@ -140,7 +141,7 @@ jobs: - binary_name: forge-aarch64-unknown-linux-gnu binary_path: target/aarch64-unknown-linux-gnu/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: aarch64-unknown-linux-gnu - binary_name: forge-x86_64-apple-darwin binary_path: target/x86_64-apple-darwin/release/forge @@ -165,7 +166,7 @@ jobs: - binary_name: forge-aarch64-linux-android binary_path: target/aarch64-linux-android/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: aarch64-linux-android steps: - name: Checkout Code @@ -180,6 +181,19 @@ jobs: uses: taiki-e/setup-cross-toolchain-action@v1 with: target: ${{ matrix.target }} + - name: Put Rust homes on the dind-shared volume + if: ${{ matrix.cross == 'true' }} + run: |- + echo "CARGO_HOME=$RUNNER_TEMP/cargo" >> "$GITHUB_ENV" + echo "RUSTUP_HOME=$RUNNER_TEMP/rustup" >> "$GITHUB_ENV" + echo "$RUNNER_TEMP/cargo/bin" >> "$GITHUB_PATH" + - name: Setup Rust (cross) + if: ${{ matrix.cross == 'true' }} + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + cache: 'false' + rustflags: '' - name: Add Rust target if: ${{ matrix.cross == 'false' }} run: rustup target add ${{ matrix.target }} @@ -210,7 +224,8 @@ jobs: - draft_release_pr if: 'github.event_name == ''pull_request'' && contains(github.event.pull_request.labels.*.name, ''ci: build all targets'')' name: build-release - runs-on: ${{ matrix.os }} + runs-on: + - ${{ matrix.os }} permissions: contents: write pull-requests: write @@ -220,12 +235,12 @@ jobs: - binary_name: forge-x86_64-unknown-linux-musl binary_path: target/x86_64-unknown-linux-musl/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: x86_64-unknown-linux-musl - binary_name: forge-aarch64-unknown-linux-musl binary_path: target/aarch64-unknown-linux-musl/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: aarch64-unknown-linux-musl - binary_name: forge-x86_64-unknown-linux-gnu binary_path: target/x86_64-unknown-linux-gnu/release/forge @@ -235,7 +250,7 @@ jobs: - binary_name: forge-aarch64-unknown-linux-gnu binary_path: target/aarch64-unknown-linux-gnu/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: aarch64-unknown-linux-gnu - binary_name: forge-x86_64-apple-darwin binary_path: target/x86_64-apple-darwin/release/forge @@ -260,7 +275,7 @@ jobs: - binary_name: forge-aarch64-linux-android binary_path: target/aarch64-linux-android/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: aarch64-linux-android steps: - name: Checkout Code @@ -275,6 +290,19 @@ jobs: uses: taiki-e/setup-cross-toolchain-action@v1 with: target: ${{ matrix.target }} + - name: Put Rust homes on the dind-shared volume + if: ${{ matrix.cross == 'true' }} + run: |- + echo "CARGO_HOME=$RUNNER_TEMP/cargo" >> "$GITHUB_ENV" + echo "RUSTUP_HOME=$RUNNER_TEMP/rustup" >> "$GITHUB_ENV" + echo "$RUNNER_TEMP/cargo/bin" >> "$GITHUB_PATH" + - name: Setup Rust (cross) + if: ${{ matrix.cross == 'true' }} + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + cache: 'false' + rustflags: '' - name: Add Rust target if: ${{ matrix.cross == 'false' }} run: rustup target add ${{ matrix.target }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01574fb031..ffb7a6cfaa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,8 @@ permissions: jobs: build_release: name: build-release - runs-on: ${{ matrix.os }} + runs-on: + - ${{ matrix.os }} permissions: contents: write pull-requests: write @@ -36,12 +37,12 @@ jobs: - binary_name: forge-x86_64-unknown-linux-musl binary_path: target/x86_64-unknown-linux-musl/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: x86_64-unknown-linux-musl - binary_name: forge-aarch64-unknown-linux-musl binary_path: target/aarch64-unknown-linux-musl/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: aarch64-unknown-linux-musl - binary_name: forge-x86_64-unknown-linux-gnu binary_path: target/x86_64-unknown-linux-gnu/release/forge @@ -51,7 +52,7 @@ jobs: - binary_name: forge-aarch64-unknown-linux-gnu binary_path: target/aarch64-unknown-linux-gnu/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: aarch64-unknown-linux-gnu - binary_name: forge-x86_64-apple-darwin binary_path: target/x86_64-apple-darwin/release/forge @@ -76,7 +77,7 @@ jobs: - binary_name: forge-aarch64-linux-android binary_path: target/aarch64-linux-android/release/forge cross: 'true' - os: ubuntu-latest + os: docker target: aarch64-linux-android steps: - name: Checkout Code @@ -91,6 +92,19 @@ jobs: uses: taiki-e/setup-cross-toolchain-action@v1 with: target: ${{ matrix.target }} + - name: Put Rust homes on the dind-shared volume + if: ${{ matrix.cross == 'true' }} + run: |- + echo "CARGO_HOME=$RUNNER_TEMP/cargo" >> "$GITHUB_ENV" + echo "RUSTUP_HOME=$RUNNER_TEMP/rustup" >> "$GITHUB_ENV" + echo "$RUNNER_TEMP/cargo/bin" >> "$GITHUB_PATH" + - name: Setup Rust (cross) + if: ${{ matrix.cross == 'true' }} + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + cache: 'false' + rustflags: '' - name: Add Rust target if: ${{ matrix.cross == 'false' }} run: rustup target add ${{ matrix.target }} diff --git a/crates/forge_ci/src/jobs/release_build_job.rs b/crates/forge_ci/src/jobs/release_build_job.rs index edd3a0662c..7710910800 100644 --- a/crates/forge_ci/src/jobs/release_build_job.rs +++ b/crates/forge_ci/src/jobs/release_build_job.rs @@ -32,7 +32,8 @@ impl From for Job { max_parallel: None, matrix: Some(ReleaseMatrix::default().into()), }) - .runs_on("${{ matrix.os }}") + // Block-list form, as the self-hosted labels are written. + .runs_on(vec!["${{ matrix.os }}"]) .permissions( Permissions::default() .contents(Level::Write) @@ -51,6 +52,28 @@ impl From for Job { .with(("target", "${{ matrix.target }}")) .if_condition(Expression::new("${{ matrix.cross == 'false' }}")), ) + // On the ARC dind runner the Docker daemon is a sidecar that only + // shares `/home/runner/_work`; `cross` bind-mounts CARGO_HOME and + // RUSTUP_HOME into its container, so they must live under it. + .add_step( + Step::new("Put Rust homes on the dind-shared volume") + .run(concat!( + "echo \"CARGO_HOME=$RUNNER_TEMP/cargo\" >> \"$GITHUB_ENV\"\n", + "echo \"RUSTUP_HOME=$RUNNER_TEMP/rustup\" >> \"$GITHUB_ENV\"\n", + "echo \"$RUNNER_TEMP/cargo/bin\" >> \"$GITHUB_PATH\"", + )) + .if_condition(Expression::new("${{ matrix.cross == 'true' }}")), + ) + // `cross` drives rustup on the host; the self-hosted docker runner + // has no preinstalled Rust (the hosted image did). + .add_step( + Step::new("Setup Rust (cross)") + .uses("actions-rust-lang", "setup-rust-toolchain", "v1") + .add_with(("toolchain", "stable")) + .add_with(("cache", "false")) + .add_with(("rustflags", "")) + .if_condition(Expression::new("${{ matrix.cross == 'true' }}")), + ) // Explicitly add the target to ensure it's available .add_step( Step::new("Add Rust target") diff --git a/crates/forge_ci/src/release_matrix.rs b/crates/forge_ci/src/release_matrix.rs index 00b6a25ad9..62323e594b 100644 --- a/crates/forge_ci/src/release_matrix.rs +++ b/crates/forge_ci/src/release_matrix.rs @@ -11,6 +11,10 @@ pub struct MatrixEntry { pub cross: &'static str, } +/// Self-hosted ARC dind pool. `cross` builds run inside Docker containers, so +/// every `cross: "true"` entry targets it; the rest stay GitHub-hosted. +const DOCKER_RUNNER: &str = "docker"; + #[derive(Clone)] pub struct ReleaseMatrix(Vec); @@ -19,14 +23,14 @@ impl Default for ReleaseMatrix { fn default() -> Self { ReleaseMatrix(vec![ MatrixEntry { - os: "ubuntu-latest", + os: DOCKER_RUNNER, target: "x86_64-unknown-linux-musl", binary_name: "forge-x86_64-unknown-linux-musl", binary_path: "target/x86_64-unknown-linux-musl/release/forge", cross: "true", }, MatrixEntry { - os: "ubuntu-latest", + os: DOCKER_RUNNER, target: "aarch64-unknown-linux-musl", binary_name: "forge-aarch64-unknown-linux-musl", binary_path: "target/aarch64-unknown-linux-musl/release/forge", @@ -40,7 +44,7 @@ impl Default for ReleaseMatrix { cross: "false", }, MatrixEntry { - os: "ubuntu-latest", + os: DOCKER_RUNNER, target: "aarch64-unknown-linux-gnu", binary_name: "forge-aarch64-unknown-linux-gnu", binary_path: "target/aarch64-unknown-linux-gnu/release/forge", @@ -75,7 +79,7 @@ impl Default for ReleaseMatrix { cross: "false", }, MatrixEntry { - os: "ubuntu-latest", + os: DOCKER_RUNNER, target: "aarch64-linux-android", binary_name: "forge-aarch64-linux-android", binary_path: "target/aarch64-linux-android/release/forge", diff --git a/crates/forge_main/src/porcelain.rs b/crates/forge_main/src/porcelain.rs index ca85f9beb0..5c8b06e1a6 100644 --- a/crates/forge_main/src/porcelain.rs +++ b/crates/forge_main/src/porcelain.rs @@ -414,8 +414,7 @@ impl From<&Info> for Porcelain { match section { Section::Title(title) => { if in_row { - rows.push(cells.clone()); - cells = HashMap::new(); + rows.push(std::mem::take(&mut cells)); value_counter = 1; } diff --git a/crates/forge_select/src/preview.rs b/crates/forge_select/src/preview.rs index 4aa90d3a1f..e552ed1e1c 100644 --- a/crates/forge_select/src/preview.rs +++ b/crates/forge_select/src/preview.rs @@ -1227,10 +1227,10 @@ fn wrap_ansi_line(line: &str, max_width: usize) -> Vec { let pushed = if is_continuation { format!("{WRAP_ICON}{current_line}") } else { - current_line.clone() + std::mem::take(&mut current_line) }; wrapped_lines.push(pushed); - current_line = String::new(); + current_line.clear(); visible_width = 0; is_continuation = true; }