From f7a50cffe16a5a0c3d5e24d81cb2182497ae749c Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 24 Oct 2025 00:16:12 -0600 Subject: [PATCH 01/12] Try gh_workflow generation --- Cargo.lock | 108 +++++++++++++++++++ Cargo.toml | 1 + crates/zed/Cargo.toml | 1 + tooling/xtask/Cargo.toml | 1 + tooling/xtask/src/main.rs | 2 + tooling/xtask/src/tasks.rs | 1 + tooling/xtask/src/tasks/generate_workflow.rs | 41 +++++++ 7 files changed, 155 insertions(+) create mode 100644 tooling/xtask/src/tasks/generate_workflow.rs diff --git a/Cargo.lock b/Cargo.lock index b80ba1c81d7c40..714c40fe7d273c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4900,6 +4900,18 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "derive_setters" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae5c625eda104c228c06ecaf988d1c60e542176bd7a490e60eeda3493244c0c9" +dependencies = [ + "darling 0.20.11", + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "deunicode" version = "1.6.2" @@ -6940,6 +6952,35 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gh-workflow" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fffeec7bd9dfa73ffe1db38979cca5716ec6ffd944f03fae65fee81f16082ae" +dependencies = [ + "async-trait", + "derive_more 2.0.1", + "derive_setters", + "gh-workflow-macros", + "indexmap 2.11.4", + "merge", + "serde", + "serde_json", + "serde_yaml", + "strum_macros 0.27.2", +] + +[[package]] +name = "gh-workflow-macros" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eafb4d2a1005d4ac6d041ce929af10be1de1e1eae478795d9d634b84ccf8191" +dependencies = [ + "heck 0.5.0", + "quote", + "syn 2.0.106", +] + [[package]] name = "gif" version = "0.13.3" @@ -9809,6 +9850,28 @@ dependencies = [ "gpui", ] +[[package]] +name = "merge" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10bbef93abb1da61525bbc45eeaff6473a41907d19f8f9aa5168d214e10693e9" +dependencies = [ + "merge_derive", + "num-traits", +] + +[[package]] +name = "merge_derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "209d075476da2e63b4b29e72a2ef627b840589588e71400a25e3565c4f849d07" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "metal" version = "0.29.0" @@ -12798,6 +12861,30 @@ dependencies = [ "toml_edit 0.23.7", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro-error-attr2" version = "2.0.0" @@ -15221,6 +15308,19 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.11.4", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "serial2" version = "0.2.33" @@ -18392,6 +18492,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "untrusted" version = "0.9.0" @@ -20801,6 +20907,7 @@ dependencies = [ "cargo_metadata", "cargo_toml", "clap", + "gh-workflow", "indoc", "toml 0.8.23", "toml_edit 0.22.27", @@ -21032,6 +21139,7 @@ dependencies = [ "file_finder", "fs", "futures 0.3.31", + "gh-workflow", "git", "git_hosting_providers", "git_ui", diff --git a/Cargo.toml b/Cargo.toml index e0682924bc377d..623314cc327bc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -506,6 +506,7 @@ fork = "0.2.0" futures = "0.3" futures-batch = "0.6.1" futures-lite = "1.13" +gh-workflow = "0.8.0" git2 = { version = "0.20.1", default-features = false } globset = "0.4" handlebars = "4.3" diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index c84fa8261fe2ef..b70a0cd012814c 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -165,6 +165,7 @@ zeta.workspace = true zeta2.workspace = true zlog.workspace = true zlog_settings.workspace = true +gh-workflow = "0.8.0" [target.'cfg(target_os = "windows")'.dependencies] windows.workspace = true diff --git a/tooling/xtask/Cargo.toml b/tooling/xtask/Cargo.toml index aa06e6164683ed..f51a24f3e97b2e 100644 --- a/tooling/xtask/Cargo.toml +++ b/tooling/xtask/Cargo.toml @@ -16,3 +16,4 @@ clap = { workspace = true, features = ["derive"] } toml.workspace = true indoc.workspace = true toml_edit.workspace = true +gh-workflow.workspace = true diff --git a/tooling/xtask/src/main.rs b/tooling/xtask/src/main.rs index 5b265392f4035c..52f2285e0a80f5 100644 --- a/tooling/xtask/src/main.rs +++ b/tooling/xtask/src/main.rs @@ -20,6 +20,7 @@ enum CliCommand { PackageConformity(tasks::package_conformity::PackageConformityArgs), /// Publishes GPUI and its dependencies to crates.io. PublishGpui(tasks::publish_gpui::PublishGpuiArgs), + GenerateWorkflow(tasks::generate_workflow::GenerateWorkflowArgs), } fn main() -> Result<()> { @@ -32,5 +33,6 @@ fn main() -> Result<()> { tasks::package_conformity::run_package_conformity(args) } CliCommand::PublishGpui(args) => tasks::publish_gpui::run_publish_gpui(args), + CliCommand::GenerateWorkflow(args) => tasks::generate_workflow::run_generate_workflow(args), } } diff --git a/tooling/xtask/src/tasks.rs b/tooling/xtask/src/tasks.rs index b73aeb0e7fce47..e5cbaa2262ac6f 100644 --- a/tooling/xtask/src/tasks.rs +++ b/tooling/xtask/src/tasks.rs @@ -1,4 +1,5 @@ pub mod clippy; +pub mod generate_workflow; pub mod licenses; pub mod package_conformity; pub mod publish_gpui; diff --git a/tooling/xtask/src/tasks/generate_workflow.rs b/tooling/xtask/src/tasks/generate_workflow.rs new file mode 100644 index 00000000000000..375ba461e068f1 --- /dev/null +++ b/tooling/xtask/src/tasks/generate_workflow.rs @@ -0,0 +1,41 @@ +use anyhow::Result; +use clap::Parser; + +use gh_workflow::*; + +#[derive(Parser)] +pub struct GenerateWorkflowArgs {} + +pub fn run_generate_workflow(_args: GenerateWorkflowArgs) -> Result<()> { + // Create the "Run tests" composite action workflow + let workflow = Workflow::default().name("Run tests").add_job( + "run_tests", + Job::default() + .add_step(Step::new("Install Rust").run("cargo install cargo-nextest --locked")) + .add_step( + Step::new("Install Node") + .uses( + "actions", + "setup-node", + "49933ea5288caeca8642d1e84afbd3f7d6820020", + ) + .add_with(("node-version", "18")), + ) + .add_step( + Step::new("Limit target directory size") + .run("script/clear-target-dir-if-larger-than ${{ env.MAX_SIZE }}") + .env(("MAX_SIZE", "${{ runner.os == 'macOS' && 300 || 100 }}")), + ) + .add_step(Step::new("Run tests").run( + "cargo nextest run --workspace --no-fail-fast --failure-output immediate-final", + )), + ); + + // Generate and print the workflow YAML + let yaml = workflow + .to_string() + .map_err(|e| anyhow::anyhow!("{:?}", e))?; + println!("{}", yaml); + + Ok(()) +} From f32fc2bfd576be1b79c6ca74d54d17019fa3a154 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 24 Oct 2025 23:13:25 -0600 Subject: [PATCH 02/12] Try using gh_workflow to generate workflows --- .github/workflows/danger.yml | 60 ++++++------- Cargo.lock | 33 ++++++- Cargo.toml | 2 +- crates/gpui/Cargo.toml | 4 +- tooling/xtask/Cargo.toml | 2 + tooling/xtask/src/tasks/generate_workflow.rs | 53 +++++------ .../src/tasks/generate_workflow/runners.rs | 9 ++ .../src/tasks/generate_workflow/steps.rs | 88 +++++++++++++++++++ .../src/tasks/generate_workflow/workflows.rs | 30 +++++++ 9 files changed, 211 insertions(+), 70 deletions(-) create mode 100644 tooling/xtask/src/tasks/generate_workflow/runners.rs create mode 100644 tooling/xtask/src/tasks/generate_workflow/steps.rs create mode 100644 tooling/xtask/src/tasks/generate_workflow/workflows.rs diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 3f84179278d1ba..03f17487c32fdd 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -1,42 +1,36 @@ +# generated `cargo xtask workflows`. Do not edit. name: Danger - on: pull_request: - branches: [main] types: - - opened - - synchronize - - reopened - - edited - + - opened + - synchronize + - reopened + - edited + branches: + - main jobs: danger: if: github.repository_owner == 'zed-industries' runs-on: namespace-profile-2x4-ubuntu-2404 - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - - - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - with: - version: 9 - - - name: Setup Node - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 - with: - node-version: "20" - cache: "pnpm" - cache-dependency-path: "script/danger/pnpm-lock.yaml" - - - run: pnpm install --dir script/danger - - - name: Run Danger - run: pnpm run --dir script/danger danger ci - env: - # This GitHub token is not used, but the value needs to be here to prevent - # Danger from throwing an error. - GITHUB_TOKEN: "not_a_real_token" - # All requests are instead proxied through an instance of - # https://github.com/maxdeviant/danger-proxy that allows Danger to securely - # authenticate with GitHub while still being able to run on PRs from forks. - DANGER_GITHUB_API_BASE_URL: "https://danger-proxy.fly.dev/github" + - name: steps::checkout_repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - name: steps::setup_pnpm + uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 + with: + version: '9' + - name: steps::danger::setup_node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version: '20' + cache: pnpm + cache-dependency-path: script/danger/pnpm-lock.yaml + - name: steps::danger::install_deps + run: pnpm install --dir script/danger + shell: bash -euxo pipefail {0} + - name: steps::danger::run + run: pnpm run --dir script/danger danger ci + shell: bash -euxo pipefail {0} + env: + DANGER_GITHUB_API_BASE_URL: https://danger-proxy.fly.dev/github diff --git a/Cargo.lock b/Cargo.lock index 714c40fe7d273c..1c322c26234385 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6952,6 +6952,22 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gh-workflow" +version = "0.8.0" +dependencies = [ + "async-trait", + "derive_more 2.0.1", + "derive_setters", + "gh-workflow-macros 0.8.0", + "indexmap 2.11.4", + "merge", + "serde", + "serde_json", + "serde_yaml", + "strum_macros 0.27.2", +] + [[package]] name = "gh-workflow" version = "0.8.0" @@ -6961,7 +6977,7 @@ dependencies = [ "async-trait", "derive_more 2.0.1", "derive_setters", - "gh-workflow-macros", + "gh-workflow-macros 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 2.11.4", "merge", "serde", @@ -6970,6 +6986,15 @@ dependencies = [ "strum_macros 0.27.2", ] +[[package]] +name = "gh-workflow-macros" +version = "0.8.0" +dependencies = [ + "heck 0.5.0", + "quote", + "syn 2.0.106", +] + [[package]] name = "gh-workflow-macros" version = "0.8.0" @@ -20904,11 +20929,13 @@ name = "xtask" version = "0.1.0" dependencies = [ "anyhow", + "backtrace", "cargo_metadata", "cargo_toml", "clap", - "gh-workflow", + "gh-workflow 0.8.0", "indoc", + "serde_json", "toml 0.8.23", "toml_edit 0.22.27", ] @@ -21139,7 +21166,7 @@ dependencies = [ "file_finder", "fs", "futures 0.3.31", - "gh-workflow", + "gh-workflow 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "git", "git_hosting_providers", "git_ui", diff --git a/Cargo.toml b/Cargo.toml index 623314cc327bc3..556488aa8845ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -506,7 +506,7 @@ fork = "0.2.0" futures = "0.3" futures-batch = "0.6.1" futures-lite = "1.13" -gh-workflow = "0.8.0" +gh-workflow = { path = "../../rust/gh-workflow/crates/gh-workflow"} git2 = { version = "0.20.1", default-features = false } globset = "0.4" handlebars = "4.3" diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index af23a336f6230a..bba9e3bd1cde78 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -85,7 +85,7 @@ doctest = false [dependencies] anyhow.workspace = true async-task = "4.7" -backtrace = { version = "0.3", optional = true } +backtrace = { workspace = true, optional = true } blade-graphics = { workspace = true, optional = true } blade-macros = { workspace = true, optional = true } blade-util = { workspace = true, optional = true } @@ -234,7 +234,7 @@ windows-numerics = "0.2" windows-registry = "0.5" [dev-dependencies] -backtrace = "0.3" +backtrace.workspace = true collections = { workspace = true, features = ["test-support"] } env_logger.workspace = true http_client = { workspace = true, features = ["test-support"] } diff --git a/tooling/xtask/Cargo.toml b/tooling/xtask/Cargo.toml index f51a24f3e97b2e..9d040b7b6f0659 100644 --- a/tooling/xtask/Cargo.toml +++ b/tooling/xtask/Cargo.toml @@ -10,10 +10,12 @@ workspace = true [dependencies] anyhow.workspace = true +backtrace.workspace = true cargo_metadata.workspace = true cargo_toml.workspace = true clap = { workspace = true, features = ["derive"] } toml.workspace = true indoc.workspace = true +serde_json.workspace = true toml_edit.workspace = true gh-workflow.workspace = true diff --git a/tooling/xtask/src/tasks/generate_workflow.rs b/tooling/xtask/src/tasks/generate_workflow.rs index 375ba461e068f1..4bb22328460960 100644 --- a/tooling/xtask/src/tasks/generate_workflow.rs +++ b/tooling/xtask/src/tasks/generate_workflow.rs @@ -1,41 +1,32 @@ -use anyhow::Result; +use anyhow::{Context, Result}; use clap::Parser; +use std::fs; +use std::path::Path; -use gh_workflow::*; +mod runners; +mod steps; +mod workflows; + +use workflows::*; #[derive(Parser)] pub struct GenerateWorkflowArgs {} -pub fn run_generate_workflow(_args: GenerateWorkflowArgs) -> Result<()> { - // Create the "Run tests" composite action workflow - let workflow = Workflow::default().name("Run tests").add_job( - "run_tests", - Job::default() - .add_step(Step::new("Install Rust").run("cargo install cargo-nextest --locked")) - .add_step( - Step::new("Install Node") - .uses( - "actions", - "setup-node", - "49933ea5288caeca8642d1e84afbd3f7d6820020", - ) - .add_with(("node-version", "18")), - ) - .add_step( - Step::new("Limit target directory size") - .run("script/clear-target-dir-if-larger-than ${{ env.MAX_SIZE }}") - .env(("MAX_SIZE", "${{ runner.os == 'macOS' && 300 || 100 }}")), - ) - .add_step(Step::new("Run tests").run( - "cargo nextest run --workspace --no-fail-fast --failure-output immediate-final", - )), - ); +pub fn run_generate_workflow(_: GenerateWorkflowArgs) -> Result<()> { + let dir = Path::new(".github/workflows"); + + let workflows = vec![("danger.yml", danger())]; + fs::create_dir_all(dir) + .with_context(|| format!("Failed to create directory: {}", dir.display()))?; - // Generate and print the workflow YAML - let yaml = workflow - .to_string() - .map_err(|e| anyhow::anyhow!("{:?}", e))?; - println!("{}", yaml); + for (filename, workflow) in workflows { + let content = workflow + .to_string() + .map_err(|e| anyhow::anyhow!("{}: {:?}", filename, e))?; + let content = format!("# generated `cargo xtask workflows`. Do not edit.\n{content}"); + let file_path = dir.join(filename); + fs::write(&file_path, content)?; + } Ok(()) } diff --git a/tooling/xtask/src/tasks/generate_workflow/runners.rs b/tooling/xtask/src/tasks/generate_workflow/runners.rs new file mode 100644 index 00000000000000..74067c05f569b2 --- /dev/null +++ b/tooling/xtask/src/tasks/generate_workflow/runners.rs @@ -0,0 +1,9 @@ +pub const LINUX_CHEAP: Runner = Runner("namespace-profile-2x4-ubuntu-2404"); + +pub struct Runner(&'static str); + +impl Into for Runner { + fn into(self) -> gh_workflow::RunsOn { + self.0.into() + } +} diff --git a/tooling/xtask/src/tasks/generate_workflow/steps.rs b/tooling/xtask/src/tasks/generate_workflow/steps.rs new file mode 100644 index 00000000000000..11e862eb8d8ce9 --- /dev/null +++ b/tooling/xtask/src/tasks/generate_workflow/steps.rs @@ -0,0 +1,88 @@ +use gh_workflow::*; + +pub fn checkout_repo() -> Step { + named::uses( + "actions", + "checkout", + "11bd71901bbe5b1630ceea73d27597364c9af683", // v4 + ) +} + +pub fn setup_pnpm() -> Step { + named::uses( + "pnpm", + "action-setup", + "fe02b34f77f8bc703788d5817da081398fad5dd2", // v4.0.0 + ) + .add_with(("version", "9")) +} + +pub mod danger { + use super::*; + + pub fn setup_node() -> Step { + named::uses( + "actions", + "setup-node", + "49933ea5288caeca8642d1e84afbd3f7d6820020", // v4 + ) + .add_with(("node-version", "20")) + .add_with(("cache", "pnpm")) + .add_with(("cache-dependency-path", "script/danger/pnpm-lock.yaml")) + } + + pub fn install_deps() -> Step { + named::run("pnpm install --dir script/danger") + } + + pub fn run() -> Step { + named::run("pnpm run --dir script/danger danger ci") + // This GitHub token is not used, but the value needs to be here to prevent + // Danger from throwing an error. + .env(("GITHUB_TOKEN", "not_a_real_token")) + // All requests are instead proxied through an instance of + // https://github.com/maxdeviant/danger-proxy that allows Danger to securely + // authenticate with GitHub while still being able to run on PRs from forks. + .env(( + "DANGER_GITHUB_API_BASE_URL", + "https://danger-proxy.fly.dev/github", + )) + } +} + +// (janky) helpers to generate steps with a name that coresponds +// to the name of the calling function. +mod named { + use gh_workflow::*; + + pub(super) fn uses(owner: &str, repo: &str, ref_: &str) -> Step { + Step::new(function_name(1)).uses(owner, repo, ref_) + } + + pub(super) fn run(script: &str) -> Step { + Step::new(function_name(1)) + .run(script) + .shell("bash -euxo pipefail {0}") + } + + fn function_name(i: usize) -> String { + let mut name = "".to_string(); + let mut count = 0; + backtrace::trace(|frame| { + if count < i + 3 { + count += 1; + return true; + } + backtrace::resolve_frame(frame, |cb| { + if let Some(s) = cb.name() { + name = s.to_string() + } + }); + false + }); + name.split("::") + .skip_while(|s| s != &"steps") + .collect::>() + .join("::") + } +} diff --git a/tooling/xtask/src/tasks/generate_workflow/workflows.rs b/tooling/xtask/src/tasks/generate_workflow/workflows.rs new file mode 100644 index 00000000000000..8e8b434eb6b9fe --- /dev/null +++ b/tooling/xtask/src/tasks/generate_workflow/workflows.rs @@ -0,0 +1,30 @@ +use gh_workflow::*; + +use super::{runners, steps}; + +/// Generates the danger.yml workflow +pub fn danger() -> Workflow { + Workflow::default() + .name("Danger") + .on( + Event::default().pull_request(PullRequest::default().add_branch("main").types([ + PullRequestType::Opened, + PullRequestType::Synchronize, + PullRequestType::Reopened, + PullRequestType::Edited, + ])), + ) + .add_job( + "danger", + Job::default() + .cond(Expression::new( + "github.repository_owner == 'zed-industries'", + )) + .runs_on(runners::LINUX_CHEAP) + .add_step(steps::checkout_repo()) + .add_step(steps::setup_pnpm()) + .add_step(steps::danger::setup_node()) + .add_step(steps::danger::install_deps()) + .add_step(steps::danger::run()), + ) +} From a3647e4486542c6a08ff5a2828d9b9a4dd42373b Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sat, 25 Oct 2025 00:08:03 -0600 Subject: [PATCH 03/12] Convert nix too --- .github/workflows/nix.yml | 122 ++++++++++-------- Cargo.lock | 1 + tooling/xtask/Cargo.toml | 1 + tooling/xtask/src/main.rs | 4 +- tooling/xtask/src/tasks.rs | 2 +- .../src/tasks/generate_workflow/runners.rs | 9 -- .../src/tasks/generate_workflow/workflows.rs | 30 ----- .../{generate_workflow.rs => workflows.rs} | 5 +- tooling/xtask/src/tasks/workflows/runners.rs | 17 +++ .../{generate_workflow => workflows}/steps.rs | 54 ++++++++ tooling/xtask/src/tasks/workflows/vars.rs | 17 +++ .../xtask/src/tasks/workflows/workflows.rs | 105 +++++++++++++++ 12 files changed, 267 insertions(+), 100 deletions(-) delete mode 100644 tooling/xtask/src/tasks/generate_workflow/runners.rs delete mode 100644 tooling/xtask/src/tasks/generate_workflow/workflows.rs rename tooling/xtask/src/tasks/{generate_workflow.rs => workflows.rs} (83%) create mode 100644 tooling/xtask/src/tasks/workflows/runners.rs rename tooling/xtask/src/tasks/{generate_workflow => workflows}/steps.rs (61%) create mode 100644 tooling/xtask/src/tasks/workflows/vars.rs create mode 100644 tooling/xtask/src/tasks/workflows/workflows.rs diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index e682ce5890b86e..df698425319e4f 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -1,69 +1,79 @@ -name: "Nix build" - +# generated `cargo xtask workflows`. Do not edit. +name: Nix build on: workflow_call: inputs: - flake-output: - type: string - default: "default" cachix-filter: type: string - default: "" - + flake-output: + type: string + default: default jobs: - nix-build: + nix-build-linux-x86: + if: github.repository_owner == 'zed-industries' + runs-on: namespace-profile-16x32-ubuntu-2204 + env: + ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }} + ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_MINIDUMP_ENDPOINT }} + ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }} + GIT_LFS_SKIP_SMUDGE: '1' + steps: + - name: steps::checkout_repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + clean: 'false' + - name: steps::nix::install_nix + uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - name: steps::nix::cachix_action + uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad + with: + name: zed + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + pushFilter: ${{ inputs.cachix-filter }} + cachixArgs: -v + - name: steps::nix::build + run: nix build .#${{ inputs.flake-output }} -L --accept-flake-config + shell: bash -euxo pipefail {0} timeout-minutes: 60 - name: (${{ matrix.system.os }}) Nix Build - continue-on-error: true # TODO: remove when we want this to start blocking CI - strategy: - fail-fast: false - matrix: - system: - - os: x86 Linux - runner: namespace-profile-16x32-ubuntu-2204 - install_nix: true - - os: arm Mac - runner: [macOS, ARM64, test] - install_nix: false + continue-on-error: true + nix-build-mac-arm: if: github.repository_owner == 'zed-industries' - runs-on: ${{ matrix.system.runner }} + runs-on: + - macOS + - ARM64 + - test env: ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }} - ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }} + ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_MINIDUMP_ENDPOINT }} ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }} - GIT_LFS_SKIP_SMUDGE: 1 # breaks the livekit rust sdk examples which we don't actually depend on + GIT_LFS_SKIP_SMUDGE: '1' steps: - - name: Checkout repo - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - with: - clean: false - - # on our macs we manually install nix. for some reason the cachix action is running - # under a non-login /bin/bash shell which doesn't source the proper script to add the - # nix profile to PATH, so we manually add them here - - name: Set path - if: ${{ ! matrix.system.install_nix }} - run: | - echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH" - echo "/Users/administrator/.nix-profile/bin" >> "$GITHUB_PATH" - - - uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31 - if: ${{ matrix.system.install_nix }} - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16 - with: - name: zed - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - pushFilter: "${{ inputs.cachix-filter }}" - cachixArgs: "-v" - - - run: nix build .#${{ inputs.flake-output }} -L --accept-flake-config - - - name: Limit /nix/store to 50GB on macs - if: ${{ ! matrix.system.install_nix }} - run: | - if [ "$(du -sm /nix/store | cut -f1)" -gt 50000 ]; then + - name: steps::checkout_repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + clean: 'false' + - name: steps::nix::set_path + run: | + echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH" + echo "/Users/administrator/.nix-profile/bin" >> "$GITHUB_PATH" + shell: bash -euxo pipefail {0} + - name: steps::nix::cachix_action + uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad + with: + name: zed + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + pushFilter: ${{ inputs.cachix-filter }} + cachixArgs: -v + - name: steps::nix::build + run: nix build .#${{ inputs.flake-output }} -L --accept-flake-config + shell: bash -euxo pipefail {0} + - name: steps::nix::limit_store + run: |- + if [ "$(du -sm /nix/store | cut -f1)" -gt 50000 ]; then nix-collect-garbage -d || true - fi + fi + shell: bash -euxo pipefail {0} + timeout-minutes: 60 + continue-on-error: true diff --git a/Cargo.lock b/Cargo.lock index 1c322c26234385..474d8cece3987b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20934,6 +20934,7 @@ dependencies = [ "cargo_toml", "clap", "gh-workflow 0.8.0", + "indexmap 2.11.4", "indoc", "serde_json", "toml 0.8.23", diff --git a/tooling/xtask/Cargo.toml b/tooling/xtask/Cargo.toml index 9d040b7b6f0659..4a77c8436d87ab 100644 --- a/tooling/xtask/Cargo.toml +++ b/tooling/xtask/Cargo.toml @@ -16,6 +16,7 @@ cargo_toml.workspace = true clap = { workspace = true, features = ["derive"] } toml.workspace = true indoc.workspace = true +indexmap.workspace = true serde_json.workspace = true toml_edit.workspace = true gh-workflow.workspace = true diff --git a/tooling/xtask/src/main.rs b/tooling/xtask/src/main.rs index 52f2285e0a80f5..6f83927d6730cb 100644 --- a/tooling/xtask/src/main.rs +++ b/tooling/xtask/src/main.rs @@ -20,7 +20,7 @@ enum CliCommand { PackageConformity(tasks::package_conformity::PackageConformityArgs), /// Publishes GPUI and its dependencies to crates.io. PublishGpui(tasks::publish_gpui::PublishGpuiArgs), - GenerateWorkflow(tasks::generate_workflow::GenerateWorkflowArgs), + Workflows(tasks::workflows::GenerateWorkflowArgs), } fn main() -> Result<()> { @@ -33,6 +33,6 @@ fn main() -> Result<()> { tasks::package_conformity::run_package_conformity(args) } CliCommand::PublishGpui(args) => tasks::publish_gpui::run_publish_gpui(args), - CliCommand::GenerateWorkflow(args) => tasks::generate_workflow::run_generate_workflow(args), + CliCommand::Workflows(args) => tasks::workflows::run_workflows(args), } } diff --git a/tooling/xtask/src/tasks.rs b/tooling/xtask/src/tasks.rs index e5cbaa2262ac6f..01b3907f048685 100644 --- a/tooling/xtask/src/tasks.rs +++ b/tooling/xtask/src/tasks.rs @@ -1,5 +1,5 @@ pub mod clippy; -pub mod generate_workflow; pub mod licenses; pub mod package_conformity; pub mod publish_gpui; +pub mod workflows; diff --git a/tooling/xtask/src/tasks/generate_workflow/runners.rs b/tooling/xtask/src/tasks/generate_workflow/runners.rs deleted file mode 100644 index 74067c05f569b2..00000000000000 --- a/tooling/xtask/src/tasks/generate_workflow/runners.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub const LINUX_CHEAP: Runner = Runner("namespace-profile-2x4-ubuntu-2404"); - -pub struct Runner(&'static str); - -impl Into for Runner { - fn into(self) -> gh_workflow::RunsOn { - self.0.into() - } -} diff --git a/tooling/xtask/src/tasks/generate_workflow/workflows.rs b/tooling/xtask/src/tasks/generate_workflow/workflows.rs deleted file mode 100644 index 8e8b434eb6b9fe..00000000000000 --- a/tooling/xtask/src/tasks/generate_workflow/workflows.rs +++ /dev/null @@ -1,30 +0,0 @@ -use gh_workflow::*; - -use super::{runners, steps}; - -/// Generates the danger.yml workflow -pub fn danger() -> Workflow { - Workflow::default() - .name("Danger") - .on( - Event::default().pull_request(PullRequest::default().add_branch("main").types([ - PullRequestType::Opened, - PullRequestType::Synchronize, - PullRequestType::Reopened, - PullRequestType::Edited, - ])), - ) - .add_job( - "danger", - Job::default() - .cond(Expression::new( - "github.repository_owner == 'zed-industries'", - )) - .runs_on(runners::LINUX_CHEAP) - .add_step(steps::checkout_repo()) - .add_step(steps::setup_pnpm()) - .add_step(steps::danger::setup_node()) - .add_step(steps::danger::install_deps()) - .add_step(steps::danger::run()), - ) -} diff --git a/tooling/xtask/src/tasks/generate_workflow.rs b/tooling/xtask/src/tasks/workflows.rs similarity index 83% rename from tooling/xtask/src/tasks/generate_workflow.rs rename to tooling/xtask/src/tasks/workflows.rs index 4bb22328460960..e46a62993b1926 100644 --- a/tooling/xtask/src/tasks/generate_workflow.rs +++ b/tooling/xtask/src/tasks/workflows.rs @@ -5,6 +5,7 @@ use std::path::Path; mod runners; mod steps; +mod vars; mod workflows; use workflows::*; @@ -12,10 +13,10 @@ use workflows::*; #[derive(Parser)] pub struct GenerateWorkflowArgs {} -pub fn run_generate_workflow(_: GenerateWorkflowArgs) -> Result<()> { +pub fn run_workflows(_: GenerateWorkflowArgs) -> Result<()> { let dir = Path::new(".github/workflows"); - let workflows = vec![("danger.yml", danger())]; + let workflows = vec![("danger.yml", danger()), ("nix.yml", nix())]; fs::create_dir_all(dir) .with_context(|| format!("Failed to create directory: {}", dir.display()))?; diff --git a/tooling/xtask/src/tasks/workflows/runners.rs b/tooling/xtask/src/tasks/workflows/runners.rs new file mode 100644 index 00000000000000..fc92c5e258b154 --- /dev/null +++ b/tooling/xtask/src/tasks/workflows/runners.rs @@ -0,0 +1,17 @@ +pub const LINUX_CHEAP: Runner = Runner::Profile("namespace-profile-2x4-ubuntu-2404"); +pub const LINUX_DEFAULT: Runner = Runner::Profile("namespace-profile-16x32-ubuntu-2204"); +pub const MAC_DEFAULT: Runner = Runner::Labelled(&["macOS", "ARM64", "test"]); + +pub enum Runner { + Profile(&'static str), + Labelled(&'static [&'static str]), +} + +impl Into for Runner { + fn into(self) -> gh_workflow::RunsOn { + match self { + Runner::Profile(profile) => profile.into(), + Runner::Labelled(items) => items.into(), + } + } +} diff --git a/tooling/xtask/src/tasks/generate_workflow/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs similarity index 61% rename from tooling/xtask/src/tasks/generate_workflow/steps.rs rename to tooling/xtask/src/tasks/workflows/steps.rs index 11e862eb8d8ce9..06ed623e5c5dbf 100644 --- a/tooling/xtask/src/tasks/generate_workflow/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -50,6 +50,60 @@ pub mod danger { } } +pub mod nix { + use indoc::indoc; + + use crate::tasks::workflows::vars; + + use super::*; + + // on our macs we manually install nix. for some reason the cachix action is running + // under a non-login /bin/bash shell which doesn't source the proper script to add the + // nix profile to PATH, so we manually add them here + pub fn set_path() -> Step { + named::run(indoc! {r#" + echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH" + echo "/Users/administrator/.nix-profile/bin" >> "$GITHUB_PATH" + "#}) + } + + pub fn install_nix() -> Step { + named::uses( + "cachix", + "install-nix-action", + "02a151ada4993995686f9ed4f1be7cfbb229e56f", // v31 + ) + .add_with(("github_access_token", vars::GITHUB_TOKEN)) + } + + pub fn cachix_action(cachix_filter: &str) -> Step { + named::uses( + "cachix", + "cachix-action", + "0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad", // v16 + ) + .add_with(("name", "zed")) + .add_with(("authToken", vars::CACHIX_AUTH_TOKEN)) + .add_with(("pushFilter", cachix_filter)) + .add_with(("cachixArgs", "-v")) + } + + pub fn build(flake_output: &str) -> Step { + named::run(&format!( + "nix build .#{} -L --accept-flake-config", + flake_output + )) + } + + pub fn limit_store() -> Step { + named::run(indoc! {r#" + if [ "$(du -sm /nix/store | cut -f1)" -gt 50000 ]; then + nix-collect-garbage -d || true + fi"# + }) + } +} + // (janky) helpers to generate steps with a name that coresponds // to the name of the calling function. mod named { diff --git a/tooling/xtask/src/tasks/workflows/vars.rs b/tooling/xtask/src/tasks/workflows/vars.rs new file mode 100644 index 00000000000000..00136b49b5c62e --- /dev/null +++ b/tooling/xtask/src/tasks/workflows/vars.rs @@ -0,0 +1,17 @@ +use gh_workflow::WorkflowCallInput; + +macro_rules! secret { + ($secret_name:ident) => { + pub const $secret_name: &str = concat!("${{ secrets.", stringify!($secret_name), " }}"); + }; +} + +secret!(GITHUB_TOKEN); +secret!(CACHIX_AUTH_TOKEN); +secret!(ZED_CLIENT_CHECKSUM_SEED); +secret!(ZED_MINIDUMP_ENDPOINT); +secret!(ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON); + +pub fn input(name: &str, input: WorkflowCallInput) -> (String, (&str, WorkflowCallInput)) { + return (format!("${{{{ inputs.{name} }}}}"), (name, input)); +} diff --git a/tooling/xtask/src/tasks/workflows/workflows.rs b/tooling/xtask/src/tasks/workflows/workflows.rs new file mode 100644 index 00000000000000..fe9ed1c874becc --- /dev/null +++ b/tooling/xtask/src/tasks/workflows/workflows.rs @@ -0,0 +1,105 @@ +use gh_workflow::*; +use indexmap::IndexMap; + +use super::{runners, steps, vars}; + +/// Generates the danger.yml workflow +pub fn danger() -> Workflow { + Workflow::default() + .name("Danger") + .on( + Event::default().pull_request(PullRequest::default().add_branch("main").types([ + PullRequestType::Opened, + PullRequestType::Synchronize, + PullRequestType::Reopened, + PullRequestType::Edited, + ])), + ) + .add_job( + "danger", + Job::default() + .cond(Expression::new( + "github.repository_owner == 'zed-industries'", + )) + .runs_on(runners::LINUX_CHEAP) + .add_step(steps::checkout_repo()) + .add_step(steps::setup_pnpm()) + .add_step(steps::danger::setup_node()) + .add_step(steps::danger::install_deps()) + .add_step(steps::danger::run()), + ) +} + +/// Generates the nix.yml workflow +pub fn nix() -> Workflow { + let env: IndexMap<_, _> = [ + ("ZED_CLIENT_CHECKSUM_SEED", vars::ZED_CLIENT_CHECKSUM_SEED), + ("ZED_MINIDUMP_ENDPOINT", vars::ZED_MINIDUMP_ENDPOINT), + ( + "ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON", + vars::ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON, + ), + ("GIT_LFS_SKIP_SMUDGE", "1"), // breaks the livekit rust sdk examples which we don't actually depend on + ] + .into_iter() + .map(|(key, value)| (key.into(), value.into())) + .collect(); + + // todo!() instead of having these as optional YAML inputs, + // should we just generate two copies of the job (one for release-nightly + // and one for CI?) + let (input_flake_output, flake_output) = vars::input( + "flake-output", + WorkflowCallInput { + input_type: "string".into(), + default: Some("default".into()), + ..Default::default() + }, + ); + let (input_cachix_filter, cachix_filter) = vars::input( + "cachix-filter", + WorkflowCallInput { + input_type: "string".into(), + ..Default::default() + }, + ); + + Workflow::default() + .name("Nix build") + .on(Event::default().workflow_call( + WorkflowCall::default() + .add_input(flake_output.0, flake_output.1) + .add_input(cachix_filter.0, cachix_filter.1), + )) + .add_job( + "nix-build-linux-x86", + Job::default() + .timeout_minutes(60u32) + .continue_on_error(true) + .cond(Expression::new( + "github.repository_owner == 'zed-industries'", + )) + .runs_on(runners::LINUX_DEFAULT) + .env(env.clone()) + .add_step(steps::checkout_repo().with(("clean", "false"))) + .add_step(steps::nix::install_nix()) + .add_step(steps::nix::cachix_action(&input_cachix_filter)) + .add_step(steps::nix::build(&input_flake_output)), + ) + .add_job( + "nix-build-mac-arm", + Job::default() + .timeout_minutes(60u32) + .continue_on_error(true) + .cond(Expression::new( + "github.repository_owner == 'zed-industries'", + )) + .runs_on(runners::MAC_DEFAULT) + .env(env) + .add_step(steps::checkout_repo().with(("clean", "false"))) + .add_step(steps::nix::set_path()) + .add_step(steps::nix::cachix_action(&input_cachix_filter)) + .add_step(steps::nix::build(&input_flake_output)) + .add_step(steps::nix::limit_store()), + ) +} From 3425fceecad35032019a458865b0fccec7e28f99 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sat, 25 Oct 2025 00:10:57 -0600 Subject: [PATCH 04/12] Fix --- Cargo.lock | 16 +++++++++------- Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 474d8cece3987b..6dabd84a1d2a86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6955,11 +6955,13 @@ dependencies = [ [[package]] name = "gh-workflow" version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fffeec7bd9dfa73ffe1db38979cca5716ec6ffd944f03fae65fee81f16082ae" dependencies = [ "async-trait", "derive_more 2.0.1", "derive_setters", - "gh-workflow-macros 0.8.0", + "gh-workflow-macros 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 2.11.4", "merge", "serde", @@ -6971,13 +6973,12 @@ dependencies = [ [[package]] name = "gh-workflow" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fffeec7bd9dfa73ffe1db38979cca5716ec6ffd944f03fae65fee81f16082ae" +source = "git+https://github.com/ConradIrwin/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105#a0b197dd77c0ed2390c150e601f9d4f9a0ca7105" dependencies = [ "async-trait", "derive_more 2.0.1", "derive_setters", - "gh-workflow-macros 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gh-workflow-macros 0.8.0 (git+https://github.com/ConradIrwin/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105)", "indexmap 2.11.4", "merge", "serde", @@ -6989,6 +6990,8 @@ dependencies = [ [[package]] name = "gh-workflow-macros" version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eafb4d2a1005d4ac6d041ce929af10be1de1e1eae478795d9d634b84ccf8191" dependencies = [ "heck 0.5.0", "quote", @@ -6998,8 +7001,7 @@ dependencies = [ [[package]] name = "gh-workflow-macros" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eafb4d2a1005d4ac6d041ce929af10be1de1e1eae478795d9d634b84ccf8191" +source = "git+https://github.com/ConradIrwin/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105#a0b197dd77c0ed2390c150e601f9d4f9a0ca7105" dependencies = [ "heck 0.5.0", "quote", @@ -20933,7 +20935,7 @@ dependencies = [ "cargo_metadata", "cargo_toml", "clap", - "gh-workflow 0.8.0", + "gh-workflow 0.8.0 (git+https://github.com/ConradIrwin/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105)", "indexmap 2.11.4", "indoc", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 556488aa8845ce..4c10a6232ba392 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -506,7 +506,7 @@ fork = "0.2.0" futures = "0.3" futures-batch = "0.6.1" futures-lite = "1.13" -gh-workflow = { path = "../../rust/gh-workflow/crates/gh-workflow"} +gh-workflow = { git = "https://github.com/ConradIrwin/gh-workflow", rev = "a0b197dd77c0ed2390c150e601f9d4f9a0ca7105" } git2 = { version = "0.20.1", default-features = false } globset = "0.4" handlebars = "4.3" From 2a082136c9bd3b5c4825874cf88ddb2edab88544 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sat, 25 Oct 2025 00:12:45 -0600 Subject: [PATCH 05/12] Fix env :/ --- tooling/xtask/src/tasks/workflows/steps.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index 06ed623e5c5dbf..c0dc42fbe5af0f 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -39,11 +39,11 @@ pub mod danger { named::run("pnpm run --dir script/danger danger ci") // This GitHub token is not used, but the value needs to be here to prevent // Danger from throwing an error. - .env(("GITHUB_TOKEN", "not_a_real_token")) + .add_env(("GITHUB_TOKEN", "not_a_real_token")) // All requests are instead proxied through an instance of // https://github.com/maxdeviant/danger-proxy that allows Danger to securely // authenticate with GitHub while still being able to run on PRs from forks. - .env(( + .add_env(( "DANGER_GITHUB_API_BASE_URL", "https://danger-proxy.fly.dev/github", )) From 4f01f13b90d375aae2a4de4d77b893bcf5066ce1 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sat, 25 Oct 2025 00:13:28 -0600 Subject: [PATCH 06/12] similar... --- tooling/xtask/src/tasks/workflows/workflows.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tooling/xtask/src/tasks/workflows/workflows.rs b/tooling/xtask/src/tasks/workflows/workflows.rs index fe9ed1c874becc..1ff02e29e2dbfb 100644 --- a/tooling/xtask/src/tasks/workflows/workflows.rs +++ b/tooling/xtask/src/tasks/workflows/workflows.rs @@ -81,7 +81,7 @@ pub fn nix() -> Workflow { )) .runs_on(runners::LINUX_DEFAULT) .env(env.clone()) - .add_step(steps::checkout_repo().with(("clean", "false"))) + .add_step(steps::checkout_repo().add_with(("clean", "false"))) .add_step(steps::nix::install_nix()) .add_step(steps::nix::cachix_action(&input_cachix_filter)) .add_step(steps::nix::build(&input_flake_output)), @@ -96,7 +96,7 @@ pub fn nix() -> Workflow { )) .runs_on(runners::MAC_DEFAULT) .env(env) - .add_step(steps::checkout_repo().with(("clean", "false"))) + .add_step(steps::checkout_repo().add_with(("clean", "false"))) .add_step(steps::nix::set_path()) .add_step(steps::nix::cachix_action(&input_cachix_filter)) .add_step(steps::nix::build(&input_flake_output)) From 7b885e33bb4e5090c1ccf5b4b5ed036d5355584e Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sat, 25 Oct 2025 00:14:25 -0600 Subject: [PATCH 07/12] Ugh, actually regenerate --- .github/workflows/danger.yml | 1 + .github/workflows/nix.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 03f17487c32fdd..03afaef6ed3de8 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -33,4 +33,5 @@ jobs: run: pnpm run --dir script/danger danger ci shell: bash -euxo pipefail {0} env: + GITHUB_TOKEN: not_a_real_token DANGER_GITHUB_API_BASE_URL: https://danger-proxy.fly.dev/github diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index df698425319e4f..442018cdc6583a 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -3,11 +3,11 @@ name: Nix build on: workflow_call: inputs: - cachix-filter: - type: string flake-output: type: string default: default + cachix-filter: + type: string jobs: nix-build-linux-x86: if: github.repository_owner == 'zed-industries' From 40201fe1960a9d8f58214d3edc69e303270799c5 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 27 Oct 2025 11:15:06 -0600 Subject: [PATCH 08/12] Fix typos, move gh-workflow to zed --- Cargo.lock | 39 ++++----------------------------------- Cargo.toml | 2 +- crates/zed/Cargo.toml | 1 - tooling/xtask/Cargo.toml | 1 - 4 files changed, 5 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6dabd84a1d2a86..b57e66d55fa3c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6955,30 +6955,12 @@ dependencies = [ [[package]] name = "gh-workflow" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fffeec7bd9dfa73ffe1db38979cca5716ec6ffd944f03fae65fee81f16082ae" +source = "git+https://github.com/zed-industries/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105#a0b197dd77c0ed2390c150e601f9d4f9a0ca7105" dependencies = [ "async-trait", "derive_more 2.0.1", "derive_setters", - "gh-workflow-macros 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 2.11.4", - "merge", - "serde", - "serde_json", - "serde_yaml", - "strum_macros 0.27.2", -] - -[[package]] -name = "gh-workflow" -version = "0.8.0" -source = "git+https://github.com/ConradIrwin/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105#a0b197dd77c0ed2390c150e601f9d4f9a0ca7105" -dependencies = [ - "async-trait", - "derive_more 2.0.1", - "derive_setters", - "gh-workflow-macros 0.8.0 (git+https://github.com/ConradIrwin/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105)", + "gh-workflow-macros", "indexmap 2.11.4", "merge", "serde", @@ -6990,18 +6972,7 @@ dependencies = [ [[package]] name = "gh-workflow-macros" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eafb4d2a1005d4ac6d041ce929af10be1de1e1eae478795d9d634b84ccf8191" -dependencies = [ - "heck 0.5.0", - "quote", - "syn 2.0.106", -] - -[[package]] -name = "gh-workflow-macros" -version = "0.8.0" -source = "git+https://github.com/ConradIrwin/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105#a0b197dd77c0ed2390c150e601f9d4f9a0ca7105" +source = "git+https://github.com/zed-industries/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105#a0b197dd77c0ed2390c150e601f9d4f9a0ca7105" dependencies = [ "heck 0.5.0", "quote", @@ -20935,10 +20906,9 @@ dependencies = [ "cargo_metadata", "cargo_toml", "clap", - "gh-workflow 0.8.0 (git+https://github.com/ConradIrwin/gh-workflow?rev=a0b197dd77c0ed2390c150e601f9d4f9a0ca7105)", + "gh-workflow", "indexmap 2.11.4", "indoc", - "serde_json", "toml 0.8.23", "toml_edit 0.22.27", ] @@ -21169,7 +21139,6 @@ dependencies = [ "file_finder", "fs", "futures 0.3.31", - "gh-workflow 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "git", "git_hosting_providers", "git_ui", diff --git a/Cargo.toml b/Cargo.toml index 4c10a6232ba392..3338c8c1b929a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -506,7 +506,7 @@ fork = "0.2.0" futures = "0.3" futures-batch = "0.6.1" futures-lite = "1.13" -gh-workflow = { git = "https://github.com/ConradIrwin/gh-workflow", rev = "a0b197dd77c0ed2390c150e601f9d4f9a0ca7105" } +gh-workflow = { git = "https://github.com/zed-industries/gh-workflow", rev = "a0b197dd77c0ed2390c150e601f9d4f9a0ca7105" } git2 = { version = "0.20.1", default-features = false } globset = "0.4" handlebars = "4.3" diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index b70a0cd012814c..c84fa8261fe2ef 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -165,7 +165,6 @@ zeta.workspace = true zeta2.workspace = true zlog.workspace = true zlog_settings.workspace = true -gh-workflow = "0.8.0" [target.'cfg(target_os = "windows")'.dependencies] windows.workspace = true diff --git a/tooling/xtask/Cargo.toml b/tooling/xtask/Cargo.toml index 4a77c8436d87ab..7fc03a563e0a03 100644 --- a/tooling/xtask/Cargo.toml +++ b/tooling/xtask/Cargo.toml @@ -17,6 +17,5 @@ clap = { workspace = true, features = ["derive"] } toml.workspace = true indoc.workspace = true indexmap.workspace = true -serde_json.workspace = true toml_edit.workspace = true gh-workflow.workspace = true From de86ae22dc9afabbb68fd382fa5bc813448b7359 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 27 Oct 2025 11:21:47 -0600 Subject: [PATCH 09/12] More happier --- tooling/xtask/src/tasks/workflows/runners.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tooling/xtask/src/tasks/workflows/runners.rs b/tooling/xtask/src/tasks/workflows/runners.rs index fc92c5e258b154..cdc1f4c026e551 100644 --- a/tooling/xtask/src/tasks/workflows/runners.rs +++ b/tooling/xtask/src/tasks/workflows/runners.rs @@ -1,17 +1,11 @@ -pub const LINUX_CHEAP: Runner = Runner::Profile("namespace-profile-2x4-ubuntu-2404"); -pub const LINUX_DEFAULT: Runner = Runner::Profile("namespace-profile-16x32-ubuntu-2204"); -pub const MAC_DEFAULT: Runner = Runner::Labelled(&["macOS", "ARM64", "test"]); +pub const LINUX_CHEAP: Runner = Runner("namespace-profile-2x4-ubuntu-2404"); +pub const LINUX_DEFAULT: Runner = Runner("namespace-profile-16x32-ubuntu-2204"); +pub const MAC_DEFAULT: Runner = Runner("self-mini-macos"); -pub enum Runner { - Profile(&'static str), - Labelled(&'static [&'static str]), -} +pub struct Runner(&'static str); impl Into for Runner { fn into(self) -> gh_workflow::RunsOn { - match self { - Runner::Profile(profile) => profile.into(), - Runner::Labelled(items) => items.into(), - } + self.0.into() } } From 085385f61f19da98406c3aad28cd6fd80b165d0c Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 27 Oct 2025 12:32:52 -0600 Subject: [PATCH 10/12] Actually fix --- .github/workflows/nix.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 442018cdc6583a..7e6f559c28ed90 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -40,10 +40,7 @@ jobs: continue-on-error: true nix-build-mac-arm: if: github.repository_owner == 'zed-industries' - runs-on: - - macOS - - ARM64 - - test + runs-on: self-mini-macos env: ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }} ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_MINIDUMP_ENDPOINT }} From 9790593e13cea7db21d22ad7358fba382a2029b2 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 27 Oct 2025 12:33:40 -0600 Subject: [PATCH 11/12] hush little linter --- tooling/xtask/src/tasks/workflows/workflows.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/xtask/src/tasks/workflows/workflows.rs b/tooling/xtask/src/tasks/workflows/workflows.rs index 1ff02e29e2dbfb..4fe81270363038 100644 --- a/tooling/xtask/src/tasks/workflows/workflows.rs +++ b/tooling/xtask/src/tasks/workflows/workflows.rs @@ -45,7 +45,7 @@ pub fn nix() -> Workflow { .map(|(key, value)| (key.into(), value.into())) .collect(); - // todo!() instead of having these as optional YAML inputs, + // todo(ci) instead of having these as optional YAML inputs, // should we just generate two copies of the job (one for release-nightly // and one for CI?) let (input_flake_output, flake_output) = vars::input( From 4b9fdc762a6b772d7b08dc72af4c518b610c0e87 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 27 Oct 2025 13:04:45 -0600 Subject: [PATCH 12/12] typo --- tooling/xtask/src/tasks/workflows/steps.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index c0dc42fbe5af0f..5590a9ecf4e7c4 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -104,7 +104,7 @@ pub mod nix { } } -// (janky) helpers to generate steps with a name that coresponds +// (janky) helpers to generate steps with a name that corresponds // to the name of the calling function. mod named { use gh_workflow::*;