Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(ci): migrate PR automation to Namespace (#4399)
teod57e3feee26e
diff --git a/.github/workflows/assign-author.yml b/.github/workflows/assign-author.ymlindex 00f1c6da81..3889abbf52 100644--- a/.github/workflows/assign-author.yml+++ b/.github/workflows/assign-author.yml@@ -1,13 +1,18 @@+# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).+# Source: rust/cloud-storage/tools/xtask/src/workflows/assign_author.rsname: Pull Request--on:+'on':pull_request:- types: [opened, reopened]-+ types:+ - opened+ - reopenedjobs:- assignAuthor:+ assign_author:name: Assign author to PR- runs-on: ubuntu-latest+ runs-on: namespace-profile-linux-tiny-no-cache+ permissions:+ issues: write+ pull-requests: writesteps:- - name: Assign author to PR- uses: technote-space/assign-author@v1+ - name: Assign author to PR+ uses: technote-space/assign-author@9558557c5c4816f38bd06176fbc324ba14bb3160diff --git a/.github/workflows/assign-labels.yml b/.github/workflows/assign-labels.ymlindex 4afe07338e..8832b712b2 100644--- a/.github/workflows/assign-labels.yml+++ b/.github/workflows/assign-labels.yml@@ -1,56 +1,67 @@+# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).+# Source: rust/cloud-storage/tools/xtask/src/workflows/assign_labels.rsname: Auto Label PRs-on:+'on':pull_request:- types: [opened, synchronize, reopened]-+ types:+ - opened+ - synchronize+ - reopenedjobs:label:- runs-on: ubuntu-latest+ runs-on: namespace-profile-linux-tiny-no-cachepermissions:contents: readpull-requests: writesteps:- - name: Checkout code- uses: actions/checkout@v6- with:- fetch-depth: 0- - name: Get changed files- id: changed-files- uses: tj-actions/changed-files@v47- - name: Label based on paths- uses: actions/github-script@v7- with:- github-token: ${{ secrets.GITHUB_TOKEN }}- script: |- const changedFiles = `${{ steps.changed-files.outputs.all_changed_files }}`.split(' ');- const labels = new Set();-- // Define path-to-label mappings- const pathMappings = [- { path: 'rust/cloud-storage', label: 'cloud-storage' },- { path: 'js/app', label: 'web-app' },- { path: 'infra', label: 'infra' }- ];-- // Check each changed file against path mappings- for (const file of changedFiles) {- for (const mapping of pathMappings) {- if (file.startsWith(mapping.path)) {- labels.add(mapping.label);- }+ - name: Checkout+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd+ with:+ clean: 'false'+ fetch-depth: '0'+ persist-credentials: 'false'+ - id: changed-files+ name: Get changed files+ uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62+ with:+ json: 'true'+ escape_json: 'false'+ - name: Label based on paths+ uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b+ with:+ github-token: ${{ secrets.GITHUB_TOKEN }}+ script: |+ const changedFiles = JSON.parse(process.env.CHANGED_FILES_JSON || '[]');+ const labels = new Set();++ // Define path-to-label mappings+ const pathMappings = [+ { path: 'rust/cloud-storage', label: 'cloud-storage' },+ { path: 'js/app', label: 'web-app' },+ { path: 'infra', label: 'infra' }+ ];++ // Check each changed file against path mappings+ for (const file of changedFiles) {+ for (const mapping of pathMappings) {+ if (file.startsWith(mapping.path)) {+ labels.add(mapping.label);}}-- // Add labels to the PR- if (labels.size > 0) {- await github.rest.issues.addLabels({- owner: context.repo.owner,- repo: context.repo.repo,- issue_number: context.issue.number,- labels: Array.from(labels)- });-- console.log(`Added labels: ${Array.from(labels).join(', ')}`);- } else {- console.log('No matching labels found for changed files');- }+ }++ // Add labels to the PR+ if (labels.size > 0) {+ await github.rest.issues.addLabels({+ owner: context.repo.owner,+ repo: context.repo.repo,+ issue_number: context.issue.number,+ labels: Array.from(labels)+ });++ console.log(`Added labels: ${Array.from(labels).join(', ')}`);+ } else {+ console.log('No matching labels found for changed files');+ }+ env:+ CHANGED_FILES_JSON: ${{ steps.changed-files.outputs.all_changed_files }}diff --git a/.github/workflows/check_generated.yml b/.github/workflows/check_generated.ymlindex bc15470d6f..fcaa1902a2 100644--- a/.github/workflows/check_generated.yml+++ b/.github/workflows/check_generated.yml@@ -16,6 +16,7 @@ jobs:uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83ddwith:clean: 'false'+ persist-credentials: 'false'- name: Setup Rustuses: './.github/actions/setup-rust'with:diff --git a/.github/workflows/code_check_cloud_storage.yml b/.github/workflows/code_check_cloud_storage.ymlindex 8f64ef1467..3b9bbeeb26 100644--- a/.github/workflows/code_check_cloud_storage.yml+++ b/.github/workflows/code_check_cloud_storage.yml@@ -30,6 +30,7 @@ jobs:with:clean: 'false'fetch-depth: '0'+ persist-credentials: 'false'- name: Setup Rustuses: './.github/actions/setup-rust'with:@@ -119,6 +120,7 @@ jobs:uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83ddwith:clean: 'false'+ persist-credentials: 'false'- name: Mount Namespace cache volumeuses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0with:@@ -218,6 +220,7 @@ jobs:uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83ddwith:clean: 'false'+ persist-credentials: 'false'- name: Mount Namespace cache volumeuses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0with:diff --git a/rust/cloud-storage/tools/xtask/src/workflows/assign_author.rs b/rust/cloud-storage/tools/xtask/src/workflows/assign_author.rsnew file mode 100644index 0000000000..5b3e28dea8--- /dev/null+++ b/rust/cloud-storage/tools/xtask/src/workflows/assign_author.rs@@ -0,0 +1,32 @@+//! `Pull Request` — assigns a newly opened/reopened PR to its author.++use gh_workflow::{Event, Job, Level, Permissions, PullRequest, PullRequestType, Step, Workflow};++use crate::workflows::runners;++/// Build the workflow.+pub fn assign_author() -> Workflow {+ Workflow::new("Pull Request")+ .on(Event::default().pull_request(+ PullRequest::default()+ .add_type(PullRequestType::Opened)+ .add_type(PullRequestType::Reopened),+ ))+ .add_job("assign_author", assign_author_job())+}++fn assign_author_job() -> Job {+ Job::default()+ .name("Assign author to PR")+ .runs_on(runners::Runner::TinyNoCache.to_string())+ .permissions(Permissions {+ issues: Some(Level::Write),+ pull_requests: Some(Level::Write),+ ..Default::default()+ })+ .add_step(Step::new("Assign author to PR").uses(+ "technote-space",+ "assign-author",+ "9558557c5c4816f38bd06176fbc324ba14bb3160",+ ))+}diff --git a/rust/cloud-storage/tools/xtask/src/workflows/assign_labels.rs b/rust/cloud-storage/tools/xtask/src/workflows/assign_labels.rsnew file mode 100644index 0000000000..e999d62ce6--- /dev/null+++ b/rust/cloud-storage/tools/xtask/src/workflows/assign_labels.rs@@ -0,0 +1,93 @@+//! `Auto Label PRs` — applies coarse area labels from changed PR paths.++use gh_workflow::{Event, Job, Level, Permissions, PullRequest, PullRequestType, Step, Workflow};++use crate::workflows::{runners, steps};++/// Build the workflow.+pub fn assign_labels() -> Workflow {+ Workflow::new("Auto Label PRs")+ .on(Event::default().pull_request(+ PullRequest::default()+ .add_type(PullRequestType::Opened)+ .add_type(PullRequestType::Synchronize)+ .add_type(PullRequestType::Reopened),+ ))+ .add_job("label", label_job())+}++fn label_job() -> Job {+ Job::default()+ .runs_on(runners::Runner::TinyNoCache.to_string())+ .permissions(Permissions {+ contents: Some(Level::Read),+ pull_requests: Some(Level::Write),+ ..Default::default()+ })+ .add_step(steps::checkout(true, false))+ .add_step(changed_files())+ .add_step(label_by_paths())+}++fn changed_files() -> Step<gh_workflow::Use> {+ Step::new("Get changed files")+ .uses(+ "tj-actions",+ "changed-files",+ "24d32ffd492484c1d75e0c0b894501ddb9d30d62",+ )+ .id("changed-files")+ .add_with(("json", true))+ .add_with(("escape_json", false))+}++fn label_by_paths() -> Step<gh_workflow::Use> {+ Step::new("Label based on paths")+ .uses(+ "actions",+ "github-script",+ "f28e40c7f34bde8b3046d885e986cb6290c5673b",+ )+ .add_env((+ "CHANGED_FILES_JSON",+ "${{ steps.changed-files.outputs.all_changed_files }}",+ ))+ .add_with(("github-token", "${{ secrets.GITHUB_TOKEN }}"))+ .add_with((+ "script",+ indoc::indoc! {r#"+ const changedFiles = JSON.parse(process.env.CHANGED_FILES_JSON || '[]');+ const labels = new Set();++ // Define path-to-label mappings+ const pathMappings = [+ { path: 'rust/cloud-storage', label: 'cloud-storage' },+ { path: 'js/app', label: 'web-app' },+ { path: 'infra', label: 'infra' }+ ];++ // Check each changed file against path mappings+ for (const file of changedFiles) {+ for (const mapping of pathMappings) {+ if (file.startsWith(mapping.path)) {+ labels.add(mapping.label);+ }+ }+ }++ // Add labels to the PR+ if (labels.size > 0) {+ await github.rest.issues.addLabels({+ owner: context.repo.owner,+ repo: context.repo.repo,+ issue_number: context.issue.number,+ labels: Array.from(labels)+ });++ console.log(`Added labels: ${Array.from(labels).join(', ')}`);+ } else {+ console.log('No matching labels found for changed files');+ }+ "#},+ ))+}diff --git a/rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rs b/rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rsindex fa4f0a44ba..539ce4047c 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rs@@ -36,7 +36,7 @@ pub fn build_appimage() -> Workflow {pub fn build_appimage_job(ref_expr: &str) -> Job {Job::default().name("Build AppImage")- .runs_on(runners::Runner::LinuxRustCi.to_string())+ .runs_on(runners::Runner::RustCi.to_string()).add_step(steps::checkout_ref(ref_expr)).add_step(steps::mount_nix_cache_volume()).add_step(steps::setup_nix())diff --git a/rust/cloud-storage/tools/xtask/src/workflows/check_generated.rs b/rust/cloud-storage/tools/xtask/src/workflows/check_generated.rsindex 09be67cc99..ca6be88556 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/check_generated.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/check_generated.rs@@ -22,8 +22,8 @@ pub fn check_generated_workflows() -> Workflow {/// Regenerate in `--check` mode and fail on any difference.fn check_workflows() -> Job {Job::default()- .runs_on(runners::Runner::LinuxSmall.to_string())- .add_step(steps::checkout(false, true))+ .runs_on(runners::Runner::Small.to_string())+ .add_step(steps::checkout(false, false)).add_step(steps::setup_rust_light()).add_step(Step::new("verify workflows are up to date").run(diff --git a/rust/cloud-storage/tools/xtask/src/workflows/check_node_modules_nix.rs b/rust/cloud-storage/tools/xtask/src/workflows/check_node_modules_nix.rsindex a0cfbe953a..192c78b41d 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/check_node_modules_nix.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/check_node_modules_nix.rs@@ -40,7 +40,7 @@ pub fn check_node_modules_nix() -> Workflow {fn check_linux_node_modules_nix() -> Job {Job::default().name("check Linux node_modules nix")- .runs_on(runners::Runner::LinuxSmall.to_string())+ .runs_on(runners::Runner::Small.to_string()).add_step(steps::checkout(false, false)).add_step(steps::setup_nix()).add_step(steps::setup_cachix())diff --git a/rust/cloud-storage/tools/xtask/src/workflows/code_check_cloud_storage.rs b/rust/cloud-storage/tools/xtask/src/workflows/code_check_cloud_storage.rsindex 19827bba14..39aef26acb 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/code_check_cloud_storage.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/code_check_cloud_storage.rs@@ -37,7 +37,7 @@ pub fn code_check_cloud_storage() -> Workflow {/// Decide whether the rest of the workflow runs, and compute the nextest filter.fn path_check() -> Job {Job::default()- .runs_on(runners::Runner::LinuxSmall.to_string())+ .runs_on(runners::Runner::Small.to_string()).add_output("should_run", "${{ steps.filter.outputs.should_run }}").add_output("nextest_filter",@@ -47,7 +47,7 @@ fn path_check() -> Job {"doppler_config_bins","${{ steps.doppler-bins.outputs.doppler_config_bins }}",)- .add_step(steps::checkout(true, true))+ .add_step(steps::checkout(true, false)).add_step(steps::setup_rust_light()).add_step(paths_filter()).add_step(compute_changed_files())@@ -58,13 +58,13 @@ fn path_check() -> Job {/// fmt + clippy (and Doppler-config validation).fn check() -> Job {steps::gated_job()- .runs_on(runners::Runner::LinuxRustCi.with_cache_tag(vars::CI_CACHE_TAG))+ .runs_on(runners::Runner::RustCi.with_cache_tag(vars::CI_CACHE_TAG)).add_env(("RUSTFLAGS","-Dwarnings -Dclippy::disallowed_methods -C link-arg=-fuse-ld=mold",)).add_env(("RUSTDOCFLAGS", "-Dwarnings"))- .add_step(steps::checkout(false, true))+ .add_step(steps::checkout(false, false)).add_step(steps::mount_cache_volume()).add_step(steps::setup_nix()).add_step(steps::setup_dev_shell())@@ -78,7 +78,7 @@ fn check() -> Job {/// cargo nextest against postgres + redis service containers.fn test() -> Job {steps::gated_job()- .runs_on(runners::Runner::LinuxRustCi.with_cache_tag(vars::CI_CACHE_TAG))+ .runs_on(runners::Runner::RustCi.with_cache_tag(vars::CI_CACHE_TAG)).add_env(("NEXTEST_FILTER","${{ needs.path-check.outputs.nextest_filter }}",@@ -87,7 +87,7 @@ fn test() -> Job {.add_env(("RUSTFLAGS", "-Dwarnings -C link-arg=-fuse-ld=mold")).add_service("postgres", postgres_service()).add_service("redis", redis_service())- .add_step(steps::checkout(false, true))+ .add_step(steps::checkout(false, false)).add_step(steps::mount_cache_volume()).add_step(steps::setup_nix()).add_step(steps::setup_dev_shell())@@ -103,7 +103,7 @@ fn test() -> Job {fn status_check() -> Job {Job::default().name("Cloud Storage Status Check")- .runs_on(runners::Runner::LinuxSmall.to_string())+ .runs_on(runners::Runner::Small.to_string()).cond(Expression::new("always()")).needs(vec!["path-check".to_string(),diff --git a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs b/rust/cloud-storage/tools/xtask/src/workflows/mod.rsindex 0c66e0adb3..a4b4c3e3e6 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/mod.rs@@ -9,6 +9,8 @@//! files — [`runners`] (runner labels), [`vars`] (env / secrets / concurrency),//! and [`steps`] (reusable step + job helpers).+mod assign_author;+mod assign_labels;mod build_appimage_on_tag;mod build_desktop_on_tag;mod build_dmg_on_tag;@@ -25,23 +27,18 @@ use std::path::{Path, PathBuf};use anyhow::{bail, Context, Result};use gh_workflow::Workflow;-/// A generated workflow. `slug` is the snake_case identifier shared by the-/// source module (`<slug>.rs`) and the output file (`<slug>.yml`) — one source-/// of truth, mirroring Zed's one-module-per-workflow naming. (Required status-/// checks key on a job *name*, not the filename, so renaming files is safe.)+/// A generated workflow. `slug` is the snake_case source module (`<slug>.rs`)+/// used in the generated header. `file_name` is explicit so generated workflows+/// can replace existing hyphenated GitHub workflow filenames without changing+/// their identity in GitHub Actions.struct WorkflowFile {slug: &'static str,+ /// Output filename under `.github/workflows/`.+ file_name: &'static str,/// Produces the YAML body for this workflow.render_yaml: fn() -> Result<String>,}-impl WorkflowFile {- /// Output file under `.github/workflows/`.- fn file_name(&self) -> String {- format!("{}.yml", self.slug)- }-}-/// Render a `gh_workflow::Workflow` to YAML. Used by most workflow modules.fn render_gh_workflow(build: fn() -> Workflow) -> impl Fn() -> Result<String> {move || build().to_string().map_err(|e| anyhow::anyhow!("{e:?}"))@@ -49,28 +46,44 @@ fn render_gh_workflow(build: fn() -> Workflow) -> impl Fn() -> Result<String> {/// Every workflow we generate. Add new workflows here.const WORKFLOWS: &[WorkflowFile] = &[+ WorkflowFile {+ slug: "assign_author",+ file_name: "assign-author.yml",+ render_yaml: || render_gh_workflow(assign_author::assign_author)(),+ },+ WorkflowFile {+ slug: "assign_labels",+ file_name: "assign-labels.yml",+ render_yaml: || render_gh_workflow(assign_labels::assign_labels)(),+ },WorkflowFile {slug: "build_appimage_on_tag",+ file_name: "build_appimage_on_tag.yml",render_yaml: || render_gh_workflow(build_appimage_on_tag::build_appimage)(),},WorkflowFile {slug: "build_dmg_on_tag",+ file_name: "build_dmg_on_tag.yml",render_yaml: || render_gh_workflow(build_dmg_on_tag::build_dmg)(),},WorkflowFile {slug: "build_desktop_on_tag",+ file_name: "build_desktop_on_tag.yml",render_yaml: || render_gh_workflow(build_desktop_on_tag::build_desktop_on_tag)(),},WorkflowFile {slug: "code_check_cloud_storage",+ file_name: "code_check_cloud_storage.yml",render_yaml: || render_gh_workflow(code_check_cloud_storage::code_check_cloud_storage)(),},WorkflowFile {slug: "check_node_modules_nix",+ file_name: "check_node_modules_nix.yml",render_yaml: || render_gh_workflow(check_node_modules_nix::check_node_modules_nix)(),},WorkflowFile {slug: "check_generated",+ file_name: "check_generated.yml",render_yaml: || render_gh_workflow(check_generated::check_generated_workflows)(),},];@@ -79,7 +92,7 @@ const WORKFLOWS: &[WorkflowFile] = &[pub fn generate() -> Result<()> {let dir = workflows_dir()?;for workflow in WORKFLOWS {- let path = dir.join(workflow.file_name());+ let path = dir.join(workflow.file_name);fs::write(&path, render(workflow)?).with_context(|| format!("writing {}", path.display()))?;println!("generated {}", path.display());@@ -92,11 +105,11 @@ pub fn check() -> Result<()> {let dir = workflows_dir()?;let mut stale = Vec::new();for workflow in WORKFLOWS {- let path = dir.join(workflow.file_name());+ let path = dir.join(workflow.file_name);let on_disk =fs::read_to_string(&path).with_context(|| format!("reading {}", path.display()))?;if on_disk != render(workflow)? {- stale.push(workflow.file_name());+ stale.push(workflow.file_name.to_string());}}if !stale.is_empty() {@@ -111,8 +124,8 @@ pub fn check() -> Result<()> {/// Serialize a workflow to YAML and prepend the "do not edit" header.fn render(workflow: &WorkflowFile) -> Result<String> {- let yaml = (workflow.render_yaml)()- .with_context(|| format!("serializing {}", workflow.file_name()))?;+ let yaml =+ (workflow.render_yaml)().with_context(|| format!("serializing {}", workflow.file_name))?;Ok(format!("{}{yaml}", disclaimer(workflow.slug)))}diff --git a/rust/cloud-storage/tools/xtask/src/workflows/runners.rs b/rust/cloud-storage/tools/xtask/src/workflows/runners.rsindex 3e13bb77b9..dee2b1f8d7 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/runners.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/runners.rs@@ -12,19 +12,22 @@ use std::fmt;/// closed; `Display` renders the `runs-on` label.#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum Runner {+ /// Tiny profile for lightweight automation that does not need cache volume.+ TinyNoCache,/// Small profile for light jobs (path filtering, status aggregation).- LinuxSmall,+ Small,/// Dedicated CI profile for the heavy compile + test jobs. Has its own/// cache volume, isolated from the deploy profiles so deploy's churn can't/// evict the CI sccache/cargo caches.- LinuxRustCi,+ RustCi,}impl fmt::Display for Runner {fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {f.write_str(match self {- Runner::LinuxSmall => "namespace-profile-linux-small",- Runner::LinuxRustCi => "namespace-profile-linux-rust-ci",+ Runner::TinyNoCache => "namespace-profile-linux-tiny-no-cache",+ Runner::Small => "namespace-profile-linux-small",+ Runner::RustCi => "namespace-profile-linux-rust-ci",})}}diff --git a/rust/cloud-storage/tools/xtask/src/workflows/steps.rs b/rust/cloud-storage/tools/xtask/src/workflows/steps.rsindex dd7176c33d..f61e22d852 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/steps.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/steps.rs@@ -39,8 +39,9 @@ fn uses_local(name: &str, path: &str) -> Step<Use> {step}-/// `actions/checkout`, pinned. `full_history` fetches the full history, which the-/// path-filter diff in `path-check` needs.+/// `actions/checkout`, pinned. `full_history` fetches the full history, which+/// the path-filter diff in `path-check` needs. `persist_credentials` controls+/// whether checkout leaves the token in git config for later steps.pub fn checkout(full_history: bool, persist_credentials: bool) -> Step<Use> {Step::new("Checkout").uses(