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 +nightly -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    - name: steps::show_sccache_stats
597      run: sccache --show-stats || true
598    - name: steps::cleanup_cargo_config
599      if: always()
600      run: |
601        rm -rf ./../.cargo
602    timeout-minutes: 60
603  check_dependencies:
604    needs:
605    - orchestrate
606    if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != 'merge_group'
607    runs-on: namespace-profile-2x4-ubuntu-2404
608    env:
609      CC: clang
610      CXX: clang++
611    steps:
612    - name: steps::checkout_repo
613      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
614      with:
615        clean: false
616    - name: steps::cache_rust_dependencies_namespace
617      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
618      with:
619        cache: rust
620        path: ~/.rustup
621    - name: run_tests::check_dependencies::install_cargo_machete
622      uses: taiki-e/install-action@02cc5f8ca9f2301050c0c099055816a41ee05507
623      with:
624        tool: cargo-machete@0.7.0
625    - name: run_tests::check_dependencies::run_cargo_machete
626      run: cargo machete
627    - name: run_tests::check_dependencies::check_cargo_lock
628      run: cargo update --locked --workspace
629    - name: run_tests::check_dependencies::check_vulnerable_dependencies
630      if: github.event_name == 'pull_request'
631      uses: actions/dependency-review-action@67d4f4bd7a9b17a0db54d2a7519187c65e339de8
632      with:
633        license-check: false
634    timeout-minutes: 60
635  check_docs:
636    needs:
637    - orchestrate
638    if: needs.orchestrate.outputs.run_docs == 'true' && github.event_name != 'merge_group'
639    runs-on: namespace-profile-8x16-ubuntu-2204
640    env:
641      CC: clang
642      CXX: clang++
643    steps:
644    - name: steps::checkout_repo
645      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
646      with:
647        clean: false
648    - name: steps::setup_cargo_config
649      run: |
650        mkdir -p ./../.cargo
651        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
652    - name: steps::cache_rust_dependencies_namespace
653      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
654      with:
655        cache: rust
656        path: ~/.rustup
657    - name: run_tests::check_docs::lychee_link_check
658      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
659      with:
660        args: --no-progress --exclude '^http' './docs/src/**/*'
661        fail: true
662        jobSummary: false
663    - name: steps::setup_linux
664      run: ./script/linux
665    - name: steps::download_wasi_sdk
666      run: ./script/download-wasi-sdk
667    - name: ./script/generate-action-metadata
668      run: ./script/generate-action-metadata
669    - name: run_tests::check_docs::install_mdbook
670      uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08
671      with:
672        mdbook-version: 0.4.37
673    - name: run_tests::check_docs::build_docs
674      run: |
675        mkdir -p target/deploy
676        mdbook build ./docs --dest-dir=../target/deploy/docs/
677    - name: run_tests::check_docs::lychee_link_check
678      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
679      with:
680        args: --no-progress --exclude '^http' 'target/deploy/docs'
681        fail: true
682        jobSummary: false
683    timeout-minutes: 60
684  check_licenses:
685    needs:
686    - orchestrate
687    if: needs.orchestrate.outputs.run_licenses == 'true' && github.event_name != 'merge_group'
688    runs-on: namespace-profile-2x4-ubuntu-2404
689    steps:
690    - name: steps::checkout_repo
691      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
692      with:
693        clean: false
694    - name: steps::cache_rust_dependencies_namespace
695      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
696      with:
697        cache: rust
698        path: ~/.rustup
699    - name: ./script/check-licenses
700      run: ./script/check-licenses
701    - name: ./script/generate-licenses
702      run: ./script/generate-licenses
703  check_scripts:
704    needs:
705    - orchestrate
706    if: needs.orchestrate.outputs.run_action_checks == 'true'
707    runs-on: namespace-profile-2x4-ubuntu-2404
708    steps:
709    - name: steps::checkout_repo
710      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
711      with:
712        clean: false
713    - name: run_tests::check_scripts::run_shellcheck
714      run: ./script/shellcheck-scripts error
715    - id: get_actionlint
716      name: run_tests::check_scripts::download_actionlint
717      run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
718    - name: run_tests::check_scripts::run_actionlint
719      run: '"$ACTIONLINT_BIN" -color'
720      env:
721        ACTIONLINT_BIN: ${{ steps.get_actionlint.outputs.executable }}
722    - name: steps::cache_rust_dependencies_namespace
723      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
724      with:
725        cache: rust
726        path: ~/.rustup
727    - name: run_tests::check_scripts::check_xtask_workflows
728      run: |
729        cargo xtask workflows
730        if ! git diff --exit-code .github; then
731          echo "Error: .github directory has uncommitted changes after running 'cargo xtask workflows'"
732          echo "Please run 'cargo xtask workflows' locally and commit the changes"
733          exit 1
734        fi
735    timeout-minutes: 60
736  check_postgres_and_protobuf_migrations:
737    needs:
738    - orchestrate
739    if: needs.orchestrate.outputs.run_tests == 'true'
740    runs-on: namespace-profile-16x32-ubuntu-2204
741    env:
742      GIT_AUTHOR_NAME: Protobuf Action
743      GIT_AUTHOR_EMAIL: ci@zed.dev
744      GIT_COMMITTER_NAME: Protobuf Action
745      GIT_COMMITTER_EMAIL: ci@zed.dev
746    steps:
747    - name: steps::checkout_repo
748      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
749      with:
750        clean: false
751        fetch-depth: 0
752    - name: run_tests::check_postgres_and_protobuf_migrations::ensure_fresh_merge
753      run: |
754        if [ -z "$GITHUB_BASE_REF" ];
755        then
756          echo "BUF_BASE_BRANCH=$(git merge-base origin/main HEAD)" >> "$GITHUB_ENV"
757        else
758          git checkout -B temp
759          git merge -q "origin/$GITHUB_BASE_REF" -m "merge main into temp"
760          echo "BUF_BASE_BRANCH=$GITHUB_BASE_REF" >> "$GITHUB_ENV"
761        fi
762    - name: run_tests::check_postgres_and_protobuf_migrations::bufbuild_setup_action
763      uses: bufbuild/buf-setup-action@v1
764      with:
765        version: v1.29.0
766        github_token: ${{ secrets.GITHUB_TOKEN }}
767    - name: run_tests::check_postgres_and_protobuf_migrations::bufbuild_breaking_action
768      uses: bufbuild/buf-breaking-action@v1
769      with:
770        input: crates/proto/proto/
771        against: https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/proto/proto/
772    - name: run_tests::check_postgres_and_protobuf_migrations::buf_lint
773      run: buf lint crates/proto/proto
774    - name: run_tests::check_postgres_and_protobuf_migrations::check_protobuf_formatting
775      run: buf format --diff --exit-code crates/proto/proto
776    timeout-minutes: 60
777  extension_tests:
778    needs:
779    - orchestrate
780    if: needs.orchestrate.outputs.changed_extensions != '[]'
781    permissions:
782      contents: read
783    strategy:
784      matrix:
785        extension: ${{ fromJson(needs.orchestrate.outputs.changed_extensions) }}
786      fail-fast: false
787      max-parallel: 1
788    uses: ./.github/workflows/extension_tests.yml
789    with:
790      working-directory: ${{ matrix.extension }}
791  tests_pass:
792    needs:
793    - orchestrate
794    - check_style
795    - clippy_windows
796    - clippy_linux
797    - clippy_mac
798    - clippy_mac_x86_64
799    - run_tests_windows
800    - run_tests_linux
801    - run_tests_mac
802    - doctests
803    - check_workspace_binaries
804    - build_visual_tests_binary
805    - check_wasm
806    - check_dependencies
807    - check_docs
808    - check_licenses
809    - check_scripts
810    - extension_tests
811    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && always()
812    runs-on: namespace-profile-2x4-ubuntu-2404
813    steps:
814    - name: run_tests::tests_pass
815      run: |
816        set +x
817        EXIT_CODE=0
818
819        check_result() {
820          echo "* $1: $2"
821          if [[ "$2" != "skipped" && "$2" != "success" ]]; then EXIT_CODE=1; fi
822        }
823
824        check_result "orchestrate" "$RESULT_ORCHESTRATE"
825        check_result "check_style" "$RESULT_CHECK_STYLE"
826        check_result "clippy_windows" "$RESULT_CLIPPY_WINDOWS"
827        check_result "clippy_linux" "$RESULT_CLIPPY_LINUX"
828        check_result "clippy_mac" "$RESULT_CLIPPY_MAC"
829        check_result "clippy_mac_x86_64" "$RESULT_CLIPPY_MAC_X86_64"
830        check_result "run_tests_windows" "$RESULT_RUN_TESTS_WINDOWS"
831        check_result "run_tests_linux" "$RESULT_RUN_TESTS_LINUX"
832        check_result "run_tests_mac" "$RESULT_RUN_TESTS_MAC"
833        check_result "doctests" "$RESULT_DOCTESTS"
834        check_result "check_workspace_binaries" "$RESULT_CHECK_WORKSPACE_BINARIES"
835        check_result "build_visual_tests_binary" "$RESULT_BUILD_VISUAL_TESTS_BINARY"
836        check_result "check_wasm" "$RESULT_CHECK_WASM"
837        check_result "check_dependencies" "$RESULT_CHECK_DEPENDENCIES"
838        check_result "check_docs" "$RESULT_CHECK_DOCS"
839        check_result "check_licenses" "$RESULT_CHECK_LICENSES"
840        check_result "check_scripts" "$RESULT_CHECK_SCRIPTS"
841        check_result "extension_tests" "$RESULT_EXTENSION_TESTS"
842
843        exit $EXIT_CODE
844      env:
845        RESULT_ORCHESTRATE: ${{ needs.orchestrate.result }}
846        RESULT_CHECK_STYLE: ${{ needs.check_style.result }}
847        RESULT_CLIPPY_WINDOWS: ${{ needs.clippy_windows.result }}
848        RESULT_CLIPPY_LINUX: ${{ needs.clippy_linux.result }}
849        RESULT_CLIPPY_MAC: ${{ needs.clippy_mac.result }}
850        RESULT_CLIPPY_MAC_X86_64: ${{ needs.clippy_mac_x86_64.result }}
851        RESULT_RUN_TESTS_WINDOWS: ${{ needs.run_tests_windows.result }}
852        RESULT_RUN_TESTS_LINUX: ${{ needs.run_tests_linux.result }}
853        RESULT_RUN_TESTS_MAC: ${{ needs.run_tests_mac.result }}
854        RESULT_DOCTESTS: ${{ needs.doctests.result }}
855        RESULT_CHECK_WORKSPACE_BINARIES: ${{ needs.check_workspace_binaries.result }}
856        RESULT_BUILD_VISUAL_TESTS_BINARY: ${{ needs.build_visual_tests_binary.result }}
857        RESULT_CHECK_WASM: ${{ needs.check_wasm.result }}
858        RESULT_CHECK_DEPENDENCIES: ${{ needs.check_dependencies.result }}
859        RESULT_CHECK_DOCS: ${{ needs.check_docs.result }}
860        RESULT_CHECK_LICENSES: ${{ needs.check_licenses.result }}
861        RESULT_CHECK_SCRIPTS: ${{ needs.check_scripts.result }}
862        RESULT_EXTENSION_TESTS: ${{ needs.extension_tests.result }}
863concurrency:
864  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
865  cancel-in-progress: true
866defaults:
867  run:
868    shell: bash -euxo pipefail {0}