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: 03d8e9aee95ea6117d75a48bcac2e19241f6e667
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 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: extension_tests::install_rust_target
67 run: rustup target add wasm32-wasip2
68 - name: steps::cargo_fmt
69 run: cargo fmt --all -- --check
70 - name: extension_tests::run_clippy
71 run: cargo clippy --release --all-targets --all-features -- --deny warnings
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 --target "$(rustc -vV | sed -n ''s|host: ||p'')"'
76 env:
77 NEXTEST_NO_TESTS: warn
78 timeout-minutes: 6
79 check_extension:
80 needs:
81 - orchestrate
82 if: needs.orchestrate.outputs.check_extension == 'true'
83 runs-on: namespace-profile-8x32-ubuntu-2404
84 steps:
85 - name: steps::checkout_repo
86 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
87 with:
88 clean: false
89 - id: cache-zed-extension-cli
90 name: extension_tests::cache_zed_extension_cli
91 uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
92 with:
93 path: zed-extension
94 key: zed-extension-${{ env.ZED_EXTENSION_CLI_SHA }}
95 - name: extension_tests::download_zed_extension_cli
96 if: steps.cache-zed-extension-cli.outputs.cache-hit != 'true'
97 run: |
98 wget --quiet "https://zed-extension-cli.nyc3.digitaloceanspaces.com/$ZED_EXTENSION_CLI_SHA/x86_64-unknown-linux-gnu/zed-extension"
99 chmod +x zed-extension
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 timeout-minutes: 4
106 tests_pass:
107 needs:
108 - orchestrate
109 - check_rust
110 - check_extension
111 if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && always()
112 runs-on: namespace-profile-2x4-ubuntu-2404
113 steps:
114 - name: run_tests::tests_pass
115 run: |
116 set +x
117 EXIT_CODE=0
118
119 check_result() {
120 echo "* $1: $2"
121 if [[ "$2" != "skipped" && "$2" != "success" ]]; then EXIT_CODE=1; fi
122 }
123
124 check_result "orchestrate" "${{ needs.orchestrate.result }}"
125 check_result "check_rust" "${{ needs.check_rust.result }}"
126 check_result "check_extension" "${{ needs.check_extension.result }}"
127
128 exit $EXIT_CODE
129concurrency:
130 group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
131 cancel-in-progress: true
132defaults:
133 run:
134 shell: bash -euxo pipefail {0}