diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index f4862d1039..2ee793f47d 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -32,14 +32,17 @@ env: jobs: lint: name: Lint Fix - runs-on: ubuntu-latest + runs-on: + - sccache permissions: contents: read steps: - name: Checkout Code uses: actions/checkout@v6 - name: Install SQLite - run: sudo apt-get install -y libsqlite3-dev + run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev + - name: Install OpenSSL + run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev - name: Setup Protobuf Compiler uses: arduino/setup-protoc@v3 with: diff --git a/.github/workflows/bounty.yml b/.github/workflows/bounty.yml index e41e7c79e3..2898f6ebac 100644 --- a/.github/workflows/bounty.yml +++ b/.github/workflows/bounty.yml @@ -39,25 +39,35 @@ permissions: jobs: sync-all-issues: name: Sync all bounty issues - runs-on: ubuntu-latest + runs-on: + - sccache permissions: issues: write steps: - name: Checkout uses: actions/checkout@v6 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' - name: Install npm packages run: npm install - name: Sync all bounty labels run: npx tsx .github/scripts/bounty/src/sync-all-issues.ts --repo ${{ github.repository }} --token ${{ secrets.GITHUB_TOKEN }} --execute sync-pr: name: Sync PR bounty labels - runs-on: ubuntu-latest + runs-on: + - sccache permissions: issues: write pull-requests: write steps: - name: Checkout uses: actions/checkout@v6 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' - name: Install npm packages run: npm install - name: Sync bounty labels diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 778df922e8..9e44bd5f94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,12 +36,15 @@ env: jobs: build: name: Build and Test - runs-on: ubuntu-latest + runs-on: + - sccache permissions: contents: read steps: - name: Checkout Code uses: actions/checkout@v6 + - name: Install OpenSSL + run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev - name: Setup Protobuf Compiler uses: arduino/setup-protoc@v3 with: @@ -56,7 +59,8 @@ jobs: run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info zsh_rprompt_perf: name: 'Performance: zsh rprompt' - runs-on: ubuntu-latest + runs-on: + - sccache permissions: contents: read steps: @@ -66,6 +70,8 @@ jobs: uses: arduino/setup-protoc@v3 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Install zsh + run: sudo apt-get update && sudo apt-get install -y zsh - name: Setup Rust Toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: @@ -77,7 +83,8 @@ jobs: - build if: github.event_name == 'push' && github.ref == 'refs/heads/main' name: Draft Release - runs-on: ubuntu-latest + runs-on: + - sccache permissions: contents: write pull-requests: write @@ -100,7 +107,8 @@ jobs: draft_release_pr: if: 'github.event_name == ''pull_request'' && contains(github.event.pull_request.labels.*.name, ''ci: build all targets'')' name: Draft Release for PR - runs-on: ubuntu-latest + runs-on: + - sccache outputs: crate_release_name: ${{ steps.set_output.outputs.crate_release_name }} crate_release_id: ${{ steps.set_output.outputs.crate_release_id }} @@ -135,7 +143,7 @@ jobs: - binary_name: forge-x86_64-unknown-linux-gnu binary_path: target/x86_64-unknown-linux-gnu/release/forge cross: 'false' - os: ubuntu-latest + os: sccache target: x86_64-unknown-linux-gnu - binary_name: forge-aarch64-unknown-linux-gnu binary_path: target/aarch64-unknown-linux-gnu/release/forge @@ -230,7 +238,7 @@ jobs: - binary_name: forge-x86_64-unknown-linux-gnu binary_path: target/x86_64-unknown-linux-gnu/release/forge cross: 'false' - os: ubuntu-latest + os: sccache target: x86_64-unknown-linux-gnu - binary_name: forge-aarch64-unknown-linux-gnu binary_path: target/aarch64-unknown-linux-gnu/release/forge diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 6c8f168130..e4fa323bc8 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -25,12 +25,17 @@ permissions: jobs: label-sync: name: label-sync - runs-on: ubuntu-latest + runs-on: + - sccache permissions: issues: write steps: - name: Checkout uses: actions/checkout@v6 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' - name: Sync labels run: |- npx github-label-sync \ diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 53cddb0648..438ffda8a3 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -36,7 +36,8 @@ permissions: jobs: update_release_draft: name: update_release_draft - runs-on: ubuntu-latest + runs-on: + - sccache steps: - name: Auto Labeler if: github.event_name == 'pull_request_target' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01574fb031..910d6c9f0a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,7 +46,7 @@ jobs: - binary_name: forge-x86_64-unknown-linux-gnu binary_path: target/x86_64-unknown-linux-gnu/release/forge cross: 'false' - os: ubuntu-latest + os: sccache target: x86_64-unknown-linux-gnu - binary_name: forge-aarch64-unknown-linux-gnu binary_path: target/aarch64-unknown-linux-gnu/release/forge @@ -120,7 +120,8 @@ jobs: needs: - build_release name: npm_release - runs-on: ubuntu-latest + runs-on: + - sccache strategy: matrix: repository: @@ -133,6 +134,10 @@ jobs: repository: ${{ matrix.repository }} ref: main token: ${{ secrets.NPM_ACCESS }} + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' - name: Update NPM Package run: './update-package.sh ${{ github.event.release.tag_name }}' env: @@ -143,7 +148,8 @@ jobs: needs: - build_release name: homebrew_release - runs-on: ubuntu-latest + runs-on: + - sccache steps: - name: Checkout Code uses: actions/checkout@v6 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 2d795379e0..0727f053b3 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -30,7 +30,8 @@ permissions: jobs: stale: name: Stale Issues - runs-on: ubuntu-latest + runs-on: + - sccache steps: - name: Mark Stale Issues uses: actions/stale@v10 diff --git a/crates/forge_ci/src/jobs/bounty_job.rs b/crates/forge_ci/src/jobs/bounty_job.rs index bb0becca26..99b5b75b01 100644 --- a/crates/forge_ci/src/jobs/bounty_job.rs +++ b/crates/forge_ci/src/jobs/bounty_job.rs @@ -26,7 +26,9 @@ fn checkout_step() -> Step { fn sync_job(job_name: &str, script: &str, args: String) -> Job { let cmd = format!("{TSX} {SCRIPTS_DIR}/{script} {args}"); Job::new(job_name) + .runs_on(crate::steps::sccache_runner()) .add_step(checkout_step()) + .add_step(crate::steps::setup_node()) .add_step(Step::new("Install npm packages").run("npm install")) .add_step(Step::new("Sync bounty labels").run(cmd)) } @@ -46,7 +48,9 @@ pub fn sync_all_issues_job() -> Job { --execute" ); Job::new("Sync all bounty issues") + .runs_on(crate::steps::sccache_runner()) .add_step(checkout_step()) + .add_step(crate::steps::setup_node()) .add_step(Step::new("Install npm packages").run("npm install")) .add_step(Step::new("Sync all bounty labels").run(cmd)) .permissions(Permissions::default().issues(Level::Write)) diff --git a/crates/forge_ci/src/jobs/draft_release_update_job.rs b/crates/forge_ci/src/jobs/draft_release_update_job.rs index ff5eb1513c..2f709d76bf 100644 --- a/crates/forge_ci/src/jobs/draft_release_update_job.rs +++ b/crates/forge_ci/src/jobs/draft_release_update_job.rs @@ -3,6 +3,7 @@ use gh_workflow::*; /// Create a job to update the release draft pub fn draft_release_update_job() -> Job { Job::new("update_release_draft") + .runs_on(crate::steps::sccache_runner()) .add_step( Step::new("Auto Labeler") .uses("release-drafter", "release-drafter/autolabeler", "v7") diff --git a/crates/forge_ci/src/jobs/label_sync_job.rs b/crates/forge_ci/src/jobs/label_sync_job.rs index aeba168d11..213a4abd7f 100644 --- a/crates/forge_ci/src/jobs/label_sync_job.rs +++ b/crates/forge_ci/src/jobs/label_sync_job.rs @@ -3,6 +3,7 @@ use gh_workflow::*; /// Create a job to sync GitHub labels pub fn label_sync_job() -> Job { Job::new("label-sync") + .runs_on(crate::steps::sccache_runner()) .permissions( Permissions::default() .issues(Level::Write) @@ -11,6 +12,7 @@ pub fn label_sync_job() -> Job { Step::new("Checkout Code").uses("actions", "checkout", "v6") .name("Checkout") ) + .add_step(crate::steps::setup_node()) .add_step( Step::new("Sync Labels").run( "npx github-label-sync \\\n --access-token ${{ secrets.GITHUB_TOKEN }} \\\n --labels \".github/labels.json\" \\\n ${{ github.repository }}" diff --git a/crates/forge_ci/src/jobs/release_draft.rs b/crates/forge_ci/src/jobs/release_draft.rs index 7565d85d8e..9ba9346934 100644 --- a/crates/forge_ci/src/jobs/release_draft.rs +++ b/crates/forge_ci/src/jobs/release_draft.rs @@ -4,6 +4,7 @@ use indexmap::indexmap; /// Create a draft release job for GitHub Actions pub fn create_draft_release_job(build_job_id: &str) -> Job { Job::new("draft_release") + .runs_on(crate::steps::sccache_runner()) .name("Draft Release") .add_needs(build_job_id) .cond(Expression::new( diff --git a/crates/forge_ci/src/jobs/release_draft_pr.rs b/crates/forge_ci/src/jobs/release_draft_pr.rs index d9b5cca937..ff08173181 100644 --- a/crates/forge_ci/src/jobs/release_draft_pr.rs +++ b/crates/forge_ci/src/jobs/release_draft_pr.rs @@ -4,6 +4,7 @@ use indexmap::indexmap; /// Create a draft release job for GitHub Actions that runs on PRs pub fn create_draft_release_pr_job() -> Job { Job::new("draft_release_pr") + .runs_on(crate::steps::sccache_runner()) .name("Draft Release for PR") .cond(Expression::new( "github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci: build all targets')", diff --git a/crates/forge_ci/src/jobs/release_homebrew.rs b/crates/forge_ci/src/jobs/release_homebrew.rs index 12b0817152..fdc8ccfe74 100644 --- a/crates/forge_ci/src/jobs/release_homebrew.rs +++ b/crates/forge_ci/src/jobs/release_homebrew.rs @@ -3,6 +3,7 @@ use gh_workflow::*; /// Create a homebrew release job pub fn release_homebrew_job() -> Job { Job::new("homebrew_release") + .runs_on(crate::steps::sccache_runner()) .add_step( Step::new("Checkout Code").uses("actions", "checkout", "v6") .add_with(("repository", "antinomyhq/homebrew-code-forge")) diff --git a/crates/forge_ci/src/jobs/release_npm.rs b/crates/forge_ci/src/jobs/release_npm.rs index 7a789a3197..77c2a1c4ec 100644 --- a/crates/forge_ci/src/jobs/release_npm.rs +++ b/crates/forge_ci/src/jobs/release_npm.rs @@ -6,6 +6,7 @@ pub fn release_npm_job() -> Job { let matrix = create_npm_matrix(); Job::new("npm_release") + .runs_on(crate::steps::sccache_runner()) .strategy(Strategy { fail_fast: None, max_parallel: None, matrix: Some(matrix) }) .add_step( Step::new("Checkout Code") @@ -14,6 +15,8 @@ pub fn release_npm_job() -> Job { .add_with(("ref", "main")) .add_with(("token", "${{ secrets.NPM_ACCESS }}")), ) + // The sccache runner image does not ship Node.js. + .add_step(crate::steps::setup_node()) // Make script executable and run it with token .add_step( Step::new("Update NPM Package") diff --git a/crates/forge_ci/src/release_matrix.rs b/crates/forge_ci/src/release_matrix.rs index 00b6a25ad9..9045d696c7 100644 --- a/crates/forge_ci/src/release_matrix.rs +++ b/crates/forge_ci/src/release_matrix.rs @@ -33,7 +33,10 @@ impl Default for ReleaseMatrix { cross: "true", }, MatrixEntry { - os: "ubuntu-latest", + // Native build: runs on the self-hosted sccache pool. Entries + // with `cross: "true"` need Docker and stay on GitHub-hosted + // runners. + os: crate::steps::SCCACHE_RUNNER, target: "x86_64-unknown-linux-gnu", binary_name: "forge-x86_64-unknown-linux-gnu", binary_path: "target/x86_64-unknown-linux-gnu/release/forge", diff --git a/crates/forge_ci/src/steps/mod.rs b/crates/forge_ci/src/steps/mod.rs index 123ec5d55b..76eac20ac4 100644 --- a/crates/forge_ci/src/steps/mod.rs +++ b/crates/forge_ci/src/steps/mod.rs @@ -1,3 +1,5 @@ +mod runner; mod setup_protoc; +pub use runner::{SCCACHE_RUNNER, install_openssl, sccache_runner, setup_node}; pub use setup_protoc::setup_protoc; diff --git a/crates/forge_ci/src/steps/runner.rs b/crates/forge_ci/src/steps/runner.rs new file mode 100644 index 0000000000..b215c0d8e9 --- /dev/null +++ b/crates/forge_ci/src/steps/runner.rs @@ -0,0 +1,25 @@ +use gh_workflow::*; + +/// Label of the self-hosted, autoscaled Cloud Run runner pool (no Docker +/// daemon). Only this label: the pool's scaler uses `noDefaultLabels`, so a job +/// that also asked for `self-hosted` would never get an instance started. +pub const SCCACHE_RUNNER: &str = "sccache"; + +/// `runs-on` value for jobs on the sccache pool, rendered as a block list. +pub fn sccache_runner() -> Vec<&'static str> { + vec![SCCACHE_RUNNER] +} + +/// Installs Node.js; the sccache runner image does not ship it. +pub fn setup_node() -> Step { + Step::new("Setup Node") + .uses("actions", "setup-node", "v4") + .add_with(("node-version", "20")) +} + +/// Installs the OpenSSL headers and `pkg-config` that `openssl-sys` needs; the +/// sccache runner image ships neither. +pub fn install_openssl() -> Step { + Step::new("Install OpenSSL") + .run("sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev") +} diff --git a/crates/forge_ci/src/workflows/autofix.rs b/crates/forge_ci/src/workflows/autofix.rs index 102ae5019b..781017f967 100644 --- a/crates/forge_ci/src/workflows/autofix.rs +++ b/crates/forge_ci/src/workflows/autofix.rs @@ -3,14 +3,19 @@ use gh_workflow::toolchain::Component; use gh_workflow::*; use crate::jobs; -use crate::steps::setup_protoc; +use crate::steps::{install_openssl, sccache_runner, setup_protoc}; /// Generate the autofix workflow pub fn generate_autofix_workflow() { let lint_fix_job = Job::new("Lint Fix") + .runs_on(sccache_runner()) .permissions(Permissions::default().contents(Level::Read)) .add_step(Step::new("Checkout Code").uses("actions", "checkout", "v6")) - .add_step(Step::new("Install SQLite").run("sudo apt-get install -y libsqlite3-dev")) + .add_step( + Step::new("Install SQLite") + .run("sudo apt-get update && sudo apt-get install -y libsqlite3-dev"), + ) + .add_step(install_openssl()) .add_step(setup_protoc()) .add_step( Step::toolchain() diff --git a/crates/forge_ci/src/workflows/ci.rs b/crates/forge_ci/src/workflows/ci.rs index 2b5d81174f..0fef344ca4 100644 --- a/crates/forge_ci/src/workflows/ci.rs +++ b/crates/forge_ci/src/workflows/ci.rs @@ -2,14 +2,16 @@ use gh_workflow::generate::Generate; use gh_workflow::*; use crate::jobs::{self, ReleaseBuilderJob}; -use crate::steps::setup_protoc; +use crate::steps::{install_openssl, sccache_runner, setup_protoc}; /// Generate the main CI workflow pub fn generate_ci_workflow() { // Create a basic build job for CI with coverage let build_job = Job::new("Build and Test") + .runs_on(sccache_runner()) .permissions(Permissions::default().contents(Level::Read)) .add_step(Step::new("Checkout Code").uses("actions", "checkout", "v6")) + .add_step(install_openssl()) .add_step(setup_protoc()) .add_step(Step::toolchain().add_stable()) .add_step(Step::new("Install cargo-llvm-cov").run("cargo install cargo-llvm-cov")) @@ -21,9 +23,14 @@ pub fn generate_ci_workflow() { // Create a performance test job to ensure zsh rprompt stays fast let perf_test_job = Job::new("zsh-rprompt-performance") .name("Performance: zsh rprompt") + .runs_on(sccache_runner()) .permissions(Permissions::default().contents(Level::Read)) .add_step(Step::new("Checkout Code").uses("actions", "checkout", "v6")) .add_step(setup_protoc()) + // The sccache runner image does not ship zsh. + .add_step( + Step::new("Install zsh").run("sudo apt-get update && sudo apt-get install -y zsh"), + ) .add_step(Step::toolchain().add_stable()) .add_step( Step::new("Run performance benchmark") diff --git a/crates/forge_ci/src/workflows/stale.rs b/crates/forge_ci/src/workflows/stale.rs index 374d61bfee..f7c6c75a6f 100644 --- a/crates/forge_ci/src/workflows/stale.rs +++ b/crates/forge_ci/src/workflows/stale.rs @@ -22,6 +22,7 @@ pub fn generate_stale_workflow() { .add_job( "stale", Job::new("Stale Issues") + .runs_on(crate::steps::sccache_runner()) .add_step( Step::new("Mark Stale Issues").uses("actions", "stale", "v10") .with(Input::from(indexmap! { diff --git a/crates/forge_main/src/porcelain.rs b/crates/forge_main/src/porcelain.rs index ca85f9beb0..b89fa2ec1b 100644 --- a/crates/forge_main/src/porcelain.rs +++ b/crates/forge_main/src/porcelain.rs @@ -415,7 +415,7 @@ impl From<&Info> for Porcelain { Section::Title(title) => { if in_row { rows.push(cells.clone()); - cells = HashMap::new(); + cells.clear(); value_counter = 1; } diff --git a/crates/forge_select/src/preview.rs b/crates/forge_select/src/preview.rs index 4aa90d3a1f..b0aabffe4f 100644 --- a/crates/forge_select/src/preview.rs +++ b/crates/forge_select/src/preview.rs @@ -1230,7 +1230,7 @@ fn wrap_ansi_line(line: &str, max_width: usize) -> Vec { current_line.clone() }; wrapped_lines.push(pushed); - current_line = String::new(); + current_line.clear(); visible_width = 0; is_continuation = true; }