Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

ci: Reinstate run-nix label in addition to run-bundling (#58034)

Jakub Konkaaeb5d6d7ff97
diff --git a/.github/workflows/nix_build.yml b/.github/workflows/nix_build.yml
new file mode 100644
index 00000000000..f658634c06c
--- /dev/null
+++ b/.github/workflows/nix_build.yml
@@ -0,0 +1,97 @@
+# Generated from xtask::workflows::nix_build
+# Rebuild with `cargo xtask workflows`.
+name: nix_build
+env:
+ CARGO_TERM_COLOR: always
+ RUST_BACKTRACE: '1'
+on:
+ pull_request:
+ types:
+ - labeled
+ - synchronize
+jobs:
+ build_nix_linux_x86_64:
+ if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && ((github.event.action == 'labeled' && (github.event.label.name == 'run-nix' || github.event.label.name == 'run-bundling')) || (github.event.action == 'synchronize' && (contains(github.event.pull_request.labels.*.name, 'run-nix') || contains(github.event.pull_request.labels.*.name, 'run-bundling'))))
+ runs-on: namespace-profile-32x64-ubuntu-2004
+ env:
+ ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
+ ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_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@93cb6efe18208431cddfb8368fd83d5badbf9bfd
+ with:
+ clean: false
+ - name: steps::cache_nix_dependencies_namespace
+ uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
+ with:
+ cache: nix
+ - name: nix_build::build_nix::install_nix
+ uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f
+ with:
+ github_access_token: ${{ secrets.GITHUB_TOKEN }}
+ - name: nix_build::build_nix::cachix_action
+ uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad
+ with:
+ name: zed
+ authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ cachixArgs: -v
+ pushFilter: -zed-editor-[0-9.]*
+ - name: nix_build::build_nix::build
+ run: nix build .#default -L --accept-flake-config
+ timeout-minutes: 60
+ continue-on-error: true
+ build_nix_mac_aarch64:
+ if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && ((github.event.action == 'labeled' && (github.event.label.name == 'run-nix' || github.event.label.name == 'run-bundling')) || (github.event.action == 'synchronize' && (contains(github.event.pull_request.labels.*.name, 'run-nix') || contains(github.event.pull_request.labels.*.name, 'run-bundling'))))
+ runs-on: namespace-profile-mac-large
+ env:
+ ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
+ ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_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@93cb6efe18208431cddfb8368fd83d5badbf9bfd
+ with:
+ clean: false
+ - name: steps::cache_nix_store_macos
+ uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
+ with:
+ path: ~/nix-cache
+ - name: nix_build::build_nix::install_nix
+ uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f
+ with:
+ github_access_token: ${{ secrets.GITHUB_TOKEN }}
+ - name: nix_build::build_nix::configure_local_nix_cache
+ run: |
+ mkdir -p ~/nix-cache
+ echo "extra-substituters = file://$HOME/nix-cache?priority=10" | sudo tee -a /etc/nix/nix.conf
+ echo "require-sigs = false" | sudo tee -a /etc/nix/nix.conf
+ sudo launchctl kickstart -k system/org.nixos.nix-daemon
+ - name: nix_build::build_nix::cachix_action
+ uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad
+ with:
+ name: zed
+ authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ cachixArgs: -v
+ pushFilter: -zed-editor-[0-9.]*
+ - name: nix_build::build_nix::build
+ run: nix build .#default -L --accept-flake-config
+ - name: nix_build::build_nix::export_to_local_nix_cache
+ if: always()
+ run: |
+ if [ -L result ]; then
+ echo "Copying build closure to local binary cache..."
+ nix copy --to "file://$HOME/nix-cache" ./result || echo "Warning: nix copy to local cache failed"
+ else
+ echo "No build result found, skipping cache export."
+ fi
+ timeout-minutes: 60
+ continue-on-error: true
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
+ cancel-in-progress: true
+defaults:
+ run:
+ shell: bash -euxo pipefail {0}
diff --git a/.github/workflows/run_bundling.yml b/.github/workflows/run_bundling.yml
index bc7408f3a21..3d3d7a7ac51 100644
--- a/.github/workflows/run_bundling.yml
+++ b/.github/workflows/run_bundling.yml
@@ -264,85 +264,6 @@ jobs:
path: target/zed-remote-server-windows-x86_64.zip
if-no-files-found: error
timeout-minutes: 60
- build_nix_linux_x86_64:
- if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && ((github.event.action == 'labeled' && github.event.label.name == 'run-bundling') || (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'run-bundling')))
- runs-on: namespace-profile-32x64-ubuntu-2004
- env:
- ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
- ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_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@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- with:
- clean: false
- - name: steps::cache_nix_dependencies_namespace
- uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
- with:
- cache: nix
- - name: nix_build::build_nix::install_nix
- uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f
- with:
- github_access_token: ${{ secrets.GITHUB_TOKEN }}
- - name: nix_build::build_nix::cachix_action
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad
- with:
- name: zed
- authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- cachixArgs: -v
- pushFilter: -zed-editor-[0-9.]*
- - name: nix_build::build_nix::build
- run: nix build .#default -L --accept-flake-config
- timeout-minutes: 60
- continue-on-error: true
- build_nix_mac_aarch64:
- if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && ((github.event.action == 'labeled' && github.event.label.name == 'run-bundling') || (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'run-bundling')))
- runs-on: namespace-profile-mac-large
- env:
- ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
- ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_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@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- with:
- clean: false
- - name: steps::cache_nix_store_macos
- uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
- with:
- path: ~/nix-cache
- - name: nix_build::build_nix::install_nix
- uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f
- with:
- github_access_token: ${{ secrets.GITHUB_TOKEN }}
- - name: nix_build::build_nix::configure_local_nix_cache
- run: |
- mkdir -p ~/nix-cache
- echo "extra-substituters = file://$HOME/nix-cache?priority=10" | sudo tee -a /etc/nix/nix.conf
- echo "require-sigs = false" | sudo tee -a /etc/nix/nix.conf
- sudo launchctl kickstart -k system/org.nixos.nix-daemon
- - name: nix_build::build_nix::cachix_action
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad
- with:
- name: zed
- authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- cachixArgs: -v
- pushFilter: -zed-editor-[0-9.]*
- - name: nix_build::build_nix::build
- run: nix build .#default -L --accept-flake-config
- - name: nix_build::build_nix::export_to_local_nix_cache
- if: always()
- run: |
- if [ -L result ]; then
- echo "Copying build closure to local binary cache..."
- nix copy --to "file://$HOME/nix-cache" ./result || echo "Warning: nix copy to local cache failed"
- else
- echo "No build result found, skipping cache export."
- fi
- timeout-minutes: 60
- continue-on-error: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
diff --git a/tooling/xtask/src/tasks/workflows.rs b/tooling/xtask/src/tasks/workflows.rs
index 1043c1fc009..6f21be93907 100644
--- a/tooling/xtask/src/tasks/workflows.rs
+++ b/tooling/xtask/src/tasks/workflows.rs
@@ -237,6 +237,7 @@ pub fn run_workflows(args: GenerateWorkflowArgs) -> Result<()> {
WorkflowFile::zed(extension_auto_bump::extension_auto_bump),
WorkflowFile::zed(extension_tests::extension_tests),
WorkflowFile::zed(extension_workflow_rollout::extension_workflow_rollout),
+ WorkflowFile::zed(nix_build::nix_build),
WorkflowFile::zed(publish_extension_cli::publish_extension_cli),
WorkflowFile::zed(release::release),
WorkflowFile::zed(release_nightly::release_nightly),
diff --git a/tooling/xtask/src/tasks/workflows/nix_build.rs b/tooling/xtask/src/tasks/workflows/nix_build.rs
index 9e401ccac08..cc04ec5b855 100644
--- a/tooling/xtask/src/tasks/workflows/nix_build.rs
+++ b/tooling/xtask/src/tasks/workflows/nix_build.rs
@@ -1,11 +1,69 @@
use crate::tasks::workflows::{
runners::{Arch, Platform},
- steps::{CommonJobConditions, NamedJob},
+ steps::{CommonJobConditions, DEFAULT_REPOSITORY_OWNER_GUARD, NamedJob},
};
use super::{runners, steps, steps::named, vars};
use gh_workflow::*;
+/// Generates the nix_build.yml workflow, which builds the Nix package on PRs
+/// that carry the `run-nix` or `run-bundling` label. The Nix jobs live only
+/// here (not in run_bundling.yml) so that setting both labels doesn't build
+/// them twice.
+pub fn nix_build() -> Workflow {
+ let [nix_linux_x86_64, nix_mac_aarch64] = nix_pr_jobs(&["run-nix", "run-bundling"]);
+ named::workflow()
+ .on(Event::default().pull_request(
+ PullRequest::default().types([PullRequestType::Labeled, PullRequestType::Synchronize]),
+ ))
+ .concurrency(
+ Concurrency::new(Expression::new(
+ "${{ github.workflow }}-${{ github.head_ref || github.ref }}",
+ ))
+ .cancel_in_progress(true),
+ )
+ .add_env(("CARGO_TERM_COLOR", "always"))
+ .add_env(("RUST_BACKTRACE", "1"))
+ .add_job(nix_linux_x86_64.name, nix_linux_x86_64.job)
+ .add_job(nix_mac_aarch64.name, nix_mac_aarch64.job)
+}
+
+/// Builds the pair of PR Nix jobs (Linux x86_64 + macOS aarch64), each gated so
+/// they run when any of the given PR `labels` is present (on
+/// `labeled`/`synchronize` events).
+fn nix_pr_jobs(labels: &[&str]) -> [NamedJob; 2] {
+ let labeled = labels
+ .iter()
+ .map(|label| format!("github.event.label.name == '{label}'"))
+ .collect::<Vec<_>>()
+ .join(" || ");
+ let synchronized = labels
+ .iter()
+ .map(|label| format!("contains(github.event.pull_request.labels.*.name, '{label}')"))
+ .collect::<Vec<_>>()
+ .join(" || ");
+ [
+ (Platform::Linux, Arch::X86_64),
+ (Platform::Mac, Arch::AARCH64),
+ ]
+ .map(|(platform, arch)| {
+ let mut job = build_nix(
+ platform,
+ arch,
+ "default",
+ // don't push PR builds to the cache
+ Some("-zed-editor-[0-9.]*"),
+ &[],
+ );
+ job.job = job.job.cond(Expression::new(format!(
+ "{DEFAULT_REPOSITORY_OWNER_GUARD} && \
+ ((github.event.action == 'labeled' && ({labeled})) || \
+ (github.event.action == 'synchronize' && ({synchronized})))"
+ )));
+ job
+ })
+}
+
pub(crate) fn build_nix(
platform: Platform,
arch: Arch,
diff --git a/tooling/xtask/src/tasks/workflows/run_bundling.rs b/tooling/xtask/src/tasks/workflows/run_bundling.rs
index 5fa6b870b02..7546e93c418 100644
--- a/tooling/xtask/src/tasks/workflows/run_bundling.rs
+++ b/tooling/xtask/src/tasks/workflows/run_bundling.rs
@@ -1,13 +1,9 @@
use std::path::Path;
use crate::tasks::workflows::{
- nix_build::build_nix,
release::ReleaseBundleJobs,
runners::{Arch, Platform, ReleaseChannel},
- steps::{
- DEFAULT_REPOSITORY_OWNER_GUARD, FluentBuilder, IfNoFilesFound, NamedJob,
- UploadArtifactStep, dependant_job, named,
- },
+ steps::{FluentBuilder, IfNoFilesFound, NamedJob, UploadArtifactStep, dependant_job, named},
vars::{assets, bundle_envs},
};
@@ -24,8 +20,6 @@ pub fn run_bundling() -> Workflow {
windows_aarch64: bundle_windows(Arch::AARCH64, None, &[]),
windows_x86_64: bundle_windows(Arch::X86_64, None, &[]),
};
- let nix_linux_x86_64 = nix_job(Platform::Linux, Arch::X86_64);
- let nix_mac_aarch64 = nix_job(Platform::Mac, Arch::AARCH64);
named::workflow()
.on(Event::default().pull_request(
PullRequest::default().types([PullRequestType::Labeled, PullRequestType::Synchronize]),
@@ -44,25 +38,6 @@ pub fn run_bundling() -> Workflow {
}
workflow
})
- .add_job(nix_linux_x86_64.name, nix_linux_x86_64.job)
- .add_job(nix_mac_aarch64.name, nix_mac_aarch64.job)
-}
-
-fn nix_job(platform: Platform, arch: Arch) -> NamedJob {
- let mut job = build_nix(
- platform,
- arch,
- "default",
- // don't push PR builds to the cache
- Some("-zed-editor-[0-9.]*"),
- &[],
- );
- job.job = job.job.cond(Expression::new(format!(
- "{} && ((github.event.action == 'labeled' && github.event.label.name == 'run-bundling') || \
- (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'run-bundling')))",
- DEFAULT_REPOSITORY_OWNER_GUARD
- )));
- job
}
fn bundle_job(deps: &[&NamedJob]) -> Job {