GitHub allows defining a default shell for all jobs on the workflow level, which we did not use before, yet practically did when it comes down to our usage of `named::bash`. Since this makes stuff quite verbose, I decided on using the defaults instead so the workflows become somewhat easier to audit when reading the generated files. Powershell steps continue to use Powershell, only the default for bash scripts was modified. Release Notes: - N/A
135 lines
4.8 KiB
YAML
135 lines
4.8 KiB
YAML
# Generated from xtask::workflows::extension_tests
|
|
# Rebuild with `cargo xtask workflows`.
|
|
name: extension_tests
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_BACKTRACE: '1'
|
|
CARGO_INCREMENTAL: '0'
|
|
ZED_EXTENSION_CLI_SHA: 03d8e9aee95ea6117d75a48bcac2e19241f6e667
|
|
RUSTUP_TOOLCHAIN: stable
|
|
CARGO_BUILD_TARGET: wasm32-wasip2
|
|
on:
|
|
workflow_call: {}
|
|
jobs:
|
|
orchestrate:
|
|
if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
|
|
runs-on: namespace-profile-2x4-ubuntu-2404
|
|
steps:
|
|
- name: steps::checkout_repo
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
with:
|
|
clean: false
|
|
fetch-depth: ${{ github.ref == 'refs/heads/main' && 2 || 350 }}
|
|
- id: filter
|
|
name: filter
|
|
run: |
|
|
if [ -z "$GITHUB_BASE_REF" ]; then
|
|
echo "Not in a PR context (i.e., push to main/stable/preview)"
|
|
COMPARE_REV="$(git rev-parse HEAD~1)"
|
|
else
|
|
echo "In a PR context comparing to pull_request.base.ref"
|
|
git fetch origin "$GITHUB_BASE_REF" --depth=350
|
|
COMPARE_REV="$(git merge-base "origin/${GITHUB_BASE_REF}" HEAD)"
|
|
fi
|
|
CHANGED_FILES="$(git diff --name-only "$COMPARE_REV" ${{ github.sha }})"
|
|
|
|
check_pattern() {
|
|
local output_name="$1"
|
|
local pattern="$2"
|
|
local grep_arg="$3"
|
|
|
|
echo "$CHANGED_FILES" | grep "$grep_arg" "$pattern" && \
|
|
echo "${output_name}=true" >> "$GITHUB_OUTPUT" || \
|
|
echo "${output_name}=false" >> "$GITHUB_OUTPUT"
|
|
}
|
|
|
|
check_pattern "check_rust" '^(Cargo.lock|Cargo.toml|.*\.rs)$' -qP
|
|
check_pattern "check_extension" '^.*\.scm$' -qP
|
|
outputs:
|
|
check_rust: ${{ steps.filter.outputs.check_rust }}
|
|
check_extension: ${{ steps.filter.outputs.check_extension }}
|
|
check_rust:
|
|
needs:
|
|
- orchestrate
|
|
if: needs.orchestrate.outputs.check_rust == 'true'
|
|
runs-on: namespace-profile-8x16-ubuntu-2204
|
|
steps:
|
|
- name: steps::checkout_repo
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
with:
|
|
clean: false
|
|
- name: steps::cache_rust_dependencies_namespace
|
|
uses: namespacelabs/nscloud-cache-action@v1
|
|
with:
|
|
cache: rust
|
|
path: ~/.rustup
|
|
- name: extension_tests::install_rust_target
|
|
run: rustup target add wasm32-wasip2
|
|
- name: steps::cargo_fmt
|
|
run: cargo fmt --all -- --check
|
|
- name: extension_tests::run_clippy
|
|
run: cargo clippy --release --all-targets --all-features -- --deny warnings
|
|
- name: steps::cargo_install_nextest
|
|
uses: taiki-e/install-action@nextest
|
|
- name: steps::cargo_nextest
|
|
run: 'cargo nextest run --workspace --no-fail-fast --target "$(rustc -vV | sed -n ''s|host: ||p'')"'
|
|
env:
|
|
NEXTEST_NO_TESTS: warn
|
|
timeout-minutes: 6
|
|
check_extension:
|
|
needs:
|
|
- orchestrate
|
|
if: needs.orchestrate.outputs.check_extension == 'true'
|
|
runs-on: namespace-profile-8x32-ubuntu-2404
|
|
steps:
|
|
- name: steps::checkout_repo
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
with:
|
|
clean: false
|
|
- id: cache-zed-extension-cli
|
|
name: extension_tests::cache_zed_extension_cli
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
|
with:
|
|
path: zed-extension
|
|
key: zed-extension-${{ env.ZED_EXTENSION_CLI_SHA }}
|
|
- name: extension_tests::download_zed_extension_cli
|
|
if: steps.cache-zed-extension-cli.outputs.cache-hit != 'true'
|
|
run: |
|
|
wget --quiet "https://zed-extension-cli.nyc3.digitaloceanspaces.com/$ZED_EXTENSION_CLI_SHA/x86_64-unknown-linux-gnu/zed-extension"
|
|
chmod +x zed-extension
|
|
- name: extension_tests::check
|
|
run: |
|
|
mkdir -p /tmp/ext-scratch
|
|
mkdir -p /tmp/ext-output
|
|
./zed-extension --source-dir . --scratch-dir /tmp/ext-scratch --output-dir /tmp/ext-output
|
|
timeout-minutes: 4
|
|
tests_pass:
|
|
needs:
|
|
- orchestrate
|
|
- check_rust
|
|
- check_extension
|
|
if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && always()
|
|
runs-on: namespace-profile-2x4-ubuntu-2404
|
|
steps:
|
|
- name: run_tests::tests_pass
|
|
run: |
|
|
set +x
|
|
EXIT_CODE=0
|
|
|
|
check_result() {
|
|
echo "* $1: $2"
|
|
if [[ "$2" != "skipped" && "$2" != "success" ]]; then EXIT_CODE=1; fi
|
|
}
|
|
|
|
check_result "orchestrate" "${{ needs.orchestrate.result }}"
|
|
check_result "check_rust" "${{ needs.check_rust.result }}"
|
|
check_result "check_extension" "${{ needs.check_extension.result }}"
|
|
|
|
exit $EXIT_CODE
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
|
|
cancel-in-progress: true
|
|
defaults:
|
|
run:
|
|
shell: bash -euxo pipefail {0}
|