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