1# Generated from xtask::workflows::extension_tests
2# Rebuild with `cargo xtask workflows`.
3name: extension_tests
4env:
5 CARGO_TERM_COLOR: always
6 RUST_BACKTRACE: '1'
7 CARGO_INCREMENTAL: '0'
8 ZED_EXTENSION_CLI_SHA: 7cfce605704d41ca247e3f84804bf323f6c6caaf
9 CARGO_BUILD_TARGET: wasm32-wasip2
10on:
11 workflow_call: {}
12jobs:
13 orchestrate:
14 if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
15 runs-on: namespace-profile-2x4-ubuntu-2404
16 steps:
17 - name: steps::checkout_repo
18 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
19 with:
20 clean: false
21 fetch-depth: ${{ github.ref == 'refs/heads/main' && 2 || 350 }}
22 - id: filter
23 name: filter
24 run: |
25 if [ -z "$GITHUB_BASE_REF" ]; then
26 echo "Not in a PR context (i.e., push to main/stable/preview)"
27 COMPARE_REV="$(git rev-parse HEAD~1)"
28 else
29 echo "In a PR context comparing to pull_request.base.ref"
30 git fetch origin "$GITHUB_BASE_REF" --depth=350
31 COMPARE_REV="$(git merge-base "origin/${GITHUB_BASE_REF}" HEAD)"
32 fi
33 CHANGED_FILES="$(git diff --name-only "$COMPARE_REV" ${{ github.sha }})"
34
35 check_pattern() {
36 local output_name="$1"
37 local pattern="$2"
38 local grep_arg="$3"
39
40 echo "$CHANGED_FILES" | grep "$grep_arg" "$pattern" && \
41 echo "${output_name}=true" >> "$GITHUB_OUTPUT" || \
42 echo "${output_name}=false" >> "$GITHUB_OUTPUT"
43 }
44
45 check_pattern "check_rust" '^(Cargo.lock|Cargo.toml|.*\.rs)$' -qP
46 check_pattern "check_extension" '^.*\.scm$' -qP
47 shell: bash -euxo pipefail {0}
48 outputs:
49 check_rust: ${{ steps.filter.outputs.check_rust }}
50 check_extension: ${{ steps.filter.outputs.check_extension }}
51 check_rust:
52 needs:
53 - orchestrate
54 if: needs.orchestrate.outputs.check_rust == 'true'
55 runs-on: namespace-profile-8x16-ubuntu-2204
56 steps:
57 - name: steps::checkout_repo
58 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
59 with:
60 clean: false
61 - name: steps::cache_rust_dependencies_namespace
62 uses: namespacelabs/nscloud-cache-action@v1
63 with:
64 cache: rust
65 path: ~/.rustup
66 - name: steps::cargo_fmt
67 run: cargo fmt --all -- --check
68 shell: bash -euxo pipefail {0}
69 - name: extension_tests::run_clippy
70 run: cargo clippy --release --all-targets --all-features -- --deny warnings
71 shell: bash -euxo pipefail {0}
72 - name: steps::cargo_install_nextest
73 uses: taiki-e/install-action@nextest
74 - name: steps::cargo_nextest
75 run: cargo nextest run --workspace --no-fail-fast
76 shell: bash -euxo pipefail {0}
77 env:
78 NEXTEST_NO_TESTS: warn
79 timeout-minutes: 6
80 check_extension:
81 needs:
82 - orchestrate
83 if: needs.orchestrate.outputs.check_extension == 'true'
84 runs-on: namespace-profile-8x32-ubuntu-2404
85 steps:
86 - name: steps::checkout_repo
87 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
88 with:
89 clean: false
90 - id: cache-zed-extension-cli
91 name: extension_tests::cache_zed_extension_cli
92 uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
93 with:
94 path: zed-extension
95 key: zed-extension-${{ env.ZED_EXTENSION_CLI_SHA }}
96 - name: extension_tests::download_zed_extension_cli
97 if: steps.cache-zed-extension-cli.outputs.cache-hit != 'true'
98 run: |
99 wget --quiet "https://zed-extension-cli.nyc3.digitaloceanspaces.com/$ZED_EXTENSION_CLI_SHA/x86_64-unknown-linux-gnu/zed-extension"
100 chmod +x zed-extension
101 shell: bash -euxo pipefail {0}
102 - name: extension_tests::check
103 run: |
104 mkdir -p /tmp/ext-scratch
105 mkdir -p /tmp/ext-output
106 ./zed-extension --source-dir . --scratch-dir /tmp/ext-scratch --output-dir /tmp/ext-output
107 shell: bash -euxo pipefail {0}
108 timeout-minutes: 4
109 tests_pass:
110 needs:
111 - orchestrate
112 - check_rust
113 - check_extension
114 if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && always()
115 runs-on: namespace-profile-2x4-ubuntu-2404
116 steps:
117 - name: run_tests::tests_pass
118 run: |
119 set +x
120 EXIT_CODE=0
121
122 check_result() {
123 echo "* $1: $2"
124 if [[ "$2" != "skipped" && "$2" != "success" ]]; then EXIT_CODE=1; fi
125 }
126
127 check_result "orchestrate" "${{ needs.orchestrate.result }}"
128 check_result "check_rust" "${{ needs.check_rust.result }}"
129 check_result "check_extension" "${{ needs.check_extension.result }}"
130
131 exit $EXIT_CODE
132 shell: bash -euxo pipefail {0}
133concurrency:
134 group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
135 cancel-in-progress: true