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