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  merge_group: {}
 10  pull_request:
 11    branches:
 12    - '**'
 13  push:
 14    branches:
 15    - main
 16    - v[0-9]+.[0-9]+.x
 17jobs:
 18  orchestrate:
 19    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
 20    runs-on: namespace-profile-2x4-ubuntu-2404
 21    steps:
 22    - name: steps::checkout_repo
 23      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
 24      with:
 25        clean: false
 26        fetch-depth: ${{ github.ref == 'refs/heads/main' && 2 || 350 }}
 27    - id: filter
 28      name: filter
 29      run: |
 30        set -euo pipefail
 31        if [ -z "$GITHUB_BASE_REF" ]; then
 32          echo "Not in a PR context (i.e., push to main/stable/preview)"
 33          COMPARE_REV="$(git rev-parse HEAD~1)"
 34        else
 35          echo "In a PR context comparing to pull_request.base.ref"
 36          git fetch origin "$GITHUB_BASE_REF" --depth=350
 37          COMPARE_REV="$(git merge-base "origin/${GITHUB_BASE_REF}" HEAD)"
 38        fi
 39        CHANGED_FILES="$(git diff --name-only "$COMPARE_REV" "$GITHUB_SHA")"
 40
 41        check_pattern() {
 42          local output_name="$1"
 43          local pattern="$2"
 44          local grep_arg="$3"
 45
 46          echo "$CHANGED_FILES" | grep "$grep_arg" "$pattern" && \
 47            echo "${output_name}=true" >> "$GITHUB_OUTPUT" || \
 48            echo "${output_name}=false" >> "$GITHUB_OUTPUT"
 49        }
 50
 51        # Check for changes that require full rebuild (no filter)
 52        # Direct pushes to main/stable/preview always run full suite
 53        if [ -z "$GITHUB_BASE_REF" ]; then
 54          echo "Not a PR, running full test suite"
 55          echo "changed_packages=" >> "$GITHUB_OUTPUT"
 56        elif echo "$CHANGED_FILES" | grep -qP '^(rust-toolchain\.toml|\.cargo/|\.github/|Cargo\.(toml|lock)$)'; then
 57          echo "Toolchain, cargo config, or root Cargo files changed, will run all tests"
 58          echo "changed_packages=" >> "$GITHUB_OUTPUT"
 59        else
 60          # Extract changed directories from file paths
 61          CHANGED_DIRS=$(echo "$CHANGED_FILES" | \
 62            grep -oP '^(crates|tooling)/\K[^/]+' | \
 63            sort -u || true)
 64
 65          # Build directory-to-package mapping using cargo metadata
 66          DIR_TO_PKG=$(cargo metadata --format-version=1 --no-deps 2>/dev/null | \
 67            jq -r '.packages[] | select(.manifest_path | test("crates/|tooling/")) | "\(.manifest_path | capture("(crates|tooling)/(?<dir>[^/]+)") | .dir)=\(.name)"')
 68
 69          # Map directory names to package names
 70          FILE_CHANGED_PKGS=""
 71          for dir in $CHANGED_DIRS; do
 72            pkg=$(echo "$DIR_TO_PKG" | grep "^${dir}=" | cut -d= -f2 | head -1)
 73            if [ -n "$pkg" ]; then
 74              FILE_CHANGED_PKGS=$(printf '%s\n%s' "$FILE_CHANGED_PKGS" "$pkg")
 75            else
 76              # Fall back to directory name if no mapping found
 77              FILE_CHANGED_PKGS=$(printf '%s\n%s' "$FILE_CHANGED_PKGS" "$dir")
 78            fi
 79          done
 80          FILE_CHANGED_PKGS=$(echo "$FILE_CHANGED_PKGS" | grep -v '^$' | sort -u || true)
 81
 82          # If assets/ changed, add crates that depend on those assets
 83          if echo "$CHANGED_FILES" | grep -qP '^assets/'; then
 84            FILE_CHANGED_PKGS=$(printf '%s\n%s\n%s' "$FILE_CHANGED_PKGS" "settings" "assets" | sort -u)
 85          fi
 86
 87          # Combine all changed packages
 88          ALL_CHANGED_PKGS=$(echo "$FILE_CHANGED_PKGS" | grep -v '^$' || true)
 89
 90          if [ -z "$ALL_CHANGED_PKGS" ]; then
 91            echo "No package changes detected, will run all tests"
 92            echo "changed_packages=" >> "$GITHUB_OUTPUT"
 93          else
 94            # Build nextest filterset with rdeps for each package
 95            FILTERSET=$(echo "$ALL_CHANGED_PKGS" | \
 96              sed 's/.*/rdeps(&)/' | \
 97              tr '\n' '|' | \
 98              sed 's/|$//')
 99            echo "Changed packages filterset: $FILTERSET"
100            echo "changed_packages=$FILTERSET" >> "$GITHUB_OUTPUT"
101          fi
102        fi
103
104        check_pattern "run_action_checks" '^\.github/(workflows/|actions/|actionlint.yml)|tooling/xtask|script/' -qP
105        check_pattern "run_docs" '^(docs/|crates/.*\.rs)' -qP
106        check_pattern "run_licenses" '^(Cargo.lock|script/.*licenses)' -qP
107        check_pattern "run_tests" '^(docs/|script/update_top_ranking_issues/|\.github/(ISSUE_TEMPLATE|workflows/(?!run_tests))|extensions/)' -qvP
108        # Detect changed extension directories (excluding extensions/workflows)
109        CHANGED_EXTENSIONS=$(echo "$CHANGED_FILES" | grep -oP '^extensions/[^/]+(?=/)' | sort -u | grep -v '^extensions/workflows$' || true)
110        # Filter out deleted extensions
111        EXISTING_EXTENSIONS=""
112        for ext in $CHANGED_EXTENSIONS; do
113            if [ -f "$ext/extension.toml" ]; then
114                EXISTING_EXTENSIONS=$(printf '%s\n%s' "$EXISTING_EXTENSIONS" "$ext")
115            fi
116        done
117        CHANGED_EXTENSIONS=$(echo "$EXISTING_EXTENSIONS" | sed '/^$/d')
118        if [ -n "$CHANGED_EXTENSIONS" ]; then
119            EXTENSIONS_JSON=$(echo "$CHANGED_EXTENSIONS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
120        else
121            EXTENSIONS_JSON="[]"
122        fi
123        echo "changed_extensions=$EXTENSIONS_JSON" >> "$GITHUB_OUTPUT"
124    outputs:
125      changed_packages: ${{ steps.filter.outputs.changed_packages }}
126      run_action_checks: ${{ steps.filter.outputs.run_action_checks }}
127      run_docs: ${{ steps.filter.outputs.run_docs }}
128      run_licenses: ${{ steps.filter.outputs.run_licenses }}
129      run_tests: ${{ steps.filter.outputs.run_tests }}
130      changed_extensions: ${{ steps.filter.outputs.changed_extensions }}
131  check_style:
132    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
133    runs-on: namespace-profile-4x8-ubuntu-2204
134    steps:
135    - name: steps::checkout_repo
136      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
137      with:
138        clean: false
139    - name: steps::cache_rust_dependencies_namespace
140      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
141      with:
142        cache: rust
143        path: ~/.rustup
144    - name: steps::setup_pnpm
145      uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2
146      with:
147        version: '9'
148    - name: steps::prettier
149      run: ./script/prettier
150    - name: steps::cargo_fmt
151      run: cargo fmt --all -- --check
152    - name: ./script/check-todos
153      run: ./script/check-todos
154    - name: ./script/check-keymaps
155      run: ./script/check-keymaps
156    - name: run_tests::check_style::check_for_typos
157      uses: crate-ci/typos@2d0ce569feab1f8752f1dde43cc2f2aa53236e06
158      with:
159        config: ./typos.toml
160    - name: run_tests::fetch_ts_query_ls
161      uses: dsaltares/fetch-gh-release-asset@aa37ae5c44d3c9820bc12fe675e8670ecd93bd1c
162      with:
163        repo: ribru17/ts_query_ls
164        version: tags/v3.15.1
165        file: ts_query_ls-x86_64-unknown-linux-gnu.tar.gz
166    - name: run_tests::run_ts_query_ls
167      run: |-
168        tar -xf "$GITHUB_WORKSPACE/ts_query_ls-x86_64-unknown-linux-gnu.tar.gz" -C "$GITHUB_WORKSPACE"
169        "$GITHUB_WORKSPACE/ts_query_ls" format --check . || {
170            echo "Found unformatted queries, please format them with ts_query_ls."
171            echo "For easy use, install the Tree-sitter query extension:"
172            echo "zed://extension/tree-sitter-query"
173            false
174        }
175    timeout-minutes: 60
176  clippy_windows:
177    needs:
178    - orchestrate
179    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
180    runs-on: self-32vcpu-windows-2022
181    steps:
182    - name: steps::checkout_repo
183      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
184      with:
185        clean: false
186    - name: steps::setup_cargo_config
187      run: |
188        New-Item -ItemType Directory -Path "./../.cargo" -Force
189        Copy-Item -Path "./.cargo/ci-config.toml" -Destination "./../.cargo/config.toml"
190      shell: pwsh
191    - name: steps::setup_sccache
192      run: ./script/setup-sccache.ps1
193      shell: pwsh
194      env:
195        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
196        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
197        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
198        SCCACHE_BUCKET: sccache-zed
199    - name: steps::clippy
200      run: ./script/clippy.ps1
201      shell: pwsh
202    - name: steps::show_sccache_stats
203      run: if ($env:RUSTC_WRAPPER) { & $env:RUSTC_WRAPPER --show-stats }; exit 0
204      shell: pwsh
205    timeout-minutes: 60
206  clippy_linux:
207    needs:
208    - orchestrate
209    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
210    runs-on: namespace-profile-16x32-ubuntu-2204
211    env:
212      CC: clang
213      CXX: clang++
214    steps:
215    - name: steps::checkout_repo
216      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
217      with:
218        clean: false
219    - name: steps::setup_cargo_config
220      run: |
221        mkdir -p ./../.cargo
222        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
223    - name: steps::cache_rust_dependencies_namespace
224      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
225      with:
226        cache: rust
227        path: ~/.rustup
228    - name: steps::setup_linux
229      run: ./script/linux
230    - name: steps::download_wasi_sdk
231      run: ./script/download-wasi-sdk
232    - name: steps::setup_sccache
233      run: ./script/setup-sccache
234      env:
235        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
236        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
237        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
238        SCCACHE_BUCKET: sccache-zed
239    - name: steps::clippy
240      run: ./script/clippy
241    - name: steps::show_sccache_stats
242      run: sccache --show-stats || true
243    timeout-minutes: 60
244  clippy_mac:
245    needs:
246    - orchestrate
247    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
248    runs-on: namespace-profile-mac-large
249    steps:
250    - name: steps::checkout_repo
251      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
252      with:
253        clean: false
254    - name: steps::setup_cargo_config
255      run: |
256        mkdir -p ./../.cargo
257        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
258    - name: steps::cache_rust_dependencies_namespace
259      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
260      with:
261        cache: rust
262        path: ~/.rustup
263    - name: steps::setup_sccache
264      run: ./script/setup-sccache
265      env:
266        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
267        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
268        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
269        SCCACHE_BUCKET: sccache-zed
270    - name: steps::clippy
271      run: ./script/clippy
272    - name: steps::show_sccache_stats
273      run: sccache --show-stats || true
274    timeout-minutes: 60
275  clippy_mac_x86_64:
276    needs:
277    - orchestrate
278    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
279    runs-on: namespace-profile-mac-large
280    steps:
281    - name: steps::checkout_repo
282      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
283      with:
284        clean: false
285    - name: steps::setup_cargo_config
286      run: |
287        mkdir -p ./../.cargo
288        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
289    - name: steps::cache_rust_dependencies_namespace
290      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
291      with:
292        cache: rust
293        path: ~/.rustup
294    - name: steps::install_rustup_target
295      run: rustup target add x86_64-apple-darwin
296    - name: steps::setup_sccache
297      run: ./script/setup-sccache
298      env:
299        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
300        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
301        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
302        SCCACHE_BUCKET: sccache-zed
303    - name: steps::clippy
304      run: ./script/clippy --target x86_64-apple-darwin
305    - name: steps::show_sccache_stats
306      run: sccache --show-stats || true
307    timeout-minutes: 60
308  run_tests_windows:
309    needs:
310    - orchestrate
311    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
312    runs-on: self-32vcpu-windows-2022
313    steps:
314    - name: steps::checkout_repo
315      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
316      with:
317        clean: false
318    - name: steps::setup_cargo_config
319      run: |
320        New-Item -ItemType Directory -Path "./../.cargo" -Force
321        Copy-Item -Path "./.cargo/ci-config.toml" -Destination "./../.cargo/config.toml"
322      shell: pwsh
323    - name: steps::setup_node
324      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
325      with:
326        node-version: '20'
327    - name: steps::clear_target_dir_if_large
328      run: ./script/clear-target-dir-if-larger-than.ps1 350 200
329      shell: pwsh
330    - name: steps::setup_sccache
331      run: ./script/setup-sccache.ps1
332      shell: pwsh
333      env:
334        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
335        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
336        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
337        SCCACHE_BUCKET: sccache-zed
338    - name: steps::cargo_nextest
339      run: cargo nextest run --workspace --no-fail-fast --no-tests=warn${{ needs.orchestrate.outputs.changed_packages && format(' -E "{0}"', needs.orchestrate.outputs.changed_packages) || '' }}
340      shell: pwsh
341    - name: steps::show_sccache_stats
342      run: if ($env:RUSTC_WRAPPER) { & $env:RUSTC_WRAPPER --show-stats }; exit 0
343      shell: pwsh
344    - name: steps::cleanup_cargo_config
345      if: always()
346      run: |
347        Remove-Item -Recurse -Path "./../.cargo" -Force -ErrorAction SilentlyContinue
348      shell: pwsh
349    timeout-minutes: 60
350  run_tests_linux:
351    needs:
352    - orchestrate
353    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
354    runs-on: namespace-profile-16x32-ubuntu-2204
355    env:
356      CC: clang
357      CXX: clang++
358    steps:
359    - name: steps::checkout_repo
360      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
361      with:
362        clean: false
363    - name: steps::setup_cargo_config
364      run: |
365        mkdir -p ./../.cargo
366        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
367    - name: steps::cache_rust_dependencies_namespace
368      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
369      with:
370        cache: rust
371        path: ~/.rustup
372    - name: steps::setup_linux
373      run: ./script/linux
374    - name: steps::download_wasi_sdk
375      run: ./script/download-wasi-sdk
376    - name: steps::setup_node
377      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
378      with:
379        node-version: '20'
380    - name: steps::cargo_install_nextest
381      uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c
382    - name: steps::clear_target_dir_if_large
383      run: ./script/clear-target-dir-if-larger-than 350 200
384    - name: steps::setup_sccache
385      run: ./script/setup-sccache
386      env:
387        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
388        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
389        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
390        SCCACHE_BUCKET: sccache-zed
391    - name: steps::cargo_nextest
392      run: cargo nextest run --workspace --no-fail-fast --no-tests=warn${{ needs.orchestrate.outputs.changed_packages && format(' -E "{0}"', needs.orchestrate.outputs.changed_packages) || '' }}
393    - name: steps::show_sccache_stats
394      run: sccache --show-stats || true
395    - name: steps::cleanup_cargo_config
396      if: always()
397      run: |
398        rm -rf ./../.cargo
399    timeout-minutes: 60
400    services:
401      postgres:
402        image: postgres:15
403        env:
404          POSTGRES_HOST_AUTH_METHOD: trust
405        ports:
406        - 5432:5432
407        options: --health-cmd pg_isready --health-interval 500ms --health-timeout 5s --health-retries 10
408  run_tests_mac:
409    needs:
410    - orchestrate
411    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
412    runs-on: namespace-profile-mac-large
413    steps:
414    - name: steps::checkout_repo
415      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
416      with:
417        clean: false
418    - name: steps::setup_cargo_config
419      run: |
420        mkdir -p ./../.cargo
421        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
422    - name: steps::cache_rust_dependencies_namespace
423      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
424      with:
425        cache: rust
426        path: ~/.rustup
427    - name: steps::setup_node
428      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
429      with:
430        node-version: '20'
431    - name: steps::cargo_install_nextest
432      uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c
433    - name: steps::clear_target_dir_if_large
434      run: ./script/clear-target-dir-if-larger-than 350 200
435    - name: steps::setup_sccache
436      run: ./script/setup-sccache
437      env:
438        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
439        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
440        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
441        SCCACHE_BUCKET: sccache-zed
442    - name: steps::cargo_nextest
443      run: cargo nextest run --workspace --no-fail-fast --no-tests=warn${{ needs.orchestrate.outputs.changed_packages && format(' -E "{0}"', needs.orchestrate.outputs.changed_packages) || '' }}
444    - name: steps::show_sccache_stats
445      run: sccache --show-stats || true
446    - name: steps::cleanup_cargo_config
447      if: always()
448      run: |
449        rm -rf ./../.cargo
450    timeout-minutes: 60
451  doctests:
452    needs:
453    - orchestrate
454    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
455    runs-on: namespace-profile-16x32-ubuntu-2204
456    env:
457      CC: clang
458      CXX: clang++
459    steps:
460    - name: steps::checkout_repo
461      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
462      with:
463        clean: false
464    - name: steps::cache_rust_dependencies_namespace
465      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
466      with:
467        cache: rust
468        path: ~/.rustup
469    - name: steps::setup_linux
470      run: ./script/linux
471    - name: steps::download_wasi_sdk
472      run: ./script/download-wasi-sdk
473    - name: steps::setup_cargo_config
474      run: |
475        mkdir -p ./../.cargo
476        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
477    - name: steps::setup_sccache
478      run: ./script/setup-sccache
479      env:
480        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
481        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
482        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
483        SCCACHE_BUCKET: sccache-zed
484    - id: run_doctests
485      name: run_tests::doctests::run_doctests
486      run: |
487        cargo test --workspace --doc --no-fail-fast
488    - name: steps::show_sccache_stats
489      run: sccache --show-stats || true
490    - name: steps::cleanup_cargo_config
491      if: always()
492      run: |
493        rm -rf ./../.cargo
494    timeout-minutes: 60
495  check_workspace_binaries:
496    needs:
497    - orchestrate
498    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
499    runs-on: namespace-profile-8x16-ubuntu-2204
500    env:
501      CC: clang
502      CXX: clang++
503    steps:
504    - name: steps::checkout_repo
505      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
506      with:
507        clean: false
508    - name: steps::setup_cargo_config
509      run: |
510        mkdir -p ./../.cargo
511        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
512    - name: steps::cache_rust_dependencies_namespace
513      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
514      with:
515        cache: rust
516        path: ~/.rustup
517    - name: steps::setup_linux
518      run: ./script/linux
519    - name: steps::download_wasi_sdk
520      run: ./script/download-wasi-sdk
521    - name: steps::setup_sccache
522      run: ./script/setup-sccache
523      env:
524        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
525        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
526        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
527        SCCACHE_BUCKET: sccache-zed
528    - name: cargo build -p collab
529      run: cargo build -p collab
530    - name: cargo build --workspace --bins --examples
531      run: cargo build --workspace --bins --examples
532    - name: steps::show_sccache_stats
533      run: sccache --show-stats || true
534    - name: steps::cleanup_cargo_config
535      if: always()
536      run: |
537        rm -rf ./../.cargo
538    timeout-minutes: 60
539  build_visual_tests_binary:
540    needs:
541    - orchestrate
542    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
543    runs-on: namespace-profile-mac-large
544    steps:
545    - name: steps::checkout_repo
546      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
547      with:
548        clean: false
549    - name: steps::setup_cargo_config
550      run: |
551        mkdir -p ./../.cargo
552        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
553    - name: steps::cache_rust_dependencies_namespace
554      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
555      with:
556        cache: rust
557        path: ~/.rustup
558    - name: run_tests::build_visual_tests_binary::cargo_build_visual_tests
559      run: cargo build -p zed --bin zed_visual_test_runner --features visual-tests
560    - name: steps::cleanup_cargo_config
561      if: always()
562      run: |
563        rm -rf ./../.cargo
564  check_wasm:
565    needs:
566    - orchestrate
567    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
568    runs-on: namespace-profile-8x16-ubuntu-2204
569    steps:
570    - name: steps::checkout_repo
571      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
572      with:
573        clean: false
574    - name: steps::setup_cargo_config
575      run: |
576        mkdir -p ./../.cargo
577        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
578    - name: steps::cache_rust_dependencies_namespace
579      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
580      with:
581        cache: rust
582        path: ~/.rustup
583    - name: run_tests::check_wasm::install_nightly_wasm_toolchain
584      run: rustup toolchain install nightly --component rust-src --target wasm32-unknown-unknown
585    - name: steps::setup_sccache
586      run: ./script/setup-sccache
587      env:
588        R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
589        R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
590        R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
591        SCCACHE_BUCKET: sccache-zed
592    - name: run_tests::check_wasm::cargo_check_wasm
593      run: cargo -Zbuild-std=std,panic_abort check --target wasm32-unknown-unknown -p gpui_platform
594      env:
595        CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS: -C target-feature=+atomics,+bulk-memory,+mutable-globals
596        RUSTC_BOOTSTRAP: '1'
597    - name: steps::show_sccache_stats
598      run: sccache --show-stats || true
599    - name: steps::cleanup_cargo_config
600      if: always()
601      run: |
602        rm -rf ./../.cargo
603    timeout-minutes: 60
604  check_dependencies:
605    needs:
606    - orchestrate
607    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
608    runs-on: namespace-profile-2x4-ubuntu-2404
609    env:
610      CC: clang
611      CXX: clang++
612    steps:
613    - name: steps::checkout_repo
614      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
615      with:
616        clean: false
617    - name: steps::cache_rust_dependencies_namespace
618      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
619      with:
620        cache: rust
621        path: ~/.rustup
622    - name: run_tests::check_dependencies::install_cargo_machete
623      uses: taiki-e/install-action@02cc5f8ca9f2301050c0c099055816a41ee05507
624      with:
625        tool: cargo-machete@0.7.0
626    - name: run_tests::check_dependencies::run_cargo_machete
627      run: cargo machete
628    - name: run_tests::check_dependencies::check_cargo_lock
629      run: cargo update --locked --workspace
630    - name: run_tests::check_dependencies::check_vulnerable_dependencies
631      if: github.event_name == 'pull_request'
632      uses: actions/dependency-review-action@67d4f4bd7a9b17a0db54d2a7519187c65e339de8
633      with:
634        license-check: false
635    timeout-minutes: 60
636  check_docs:
637    needs:
638    - orchestrate
639    if: needs.orchestrate.outputs.run_docs == 'true' && github.event_name != 'merge_group'
640    runs-on: namespace-profile-8x16-ubuntu-2204
641    env:
642      CC: clang
643      CXX: clang++
644    steps:
645    - name: steps::checkout_repo
646      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
647      with:
648        clean: false
649    - name: steps::setup_cargo_config
650      run: |
651        mkdir -p ./../.cargo
652        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
653    - name: steps::cache_rust_dependencies_namespace
654      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
655      with:
656        cache: rust
657        path: ~/.rustup
658    - name: run_tests::check_docs::lychee_link_check
659      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
660      with:
661        args: --no-progress --exclude '^http' './docs/src/**/*'
662        fail: true
663        jobSummary: false
664    - name: steps::setup_linux
665      run: ./script/linux
666    - name: steps::download_wasi_sdk
667      run: ./script/download-wasi-sdk
668    - name: ./script/generate-action-metadata
669      run: ./script/generate-action-metadata
670    - name: run_tests::check_docs::install_mdbook
671      uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08
672      with:
673        mdbook-version: 0.4.37
674    - name: run_tests::check_docs::build_docs
675      run: |
676        mkdir -p target/deploy
677        mdbook build ./docs --dest-dir=../target/deploy/docs/
678    - name: run_tests::check_docs::lychee_link_check
679      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
680      with:
681        args: --no-progress --exclude '^http' 'target/deploy/docs'
682        fail: true
683        jobSummary: false
684    timeout-minutes: 60
685  check_licenses:
686    needs:
687    - orchestrate
688    if: needs.orchestrate.outputs.run_licenses == 'true' && github.event_name != 'merge_group'
689    runs-on: namespace-profile-2x4-ubuntu-2404
690    steps:
691    - name: steps::checkout_repo
692      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
693      with:
694        clean: false
695    - name: steps::cache_rust_dependencies_namespace
696      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
697      with:
698        cache: rust
699        path: ~/.rustup
700    - name: ./script/check-licenses
701      run: ./script/check-licenses
702    - name: ./script/generate-licenses
703      run: ./script/generate-licenses
704  check_scripts:
705    needs:
706    - orchestrate
707    if: needs.orchestrate.outputs.run_action_checks == 'true'
708    runs-on: namespace-profile-2x4-ubuntu-2404
709    steps:
710    - name: steps::checkout_repo
711      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
712      with:
713        clean: false
714    - name: run_tests::check_scripts::run_shellcheck
715      run: ./script/shellcheck-scripts error
716    - id: get_actionlint
717      name: run_tests::check_scripts::download_actionlint
718      run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
719    - name: run_tests::check_scripts::run_actionlint
720      run: '"$ACTIONLINT_BIN" -color'
721      env:
722        ACTIONLINT_BIN: ${{ steps.get_actionlint.outputs.executable }}
723    - name: steps::cache_rust_dependencies_namespace
724      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
725      with:
726        cache: rust
727        path: ~/.rustup
728    - name: run_tests::check_scripts::check_xtask_workflows
729      run: |
730        cargo xtask workflows
731        if ! git diff --exit-code .github; then
732          echo "Error: .github directory has uncommitted changes after running 'cargo xtask workflows'"
733          echo "Please run 'cargo xtask workflows' locally and commit the changes"
734          exit 1
735        fi
736    timeout-minutes: 60
737  check_postgres_and_protobuf_migrations:
738    needs:
739    - orchestrate
740    if: needs.orchestrate.outputs.run_tests == 'true'
741    runs-on: namespace-profile-16x32-ubuntu-2204
742    env:
743      GIT_AUTHOR_NAME: Protobuf Action
744      GIT_AUTHOR_EMAIL: ci@zed.dev
745      GIT_COMMITTER_NAME: Protobuf Action
746      GIT_COMMITTER_EMAIL: ci@zed.dev
747    steps:
748    - name: steps::checkout_repo
749      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
750      with:
751        clean: false
752        fetch-depth: 0
753    - name: run_tests::check_postgres_and_protobuf_migrations::ensure_fresh_merge
754      run: |
755        if [ -z "$GITHUB_BASE_REF" ];
756        then
757          echo "BUF_BASE_BRANCH=$(git merge-base origin/main HEAD)" >> "$GITHUB_ENV"
758        else
759          git checkout -B temp
760          git merge -q "origin/$GITHUB_BASE_REF" -m "merge main into temp"
761          echo "BUF_BASE_BRANCH=$GITHUB_BASE_REF" >> "$GITHUB_ENV"
762        fi
763    - name: run_tests::check_postgres_and_protobuf_migrations::bufbuild_setup_action
764      uses: bufbuild/buf-setup-action@v1
765      with:
766        version: v1.29.0
767        github_token: ${{ secrets.GITHUB_TOKEN }}
768    - name: run_tests::check_postgres_and_protobuf_migrations::bufbuild_breaking_action
769      uses: bufbuild/buf-breaking-action@v1
770      with:
771        input: crates/proto/proto/
772        against: https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/proto/proto/
773    - name: run_tests::check_postgres_and_protobuf_migrations::buf_lint
774      run: buf lint crates/proto/proto
775    - name: run_tests::check_postgres_and_protobuf_migrations::check_protobuf_formatting
776      run: buf format --diff --exit-code crates/proto/proto
777    timeout-minutes: 60
778  extension_tests:
779    needs:
780    - orchestrate
781    if: needs.orchestrate.outputs.changed_extensions != '[]'
782    permissions:
783      contents: read
784    strategy:
785      matrix:
786        extension: ${{ fromJson(needs.orchestrate.outputs.changed_extensions) }}
787      fail-fast: false
788      max-parallel: 1
789    uses: ./.github/workflows/extension_tests.yml
790    with:
791      working-directory: ${{ matrix.extension }}
792  tests_pass:
793    needs:
794    - orchestrate
795    - check_style
796    - clippy_windows
797    - clippy_linux
798    - clippy_mac
799    - clippy_mac_x86_64
800    - run_tests_windows
801    - run_tests_linux
802    - run_tests_mac
803    - doctests
804    - check_workspace_binaries
805    - build_visual_tests_binary
806    - check_wasm
807    - check_dependencies
808    - check_docs
809    - check_licenses
810    - check_scripts
811    - extension_tests
812    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && always()
813    runs-on: namespace-profile-2x4-ubuntu-2404
814    steps:
815    - name: run_tests::tests_pass
816      run: |
817        set +x
818        EXIT_CODE=0
819
820        check_result() {
821          echo "* $1: $2"
822          if [[ "$2" != "skipped" && "$2" != "success" ]]; then EXIT_CODE=1; fi
823        }
824
825        check_result "orchestrate" "$RESULT_ORCHESTRATE"
826        check_result "check_style" "$RESULT_CHECK_STYLE"
827        check_result "clippy_windows" "$RESULT_CLIPPY_WINDOWS"
828        check_result "clippy_linux" "$RESULT_CLIPPY_LINUX"
829        check_result "clippy_mac" "$RESULT_CLIPPY_MAC"
830        check_result "clippy_mac_x86_64" "$RESULT_CLIPPY_MAC_X86_64"
831        check_result "run_tests_windows" "$RESULT_RUN_TESTS_WINDOWS"
832        check_result "run_tests_linux" "$RESULT_RUN_TESTS_LINUX"
833        check_result "run_tests_mac" "$RESULT_RUN_TESTS_MAC"
834        check_result "doctests" "$RESULT_DOCTESTS"
835        check_result "check_workspace_binaries" "$RESULT_CHECK_WORKSPACE_BINARIES"
836        check_result "build_visual_tests_binary" "$RESULT_BUILD_VISUAL_TESTS_BINARY"
837        check_result "check_wasm" "$RESULT_CHECK_WASM"
838        check_result "check_dependencies" "$RESULT_CHECK_DEPENDENCIES"
839        check_result "check_docs" "$RESULT_CHECK_DOCS"
840        check_result "check_licenses" "$RESULT_CHECK_LICENSES"
841        check_result "check_scripts" "$RESULT_CHECK_SCRIPTS"
842        check_result "extension_tests" "$RESULT_EXTENSION_TESTS"
843
844        exit $EXIT_CODE
845      env:
846        RESULT_ORCHESTRATE: ${{ needs.orchestrate.result }}
847        RESULT_CHECK_STYLE: ${{ needs.check_style.result }}
848        RESULT_CLIPPY_WINDOWS: ${{ needs.clippy_windows.result }}
849        RESULT_CLIPPY_LINUX: ${{ needs.clippy_linux.result }}
850        RESULT_CLIPPY_MAC: ${{ needs.clippy_mac.result }}
851        RESULT_CLIPPY_MAC_X86_64: ${{ needs.clippy_mac_x86_64.result }}
852        RESULT_RUN_TESTS_WINDOWS: ${{ needs.run_tests_windows.result }}
853        RESULT_RUN_TESTS_LINUX: ${{ needs.run_tests_linux.result }}
854        RESULT_RUN_TESTS_MAC: ${{ needs.run_tests_mac.result }}
855        RESULT_DOCTESTS: ${{ needs.doctests.result }}
856        RESULT_CHECK_WORKSPACE_BINARIES: ${{ needs.check_workspace_binaries.result }}
857        RESULT_BUILD_VISUAL_TESTS_BINARY: ${{ needs.build_visual_tests_binary.result }}
858        RESULT_CHECK_WASM: ${{ needs.check_wasm.result }}
859        RESULT_CHECK_DEPENDENCIES: ${{ needs.check_dependencies.result }}
860        RESULT_CHECK_DOCS: ${{ needs.check_docs.result }}
861        RESULT_CHECK_LICENSES: ${{ needs.check_licenses.result }}
862        RESULT_CHECK_SCRIPTS: ${{ needs.check_scripts.result }}
863        RESULT_EXTENSION_TESTS: ${{ needs.extension_tests.result }}
864concurrency:
865  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
866  cancel-in-progress: true
867defaults:
868  run:
869    shell: bash -euxo pipefail {0}