run_tests.yml

  1# Generated from xtask::workflows::run_tests
  2# Rebuild with `cargo xtask workflows`.
  3name: run_tests
  4env:
  5  CARGO_TERM_COLOR: always
  6  RUST_BACKTRACE: '1'
  7  CARGO_INCREMENTAL: '0'
  8on:
  9  pull_request:
 10    branches:
 11    - '**'
 12  push:
 13    branches:
 14    - main
 15    - v[0-9]+.[0-9]+.x
 16jobs:
 17  orchestrate:
 18    if: github.repository_owner == 'zed-industries'
 19    runs-on: namespace-profile-2x4-ubuntu-2404
 20    steps:
 21    - name: steps::checkout_repo
 22      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
 23      with:
 24        clean: false
 25        fetch-depth: ${{ github.ref == 'refs/heads/main' && 2 || 350 }}
 26    - id: filter
 27      name: filter
 28      run: |
 29        if [ -z "$GITHUB_BASE_REF" ]; then
 30          echo "Not in a PR context (i.e., push to main/stable/preview)"
 31          COMPARE_REV="$(git rev-parse HEAD~1)"
 32        else
 33          echo "In a PR context comparing to pull_request.base.ref"
 34          git fetch origin "$GITHUB_BASE_REF" --depth=350
 35          COMPARE_REV="$(git merge-base "origin/${GITHUB_BASE_REF}" HEAD)"
 36        fi
 37        CHANGED_FILES="$(git diff --name-only "$COMPARE_REV" ${{ github.sha }})"
 38
 39        check_pattern() {
 40          local output_name="$1"
 41          local pattern="$2"
 42          local grep_arg="$3"
 43
 44          echo "$CHANGED_FILES" | grep "$grep_arg" "$pattern" && \
 45            echo "${output_name}=true" >> "$GITHUB_OUTPUT" || \
 46            echo "${output_name}=false" >> "$GITHUB_OUTPUT"
 47        }
 48
 49        check_pattern "run_action_checks" '^\.github/(workflows/|actions/|actionlint.yml)|tooling/xtask' -qP
 50        check_pattern "run_docs" '^docs/' -qP
 51        check_pattern "run_licenses" '^(Cargo.lock|script/.*licenses)' -qP
 52        check_pattern "run_nix" '^(nix/|flake\.|Cargo\.|rust-toolchain.toml|\.cargo/config.toml)' -qP
 53        check_pattern "run_tests" '^(docs/|script/update_top_ranking_issues/|\.github/(ISSUE_TEMPLATE|workflows/(?!run_tests)))' -qvP
 54      shell: bash -euxo pipefail {0}
 55    outputs:
 56      run_action_checks: ${{ steps.filter.outputs.run_action_checks }}
 57      run_docs: ${{ steps.filter.outputs.run_docs }}
 58      run_licenses: ${{ steps.filter.outputs.run_licenses }}
 59      run_nix: ${{ steps.filter.outputs.run_nix }}
 60      run_tests: ${{ steps.filter.outputs.run_tests }}
 61  check_style:
 62    if: github.repository_owner == 'zed-industries'
 63    runs-on: namespace-profile-4x8-ubuntu-2204
 64    steps:
 65    - name: steps::checkout_repo
 66      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
 67      with:
 68        clean: false
 69    - name: steps::setup_pnpm
 70      uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2
 71      with:
 72        version: '9'
 73    - name: ./script/prettier
 74      run: ./script/prettier
 75      shell: bash -euxo pipefail {0}
 76    - name: ./script/check-todos
 77      run: ./script/check-todos
 78      shell: bash -euxo pipefail {0}
 79    - name: ./script/check-keymaps
 80      run: ./script/check-keymaps
 81      shell: bash -euxo pipefail {0}
 82    - name: run_tests::check_style::check_for_typos
 83      uses: crate-ci/typos@80c8a4945eec0f6d464eaf9e65ed98ef085283d1
 84      with:
 85        config: ./typos.toml
 86    - name: steps::cargo_fmt
 87      run: cargo fmt --all -- --check
 88      shell: bash -euxo pipefail {0}
 89    timeout-minutes: 60
 90  run_tests_windows:
 91    needs:
 92    - orchestrate
 93    if: needs.orchestrate.outputs.run_tests == 'true'
 94    runs-on: self-32vcpu-windows-2022
 95    steps:
 96    - name: steps::checkout_repo
 97      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
 98      with:
 99        clean: false
100    - name: steps::setup_cargo_config
101      run: |
102        New-Item -ItemType Directory -Path "./../.cargo" -Force
103        Copy-Item -Path "./.cargo/ci-config.toml" -Destination "./../.cargo/config.toml"
104      shell: pwsh
105    - name: steps::setup_node
106      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
107      with:
108        node-version: '20'
109    - name: steps::clippy
110      run: ./script/clippy.ps1
111      shell: pwsh
112    - name: steps::cargo_install_nextest
113      run: cargo install cargo-nextest --locked
114      shell: pwsh
115    - name: steps::clear_target_dir_if_large
116      run: ./script/clear-target-dir-if-larger-than.ps1 250
117      shell: pwsh
118    - name: steps::cargo_nextest
119      run: cargo nextest run --workspace --no-fail-fast --failure-output immediate-final
120      shell: pwsh
121    - name: steps::cleanup_cargo_config
122      if: always()
123      run: |
124        Remove-Item -Recurse -Path "./../.cargo" -Force -ErrorAction SilentlyContinue
125      shell: pwsh
126    timeout-minutes: 60
127  run_tests_linux:
128    needs:
129    - orchestrate
130    if: needs.orchestrate.outputs.run_tests == 'true'
131    runs-on: namespace-profile-16x32-ubuntu-2204
132    steps:
133    - name: steps::checkout_repo
134      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
135      with:
136        clean: false
137    - name: steps::setup_cargo_config
138      run: |
139        mkdir -p ./../.cargo
140        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
141      shell: bash -euxo pipefail {0}
142    - name: steps::setup_linux
143      run: ./script/linux
144      shell: bash -euxo pipefail {0}
145    - name: steps::install_mold
146      run: ./script/install-mold
147      shell: bash -euxo pipefail {0}
148    - name: steps::setup_node
149      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
150      with:
151        node-version: '20'
152    - name: steps::clippy
153      run: ./script/clippy
154      shell: bash -euxo pipefail {0}
155    - name: steps::cargo_install_nextest
156      run: cargo install cargo-nextest --locked
157      shell: bash -euxo pipefail {0}
158    - name: steps::clear_target_dir_if_large
159      run: ./script/clear-target-dir-if-larger-than 100
160      shell: bash -euxo pipefail {0}
161    - name: steps::cargo_nextest
162      run: cargo nextest run --workspace --no-fail-fast --failure-output immediate-final
163      shell: bash -euxo pipefail {0}
164    - name: steps::cleanup_cargo_config
165      if: always()
166      run: |
167        rm -rf ./../.cargo
168      shell: bash -euxo pipefail {0}
169    timeout-minutes: 60
170  run_tests_mac:
171    needs:
172    - orchestrate
173    if: needs.orchestrate.outputs.run_tests == 'true'
174    runs-on: self-mini-macos
175    steps:
176    - name: steps::checkout_repo
177      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
178      with:
179        clean: false
180    - name: steps::setup_cargo_config
181      run: |
182        mkdir -p ./../.cargo
183        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
184      shell: bash -euxo pipefail {0}
185    - name: steps::setup_node
186      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
187      with:
188        node-version: '20'
189    - name: steps::clippy
190      run: ./script/clippy
191      shell: bash -euxo pipefail {0}
192    - name: steps::cargo_install_nextest
193      run: cargo install cargo-nextest --locked
194      shell: bash -euxo pipefail {0}
195    - name: steps::clear_target_dir_if_large
196      run: ./script/clear-target-dir-if-larger-than 300
197      shell: bash -euxo pipefail {0}
198    - name: steps::cargo_nextest
199      run: cargo nextest run --workspace --no-fail-fast --failure-output immediate-final
200      shell: bash -euxo pipefail {0}
201    - name: steps::cleanup_cargo_config
202      if: always()
203      run: |
204        rm -rf ./../.cargo
205      shell: bash -euxo pipefail {0}
206    timeout-minutes: 60
207  doctests:
208    needs:
209    - orchestrate
210    if: needs.orchestrate.outputs.run_tests == 'true'
211    runs-on: namespace-profile-16x32-ubuntu-2204
212    steps:
213    - name: steps::checkout_repo
214      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
215      with:
216        clean: false
217    - name: steps::cache_rust_dependencies
218      uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
219      with:
220        save-if: ${{ github.ref == 'refs/heads/main' }}
221    - name: steps::setup_linux
222      run: ./script/linux
223      shell: bash -euxo pipefail {0}
224    - name: steps::install_mold
225      run: ./script/install-mold
226      shell: bash -euxo pipefail {0}
227    - name: steps::setup_cargo_config
228      run: |
229        mkdir -p ./../.cargo
230        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
231      shell: bash -euxo pipefail {0}
232    - id: run_doctests
233      name: run_tests::doctests::run_doctests
234      run: |
235        cargo test --workspace --doc --no-fail-fast
236      shell: bash -euxo pipefail {0}
237    - name: steps::cleanup_cargo_config
238      if: always()
239      run: |
240        rm -rf ./../.cargo
241      shell: bash -euxo pipefail {0}
242    timeout-minutes: 60
243  check_workspace_binaries:
244    needs:
245    - orchestrate
246    if: needs.orchestrate.outputs.run_tests == 'true'
247    runs-on: namespace-profile-8x16-ubuntu-2204
248    steps:
249    - name: steps::checkout_repo
250      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
251      with:
252        clean: false
253    - name: steps::setup_cargo_config
254      run: |
255        mkdir -p ./../.cargo
256        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
257      shell: bash -euxo pipefail {0}
258    - name: steps::setup_linux
259      run: ./script/linux
260      shell: bash -euxo pipefail {0}
261    - name: steps::install_mold
262      run: ./script/install-mold
263      shell: bash -euxo pipefail {0}
264    - name: cargo build -p collab
265      run: cargo build -p collab
266      shell: bash -euxo pipefail {0}
267    - name: cargo build --workspace --bins --examples
268      run: cargo build --workspace --bins --examples
269      shell: bash -euxo pipefail {0}
270    - name: steps::cleanup_cargo_config
271      if: always()
272      run: |
273        rm -rf ./../.cargo
274      shell: bash -euxo pipefail {0}
275    timeout-minutes: 60
276  check_postgres_and_protobuf_migrations:
277    needs:
278    - orchestrate
279    if: needs.orchestrate.outputs.run_tests == 'true'
280    runs-on: self-mini-macos
281    steps:
282    - name: steps::checkout_repo
283      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
284      with:
285        fetch-depth: 0
286    - name: run_tests::check_postgres_and_protobuf_migrations::remove_untracked_files
287      run: git clean -df
288      shell: bash -euxo pipefail {0}
289    - name: run_tests::check_postgres_and_protobuf_migrations::ensure_fresh_merge
290      run: |
291        if [ -z "$GITHUB_BASE_REF" ];
292        then
293          echo "BUF_BASE_BRANCH=$(git merge-base origin/main HEAD)" >> "$GITHUB_ENV"
294        else
295          git checkout -B temp
296          git merge -q "origin/$GITHUB_BASE_REF" -m "merge main into temp"
297          echo "BUF_BASE_BRANCH=$GITHUB_BASE_REF" >> "$GITHUB_ENV"
298        fi
299      shell: bash -euxo pipefail {0}
300    - name: run_tests::check_postgres_and_protobuf_migrations::bufbuild_setup_action
301      uses: bufbuild/buf-setup-action@v1
302      with:
303        version: v1.29.0
304    - name: run_tests::check_postgres_and_protobuf_migrations::bufbuild_breaking_action
305      uses: bufbuild/buf-breaking-action@v1
306      with:
307        input: crates/proto/proto/
308        against: https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/proto/proto/
309    timeout-minutes: 60
310  check_dependencies:
311    needs:
312    - orchestrate
313    if: needs.orchestrate.outputs.run_tests == 'true'
314    runs-on: namespace-profile-2x4-ubuntu-2404
315    steps:
316    - name: steps::checkout_repo
317      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
318      with:
319        clean: false
320    - name: run_tests::check_dependencies::install_cargo_machete
321      uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386
322      with:
323        command: install
324        args: cargo-machete@0.7.0
325    - name: run_tests::check_dependencies::run_cargo_machete
326      uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386
327      with:
328        command: machete
329    - name: run_tests::check_dependencies::check_cargo_lock
330      run: cargo update --locked --workspace
331      shell: bash -euxo pipefail {0}
332    - name: run_tests::check_dependencies::check_vulnerable_dependencies
333      if: github.event_name == 'pull_request'
334      uses: actions/dependency-review-action@67d4f4bd7a9b17a0db54d2a7519187c65e339de8
335      with:
336        license-check: false
337    timeout-minutes: 60
338  check_docs:
339    needs:
340    - orchestrate
341    if: needs.orchestrate.outputs.run_docs == 'true'
342    runs-on: namespace-profile-8x16-ubuntu-2204
343    steps:
344    - name: steps::checkout_repo
345      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
346      with:
347        clean: false
348    - name: steps::setup_cargo_config
349      run: |
350        mkdir -p ./../.cargo
351        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
352      shell: bash -euxo pipefail {0}
353    - name: steps::cache_rust_dependencies
354      uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
355      with:
356        save-if: ${{ github.ref == 'refs/heads/main' }}
357    - name: run_tests::check_docs::lychee_link_check
358      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
359      with:
360        args: --no-progress --exclude '^http' './docs/src/**/*'
361        fail: true
362        jobSummary: false
363    - name: steps::setup_linux
364      run: ./script/linux
365      shell: bash -euxo pipefail {0}
366    - name: steps::install_mold
367      run: ./script/install-mold
368      shell: bash -euxo pipefail {0}
369    - name: run_tests::check_docs::install_mdbook
370      uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08
371      with:
372        mdbook-version: 0.4.37
373    - name: run_tests::check_docs::build_docs
374      run: |
375        mkdir -p target/deploy
376        mdbook build ./docs --dest-dir=../target/deploy/docs/
377      shell: bash -euxo pipefail {0}
378    - name: run_tests::check_docs::lychee_link_check
379      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
380      with:
381        args: --no-progress --exclude '^http' 'target/deploy/docs'
382        fail: true
383        jobSummary: false
384    timeout-minutes: 60
385  check_licenses:
386    needs:
387    - orchestrate
388    if: needs.orchestrate.outputs.run_licenses == 'true'
389    runs-on: namespace-profile-2x4-ubuntu-2404
390    steps:
391    - name: steps::checkout_repo
392      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
393      with:
394        clean: false
395    - name: ./script/check-licenses
396      run: ./script/check-licenses
397      shell: bash -euxo pipefail {0}
398    - name: ./script/generate-licenses
399      run: ./script/generate-licenses
400      shell: bash -euxo pipefail {0}
401  check_scripts:
402    needs:
403    - orchestrate
404    if: needs.orchestrate.outputs.run_action_checks == 'true'
405    runs-on: namespace-profile-2x4-ubuntu-2404
406    steps:
407    - name: steps::checkout_repo
408      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
409      with:
410        clean: false
411    - name: run_tests::check_scripts::run_shellcheck
412      run: ./script/shellcheck-scripts error
413      shell: bash -euxo pipefail {0}
414    - id: get_actionlint
415      name: run_tests::check_scripts::download_actionlint
416      run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
417      shell: bash -euxo pipefail {0}
418    - name: run_tests::check_scripts::run_actionlint
419      run: |
420        ${{ steps.get_actionlint.outputs.executable }} -color
421      shell: bash -euxo pipefail {0}
422    - name: run_tests::check_scripts::check_xtask_workflows
423      run: |
424        cargo xtask workflows
425        if ! git diff --exit-code .github; then
426          echo "Error: .github directory has uncommitted changes after running 'cargo xtask workflows'"
427          echo "Please run 'cargo xtask workflows' locally and commit the changes"
428          exit 1
429        fi
430      shell: bash -euxo pipefail {0}
431    timeout-minutes: 60
432  build_nix_linux_x86_64:
433    needs:
434    - orchestrate
435    if: needs.orchestrate.outputs.run_nix == 'true'
436    runs-on: namespace-profile-32x64-ubuntu-2004
437    env:
438      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
439      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
440      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
441      GIT_LFS_SKIP_SMUDGE: '1'
442    steps:
443    - name: steps::checkout_repo
444      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
445      with:
446        clean: false
447    - name: nix_build::install_nix
448      uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f
449      with:
450        github_access_token: ${{ secrets.GITHUB_TOKEN }}
451    - name: nix_build::cachix_action
452      uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad
453      with:
454        name: zed
455        authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
456        cachixArgs: -v
457        pushFilter: -zed-editor-[0-9.]*-nightly
458    - name: nix_build::build
459      run: nix build .#debug -L --accept-flake-config
460      shell: bash -euxo pipefail {0}
461    timeout-minutes: 60
462    continue-on-error: true
463  build_nix_mac_aarch64:
464    needs:
465    - orchestrate
466    if: needs.orchestrate.outputs.run_nix == 'true'
467    runs-on: self-mini-macos
468    env:
469      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
470      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
471      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
472      GIT_LFS_SKIP_SMUDGE: '1'
473    steps:
474    - name: steps::checkout_repo
475      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
476      with:
477        clean: false
478    - name: nix_build::set_path
479      run: |
480        echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
481        echo "/Users/administrator/.nix-profile/bin" >> "$GITHUB_PATH"
482      shell: bash -euxo pipefail {0}
483    - name: nix_build::cachix_action
484      uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad
485      with:
486        name: zed
487        authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
488        cachixArgs: -v
489        pushFilter: -zed-editor-[0-9.]*-nightly
490    - name: nix_build::build
491      run: nix build .#debug -L --accept-flake-config
492      shell: bash -euxo pipefail {0}
493    - name: nix_build::limit_store
494      run: |-
495        if [ "$(du -sm /nix/store | cut -f1)" -gt 50000 ]; then
496            nix-collect-garbage -d || true
497        fi
498      shell: bash -euxo pipefail {0}
499    timeout-minutes: 60
500    continue-on-error: true
501  tests_pass:
502    needs:
503    - orchestrate
504    - check_style
505    - run_tests_windows
506    - run_tests_linux
507    - run_tests_mac
508    - doctests
509    - check_workspace_binaries
510    - check_postgres_and_protobuf_migrations
511    - check_dependencies
512    - check_docs
513    - check_licenses
514    - check_scripts
515    - build_nix_linux_x86_64
516    - build_nix_mac_aarch64
517    if: github.repository_owner == 'zed-industries' && always()
518    runs-on: namespace-profile-2x4-ubuntu-2404
519    steps:
520    - name: run_tests::tests_pass
521      run: |
522        set +x
523        EXIT_CODE=0
524
525        check_result() {
526          echo "* $1: $2"
527          if [[ "$2" != "skipped" && "$2" != "success" ]]; then EXIT_CODE=1; fi
528        }
529
530        check_result "orchestrate" "${{ needs.orchestrate.result }}"
531        check_result "check_style" "${{ needs.check_style.result }}"
532        check_result "run_tests_windows" "${{ needs.run_tests_windows.result }}"
533        check_result "run_tests_linux" "${{ needs.run_tests_linux.result }}"
534        check_result "run_tests_mac" "${{ needs.run_tests_mac.result }}"
535        check_result "doctests" "${{ needs.doctests.result }}"
536        check_result "check_workspace_binaries" "${{ needs.check_workspace_binaries.result }}"
537        check_result "check_postgres_and_protobuf_migrations" "${{ needs.check_postgres_and_protobuf_migrations.result }}"
538        check_result "check_dependencies" "${{ needs.check_dependencies.result }}"
539        check_result "check_docs" "${{ needs.check_docs.result }}"
540        check_result "check_licenses" "${{ needs.check_licenses.result }}"
541        check_result "check_scripts" "${{ needs.check_scripts.result }}"
542        check_result "build_nix_linux_x86_64" "${{ needs.build_nix_linux_x86_64.result }}"
543        check_result "build_nix_mac_aarch64" "${{ needs.build_nix_mac_aarch64.result }}"
544
545        exit $EXIT_CODE
546      shell: bash -euxo pipefail {0}
547concurrency:
548  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
549  cancel-in-progress: true