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