Don't run nix checks on PRs (#48849)

Conrad Irwin created

Although this introduces a small possiblity that we will regress the nix
build,
the existing check is very slow and fails very rarely.

Release Notes:

- N/A

Change summary

.github/workflows/run_bundling.yml                | 79 +++++++++++++++
.github/workflows/run_tests.yml                   | 89 -----------------
tooling/xtask/src/tasks/workflows/run_bundling.rs | 24 ++++
tooling/xtask/src/tasks/workflows/run_tests.rs    | 23 ----
4 files changed, 102 insertions(+), 113 deletions(-)

Detailed changes

.github/workflows/run_bundling.yml 🔗

@@ -264,6 +264,85 @@ 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@11bd71901bbe5b1630ceea73d27597364c9af683
+      with:
+        clean: false
+    - name: steps::cache_nix_dependencies_namespace
+      uses: namespacelabs/nscloud-cache-action@v1
+      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@11bd71901bbe5b1630ceea73d27597364c9af683
+      with:
+        clean: false
+    - name: steps::cache_nix_store_macos
+      uses: namespacelabs/nscloud-cache-action@v1
+      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

.github/workflows/run_tests.yml 🔗

@@ -102,14 +102,12 @@ jobs:
         check_pattern "run_action_checks" '^\.github/(workflows/|actions/|actionlint.yml)|tooling/xtask|script/' -qP
         check_pattern "run_docs" '^(docs/|crates/.*\.rs)' -qP
         check_pattern "run_licenses" '^(Cargo.lock|script/.*licenses)' -qP
-        check_pattern "run_nix" '^(nix/|flake\.|Cargo\.|rust-toolchain.toml|\.cargo/config.toml)' -qP
         check_pattern "run_tests" '^(docs/|script/update_top_ranking_issues/|\.github/(ISSUE_TEMPLATE|workflows/(?!run_tests)))' -qvP
     outputs:
       changed_packages: ${{ steps.filter.outputs.changed_packages }}
       run_action_checks: ${{ steps.filter.outputs.run_action_checks }}
       run_docs: ${{ steps.filter.outputs.run_docs }}
       run_licenses: ${{ steps.filter.outputs.run_licenses }}
-      run_nix: ${{ steps.filter.outputs.run_nix }}
       run_tests: ${{ steps.filter.outputs.run_tests }}
   check_style:
     if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
@@ -517,89 +515,6 @@ jobs:
           exit 1
         fi
     timeout-minutes: 60
-  build_nix_linux_x86_64:
-    needs:
-    - orchestrate
-    if: needs.orchestrate.outputs.run_nix == 'true'
-    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@11bd71901bbe5b1630ceea73d27597364c9af683
-      with:
-        clean: false
-    - name: steps::cache_nix_dependencies_namespace
-      uses: namespacelabs/nscloud-cache-action@v1
-      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.]*-nightly
-    - name: nix_build::build_nix::build
-      run: nix build .#debug -L --accept-flake-config
-    timeout-minutes: 60
-    continue-on-error: true
-  build_nix_mac_aarch64:
-    needs:
-    - orchestrate
-    if: needs.orchestrate.outputs.run_nix == 'true'
-    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@11bd71901bbe5b1630ceea73d27597364c9af683
-      with:
-        clean: false
-    - name: steps::cache_nix_store_macos
-      uses: namespacelabs/nscloud-cache-action@v1
-      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.]*-nightly
-    - name: nix_build::build_nix::build
-      run: nix build .#debug -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
   check_postgres_and_protobuf_migrations:
     needs:
     - orchestrate
@@ -654,8 +569,6 @@ jobs:
     - check_docs
     - check_licenses
     - check_scripts
-    - build_nix_linux_x86_64
-    - build_nix_mac_aarch64
     if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && always()
     runs-on: namespace-profile-2x4-ubuntu-2404
     steps:
@@ -683,8 +596,6 @@ jobs:
         check_result "check_docs" "${{ needs.check_docs.result }}"
         check_result "check_licenses" "${{ needs.check_licenses.result }}"
         check_result "check_scripts" "${{ needs.check_scripts.result }}"
-        check_result "build_nix_linux_x86_64" "${{ needs.build_nix_linux_x86_64.result }}"
-        check_result "build_nix_mac_aarch64" "${{ needs.build_nix_mac_aarch64.result }}"
 
         exit $EXIT_CODE
 concurrency:

tooling/xtask/src/tasks/workflows/run_bundling.rs 🔗

@@ -1,9 +1,10 @@
 use std::path::Path;
 
 use crate::tasks::workflows::{
+    nix_build::build_nix,
     release::ReleaseBundleJobs,
     runners::{Arch, Platform, ReleaseChannel},
-    steps::{FluentBuilder, NamedJob, dependant_job, named},
+    steps::{DEFAULT_REPOSITORY_OWNER_GUARD, FluentBuilder, NamedJob, dependant_job, named},
     vars::{assets, bundle_envs},
 };
 
@@ -20,6 +21,8 @@ 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]),
@@ -38,6 +41,25 @@ 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 {

tooling/xtask/src/tasks/workflows/run_tests.rs 🔗

@@ -5,8 +5,6 @@ use gh_workflow::{
 use indexmap::IndexMap;
 
 use crate::tasks::workflows::{
-    nix_build::build_nix,
-    runners::Arch,
     steps::{CommonJobConditions, repository_owner_guard_expression},
     vars::{self, PathCondition},
 };
@@ -33,16 +31,11 @@ pub(crate) fn run_tests() -> Workflow {
     );
     let should_check_licences =
         PathCondition::new("run_licenses", r"^(Cargo.lock|script/.*licenses)");
-    let should_build_nix = PathCondition::new(
-        "run_nix",
-        r"^(nix/|flake\.|Cargo\.|rust-toolchain.toml|\.cargo/config.toml)",
-    );
 
     let orchestrate = orchestrate(&[
         &should_check_scripts,
         &should_check_docs,
         &should_check_licences,
-        &should_build_nix,
         &should_run_tests,
     ]);
 
@@ -61,22 +54,6 @@ pub(crate) fn run_tests() -> Workflow {
         should_check_docs.guard(check_docs()),
         should_check_licences.guard(check_licenses()),
         should_check_scripts.guard(check_scripts()),
-        should_build_nix.guard(build_nix(
-            Platform::Linux,
-            Arch::X86_64,
-            "debug",
-            // *don't* cache the built output
-            Some("-zed-editor-[0-9.]*-nightly"),
-            &[],
-        )),
-        should_build_nix.guard(build_nix(
-            Platform::Mac,
-            Arch::AARCH64,
-            "debug",
-            // *don't* cache the built output
-            Some("-zed-editor-[0-9.]*-nightly"),
-            &[],
-        )),
     ];
     let tests_pass = tests_pass(&jobs);