extension_tests.yml

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