Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/bounty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -120,7 +120,8 @@ jobs:
needs:
- build_release
name: npm_release
runs-on: ubuntu-latest
runs-on:
- sccache
strategy:
matrix:
repository:
Expand All @@ -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:
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions crates/forge_ci/src/jobs/bounty_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ fn checkout_step() -> Step<Use> {
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))
}
Expand All @@ -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))
Expand Down
1 change: 1 addition & 0 deletions crates/forge_ci/src/jobs/draft_release_update_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions crates/forge_ci/src/jobs/label_sync_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 }}"
Expand Down
1 change: 1 addition & 0 deletions crates/forge_ci/src/jobs/release_draft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions crates/forge_ci/src/jobs/release_draft_pr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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')",
Expand Down
1 change: 1 addition & 0 deletions crates/forge_ci/src/jobs/release_homebrew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
3 changes: 3 additions & 0 deletions crates/forge_ci/src/jobs/release_npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion crates/forge_ci/src/release_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions crates/forge_ci/src/steps/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
25 changes: 25 additions & 0 deletions crates/forge_ci/src/steps/runner.rs
Original file line number Diff line number Diff line change
@@ -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<Use> {
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<Run> {
Step::new("Install OpenSSL")
.run("sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev")
}
9 changes: 7 additions & 2 deletions crates/forge_ci/src/workflows/autofix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 8 additions & 1 deletion crates/forge_ci/src/workflows/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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")
Expand Down
Loading
Loading