Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(ci): migrate cargo hygiene checks to namespace + cargo x workflows (#4518)

teoe718f9395d7a
diff --git a/.github/workflows/cargo-deny.yml b/.github/workflows/cargo-deny.yml
deleted file mode 100644
index 48663c7322..0000000000
--- a/.github/workflows/cargo-deny.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-name: cargo deny check
-
-on:
- pull_request:
- branches: ['main']
- types: [opened, synchronize, reopened, ready_for_review]
- paths:
- - 'rust/cloud-storage/Cargo.toml'
- - 'rust/cloud-storage/**/Cargo.toml'
- - 'rust/cloud-storage/Cargo.lock'
- - 'rust/cloud-storage/deny.toml'
- - .github/workflows/cargo-deny.yml
-
-concurrency:
- group: cargo-deny-${{ github.ref }}
- cancel-in-progress: true
-
-jobs:
- cargo-deny:
- runs-on: ubuntu-22.04
- steps:
- - uses: actions/checkout@v6
- - uses: EmbarkStudios/cargo-deny-action@v2
- with:
- manifest-path: rust/cloud-storage/Cargo.toml
diff --git a/.github/workflows/cargo-workspace-dependency-check.yml b/.github/workflows/cargo-workspace-dependency-check.yml
deleted file mode 100644
index cd846ab25b..0000000000
--- a/.github/workflows/cargo-workspace-dependency-check.yml
+++ /dev/null
@@ -1,57 +0,0 @@
-name: cargo workspace dependency check
-on:
- pull_request:
- branches: [ 'main' ]
- types: [opened, synchronize, reopened, ready_for_review]
- paths:
- - 'rust/cloud-storage/Cargo.toml'
- - 'rust/cloud-storage/**/Cargo.toml'
- - 'rust/cloud-storage/Cargo.lock'
- - 'rust/cloud-storage/.config/hakari.toml'
- - 'rust/cloud-storage/workspace-hack/**'
- - 'rust/cloud-storage/tools/xtask/**'
- - '.github/workspace-dep-closures.json'
- - .github/workflows/cargo-workspace-dependency-check.yml
-
-concurrency:
- group: cargo-workspace-dependency-check-${{ github.ref }}
- cancel-in-progress: true
-
-jobs:
- dependency-check:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v6
- - uses: actions-rs/toolchain@v1
- with:
- toolchain: stable
- - name: setup rust version
- run: rustup default 1.85
- - name: install tool
- run: cargo install [email protected]
- - name: check
- run: |
- cd rust/cloud-storage
- # workspace-hack (generated, see xtask) re-declares third-party deps
- # with explicit versions by design — that is how it pins union
- # features. Drop it from the member list so this check only polices
- # human-written crates for duplicate dependencies.
- sed -i '/^ "workspace-hack",$/d' Cargo.toml
- cargo-workspace-dependency-checker
-
- # The workspace-hack crate pins every third-party dep to its union feature
- # set so a solo `cargo build -p <crate>` resolves identical features to the
- # union-built crane dep layers (deployCargoArtifacts /
- # lambdaDeployCargoArtifacts) — without it, per-service/per-lambda CI builds
- # silently recompile shared deps. The closure map drives the pruned
- # per-artifact deploy sources in flake.nix. Both are generated by the
- # lock-pinned engine in rust/cloud-storage/tools/xtask; this job rejects drift.
- # Regenerate locally with `just hakari` from rust/cloud-storage.
- hakari-and-dep-closures:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v6
- - name: generated dependency artifacts are up to date
- run: |
- cd rust/cloud-storage
- cargo run -p xtask --locked -- deps --check
diff --git a/.github/workflows/cargo_deny.yml b/.github/workflows/cargo_deny.yml
new file mode 100644
index 0000000000..a9e4edc4bc
--- /dev/null
+++ b/.github/workflows/cargo_deny.yml
@@ -0,0 +1,31 @@
+# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
+# Source: rust/cloud-storage/tools/xtask/src/workflows/cargo_deny.rs
+name: cargo deny check
+'on':
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - reopened
+ - ready_for_review
+ branches:
+ - main
+ paths:
+ - rust/cloud-storage/Cargo.toml
+ - rust/cloud-storage/**/Cargo.toml
+ - rust/cloud-storage/Cargo.lock
+ - rust/cloud-storage/deny.toml
+ - '.github/workflows/cargo_deny.yml'
+jobs:
+ cargo-deny:
+ runs-on: namespace-profile-linux-small
+ steps:
+ - name: Checkout Repo
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - name: cargo deny
+ uses: EmbarkStudios/cargo-deny-action@bb137d7af7e4fb67e5f82a49c4fce4fad40782fe
+ with:
+ manifest-path: rust/cloud-storage/Cargo.toml
+concurrency:
+ group: cargo-deny-${{ github.ref }}
+ cancel-in-progress: true
diff --git a/.github/workflows/cargo_workspace_dependency_check.yml b/.github/workflows/cargo_workspace_dependency_check.yml
new file mode 100644
index 0000000000..339d274950
--- /dev/null
+++ b/.github/workflows/cargo_workspace_dependency_check.yml
@@ -0,0 +1,88 @@
+# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
+# Source: rust/cloud-storage/tools/xtask/src/workflows/cargo_workspace_dependency_check.rs
+name: cargo workspace dependency check
+'on':
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - reopened
+ - ready_for_review
+ branches:
+ - main
+ paths:
+ - rust/cloud-storage/Cargo.toml
+ - rust/cloud-storage/**/Cargo.toml
+ - rust/cloud-storage/Cargo.lock
+ - rust/cloud-storage/.config/hakari.toml
+ - rust/cloud-storage/workspace-hack/**
+ - rust/cloud-storage/tools/xtask/**
+ - '.github/workspace-dep-closures.json'
+ - '.github/workflows/cargo_workspace_dependency_check.yml'
+jobs:
+ dependency-check:
+ runs-on: namespace-profile-linux-rust-ci;overrides.cache-tag=sccache-ci
+ steps:
+ - name: Checkout Repo
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - name: Mount Namespace cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ cache: rust
+ path: |-
+ /home/runner/.cache/sccache
+ /nix
+ continue-on-error: true
+ - name: Setup Nix
+ uses: './.github/actions/setup-nix'
+ - name: Setup Nix dev shell
+ uses: './.github/actions/setup-cachix'
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ dev-shell: 'true'
+ - name: Point sccache at the cache volume
+ run: |-
+ echo "SCCACHE_DIR=/home/runner/.cache/sccache" >> "$GITHUB_ENV"
+ echo "SCCACHE_CACHE_SIZE=20G" >> "$GITHUB_ENV"
+ - name: install tool
+ run: cargo install [email protected]
+ - name: check
+ run: |
+ cd rust/cloud-storage
+ # workspace-hack (generated, see xtask) re-declares third-party deps
+ # with explicit versions by design — that is how it pins union
+ # features. Drop it from the member list so this check only polices
+ # human-written crates for duplicate dependencies.
+ sed -i '/^ "workspace-hack",$/d' Cargo.toml
+ cargo-workspace-dependency-checker
+ hakari-and-dep-closures:
+ runs-on: namespace-profile-linux-rust-ci;overrides.cache-tag=sccache-ci
+ steps:
+ - name: Checkout Repo
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - name: Mount Namespace cache volume
+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0
+ with:
+ cache: rust
+ path: |-
+ /home/runner/.cache/sccache
+ /nix
+ continue-on-error: true
+ - name: Setup Nix
+ uses: './.github/actions/setup-nix'
+ - name: Setup Nix dev shell
+ uses: './.github/actions/setup-cachix'
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ dev-shell: 'true'
+ - name: Point sccache at the cache volume
+ run: |-
+ echo "SCCACHE_DIR=/home/runner/.cache/sccache" >> "$GITHUB_ENV"
+ echo "SCCACHE_CACHE_SIZE=20G" >> "$GITHUB_ENV"
+ - name: generated dependency artifacts are up to date
+ run: |
+ cd rust/cloud-storage
+ cargo run -p xtask --locked -- deps --check
+concurrency:
+ group: cargo-workspace-dependency-check-${{ github.ref }}
+ cancel-in-progress: true
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/cargo_deny.rs b/rust/cloud-storage/tools/xtask/src/workflows/cargo_deny.rs
new file mode 100644
index 0000000000..474ca7f1b0
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/src/workflows/cargo_deny.rs
@@ -0,0 +1,59 @@
+//! `cargo deny check` — advisories/licenses/bans over the cloud-storage
+//! workspace on PRs that touch manifests. Generated into `cargo_deny.yml`
+//! (replaces the hand-written `cargo-deny.yml`).
+
+use gh_workflow::{
+ Concurrency, Event, Expression, Job, PullRequest, PullRequestType, Step, Use, Workflow,
+};
+
+use crate::workflows::runners;
+
+/// Build the workflow.
+pub fn cargo_deny() -> Workflow {
+ Workflow::new("cargo deny check")
+ .on(Event::default().pull_request(
+ PullRequest::default()
+ .add_branch("main")
+ .add_type(PullRequestType::Opened)
+ .add_type(PullRequestType::Synchronize)
+ .add_type(PullRequestType::Reopened)
+ .add_type(PullRequestType::ReadyForReview)
+ .add_path("rust/cloud-storage/Cargo.toml")
+ .add_path("rust/cloud-storage/**/Cargo.toml")
+ .add_path("rust/cloud-storage/Cargo.lock")
+ .add_path("rust/cloud-storage/deny.toml")
+ .add_path(".github/workflows/cargo_deny.yml"),
+ ))
+ .concurrency(
+ Concurrency::new(Expression::new("cargo-deny-${{ github.ref }}"))
+ .cancel_in_progress(true),
+ )
+ .add_job("cargo-deny", cargo_deny_job())
+}
+
+/// The deny action ships its own musl cargo-deny binary — no toolchain, no
+/// cache volume needed. Small suffices.
+fn cargo_deny_job() -> Job {
+ Job::default()
+ .runs_on(runners::Runner::Small.to_string())
+ .add_step(checkout())
+ .add_step(deny())
+}
+
+fn checkout() -> Step<Use> {
+ Step::new("Checkout Repo").uses(
+ "actions",
+ "checkout",
+ "df4cb1c069e1874edd31b4311f1884172cec0e10",
+ ) // v6
+}
+
+fn deny() -> Step<Use> {
+ Step::new("cargo deny")
+ .uses(
+ "EmbarkStudios",
+ "cargo-deny-action",
+ "bb137d7af7e4fb67e5f82a49c4fce4fad40782fe",
+ ) // v2
+ .add_with(("manifest-path", "rust/cloud-storage/Cargo.toml"))
+}
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/cargo_workspace_dependency_check.rs b/rust/cloud-storage/tools/xtask/src/workflows/cargo_workspace_dependency_check.rs
new file mode 100644
index 0000000000..3a4af834b0
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/src/workflows/cargo_workspace_dependency_check.rs
@@ -0,0 +1,107 @@
+//! `cargo workspace dependency check` — polices duplicate third-party deps in
+//! human-written crates, and rejects drift in the generated workspace-hack +
+//! dep-closure map. Generated into `cargo_workspace_dependency_check.yml`
+//! (replaces the hand-written `cargo-workspace-dependency-check.yml`).
+//!
+//! Both jobs build Rust, so they run on the rust-ci profile with the shared
+//! `sccache-ci` volume and the Nix dev shell — this replaces the deprecated
+//! `actions-rs/toolchain` + hardcoded `rustup default 1.85` (which drifted
+//! from the workspace toolchain) and gives the `cargo install`/xtask builds
+//! warm caches instead of compiling cold on every run.
+
+use gh_workflow::{
+ Concurrency, Event, Expression, Job, PullRequest, PullRequestType, Run, Step, Use, Workflow,
+};
+
+use crate::workflows::{runners, steps, vars};
+
+/// Build the workflow.
+pub fn cargo_workspace_dependency_check() -> Workflow {
+ Workflow::new("cargo workspace dependency check")
+ .on(Event::default().pull_request(
+ PullRequest::default()
+ .add_branch("main")
+ .add_type(PullRequestType::Opened)
+ .add_type(PullRequestType::Synchronize)
+ .add_type(PullRequestType::Reopened)
+ .add_type(PullRequestType::ReadyForReview)
+ .add_path("rust/cloud-storage/Cargo.toml")
+ .add_path("rust/cloud-storage/**/Cargo.toml")
+ .add_path("rust/cloud-storage/Cargo.lock")
+ .add_path("rust/cloud-storage/.config/hakari.toml")
+ .add_path("rust/cloud-storage/workspace-hack/**")
+ .add_path("rust/cloud-storage/tools/xtask/**")
+ .add_path(".github/workspace-dep-closures.json")
+ .add_path(".github/workflows/cargo_workspace_dependency_check.yml"),
+ ))
+ .concurrency(
+ Concurrency::new(Expression::new(
+ "cargo-workspace-dependency-check-${{ github.ref }}",
+ ))
+ .cancel_in_progress(true),
+ )
+ .add_job("dependency-check", dependency_check())
+ .add_job("hakari-and-dep-closures", hakari_and_dep_closures())
+}
+
+fn rust_ci_job() -> Job {
+ Job::default()
+ .runs_on(runners::Runner::RustCi.with_cache_tag(vars::CI_CACHE_TAG))
+ .add_step(checkout())
+ .add_step(steps::mount_cache_volume())
+ .add_step(steps::setup_nix())
+ .add_step(steps::setup_dev_shell())
+ .add_step(steps::pin_sccache_dir())
+}
+
+fn dependency_check() -> Job {
+ rust_ci_job()
+ .add_step(install_checker())
+ .add_step(run_checker())
+}
+
+/// The workspace-hack crate pins every third-party dep to its union feature
+/// set so a solo `cargo build -p <crate>` resolves identical features to the
+/// union-built crane dep layers (deployCargoArtifacts /
+/// lambdaDeployCargoArtifacts) — without it, per-service/per-lambda CI builds
+/// silently recompile shared deps. The closure map drives the pruned
+/// per-artifact deploy sources in flake.nix. Both are generated by the
+/// lock-pinned engine in rust/cloud-storage/tools/xtask; this job rejects
+/// drift. Regenerate locally with `just hakari` from rust/cloud-storage.
+fn hakari_and_dep_closures() -> Job {
+ rust_ci_job().add_step(deps_check())
+}
+
+fn checkout() -> Step<Use> {
+ Step::new("Checkout Repo").uses(
+ "actions",
+ "checkout",
+ "df4cb1c069e1874edd31b4311f1884172cec0e10",
+ ) // v6
+}
+
+/// `cargo install` skips the build when the same version is already present
+/// in `~/.cargo/bin` (persisted on the cache volume); cold installs compile
+/// through the volume-backed sccache.
+fn install_checker() -> Step<Run> {
+ Step::new("install tool").run("cargo install [email protected]")
+}
+
+fn run_checker() -> Step<Run> {
+ Step::new("check").run(indoc::indoc! {r#"
+ cd rust/cloud-storage
+ # workspace-hack (generated, see xtask) re-declares third-party deps
+ # with explicit versions by design — that is how it pins union
+ # features. Drop it from the member list so this check only polices
+ # human-written crates for duplicate dependencies.
+ sed -i '/^ "workspace-hack",$/d' Cargo.toml
+ cargo-workspace-dependency-checker
+ "#})
+}
+
+fn deps_check() -> Step<Run> {
+ Step::new("generated dependency artifacts are up to date").run(indoc::indoc! {r#"
+ cd rust/cloud-storage
+ cargo run -p xtask --locked -- deps --check
+ "#})
+}
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs b/rust/cloud-storage/tools/xtask/src/workflows/mod.rs
index 2e1ebbec97..1d1b6230e7 100644
--- a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs
+++ b/rust/cloud-storage/tools/xtask/src/workflows/mod.rs
@@ -15,6 +15,8 @@ mod build_appimage_on_tag;
mod build_desktop_on_tag;
mod build_dmg_on_tag;
mod cancel_stuck_cloud_storage_deploys;
+mod cargo_deny;
+mod cargo_workspace_dependency_check;
mod check_generated;
mod check_node_modules_nix;
mod cleanup_preview;
@@ -124,6 +126,18 @@ const WORKFLOWS: &[WorkflowFile] = &[
)
},
},
+ WorkflowFile {
+ slug: "cargo_deny",
+ file_name: "cargo_deny.yml",
+ render_yaml: || render_gh_workflow(cargo_deny::cargo_deny)(),
+ },
+ WorkflowFile {
+ slug: "cargo_workspace_dependency_check",
+ file_name: "cargo_workspace_dependency_check.yml",
+ render_yaml: || {
+ render_gh_workflow(cargo_workspace_dependency_check::cargo_workspace_dependency_check)()
+ },
+ },
WorkflowFile {
slug: "cleanup_preview",
file_name: "cleanup_preview.yml",