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