Skip to content

Commit 9cd5826

Browse files
authored
Merge pull request #20116 from Veykril/push-uypnmlyvotlm
ci: Cancel workflow only after the main matrix has finished
2 parents 502bac3 + ea2e042 commit 9cd5826

File tree

1 file changed

+19
-15
lines changed
  • src/tools/rust-analyzer/.github/workflows

1 file changed

+19
-15
lines changed

src/tools/rust-analyzer/.github/workflows/ci.yaml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
rustup toolchain install nightly --profile minimal --component rustfmt
104104
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/rust.json
105105
- name: Install Rust Problem Matcher
106-
if: matrix.os == 'ubuntu-latest'
106+
if: matrix.os == 'macos-latest'
107107
run: echo "::add-matcher::.github/rust.json"
108108

109109
# - name: Cache Dependencies
@@ -120,23 +120,9 @@ jobs:
120120
if: matrix.os == 'ubuntu-latest'
121121
run: cargo codegen --check
122122

123-
- name: Compile tests
124-
run: cargo test --no-run
125-
126123
- name: Run tests
127124
run: cargo nextest run --no-fail-fast --hide-progress-bar --status-level fail
128125

129-
- name: Cancel parallel jobs
130-
if: failure()
131-
run: |
132-
# https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#cancel-a-workflow-run
133-
curl -L \
134-
-X POST \
135-
-H "Accept: application/vnd.github.v3+json" \
136-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
137-
-H "X-GitHub-Api-Version: 2022-11-28" \
138-
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel
139-
140126
- name: Run Clippy
141127
if: matrix.os == 'macos-latest'
142128
run: cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr
@@ -337,3 +323,21 @@ jobs:
337323
jq -C <<< '${{ toJson(needs) }}'
338324
# Check if all jobs that we depend on (in the needs array) were successful (or have been skipped).
339325
jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'
326+
327+
cancel-if-matrix-failed:
328+
needs: rust
329+
runs-on: ubuntu-latest
330+
steps:
331+
- name: Cancel parallel jobs
332+
if: failure()
333+
run: |
334+
if [ jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}' ]; then
335+
exit 0
336+
fi
337+
# https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#cancel-a-workflow-run
338+
curl -L \
339+
-X POST \
340+
-H "Accept: application/vnd.github.v3+json" \
341+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
342+
-H "X-GitHub-Api-Version: 2022-11-28" \
343+
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel

0 commit comments

Comments
 (0)