|
21 | 21 | - ".github/workflows/ci-rust-python-package.yaml" |
22 | 22 | - ".github/workflows/release-rust-python-package.yaml" |
23 | 23 |
|
| 24 | +concurrency: |
| 25 | + group: ci-rust-python-package-${{ github.event.pull_request.head.repo.full_name || github.repository }}-${{ github.head_ref || github.ref_name }} |
| 26 | + cancel-in-progress: true |
| 27 | + |
24 | 28 | permissions: |
25 | 29 | contents: read |
| 30 | + pull-requests: read |
26 | 31 |
|
27 | 32 | jobs: |
| 33 | + dedupe: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + outputs: |
| 36 | + should_run: ${{ steps.decide.outputs.should_run }} |
| 37 | + steps: |
| 38 | + - id: decide |
| 39 | + shell: bash |
| 40 | + env: |
| 41 | + EVENT_NAME: ${{ github.event_name }} |
| 42 | + REF_NAME: ${{ github.ref_name }} |
| 43 | + REF_TYPE: ${{ github.ref_type }} |
| 44 | + REPOSITORY: ${{ github.repository }} |
| 45 | + GITHUB_TOKEN: ${{ github.token }} |
| 46 | + run: | |
| 47 | + set -euo pipefail |
| 48 | + should_run=true |
| 49 | +
|
| 50 | + if [[ "${EVENT_NAME}" == "push" && "${REF_TYPE}" == "branch" ]]; then |
| 51 | + head="${REPOSITORY%%/*}:${REF_NAME}" |
| 52 | + prs_json=$(curl -fsSL \ |
| 53 | + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ |
| 54 | + -H "Accept: application/vnd.github+json" \ |
| 55 | + "https://api.github.com/repos/${REPOSITORY}/pulls?state=open&head=${head}") |
| 56 | + open_pr_count=$(JSON_INPUT="$prs_json" python3 - <<'PY' |
| 57 | + import json |
| 58 | + import os |
| 59 | +
|
| 60 | + print(len(json.loads(os.environ["JSON_INPUT"]))) |
| 61 | + PY |
| 62 | + ) |
| 63 | + if [[ "${open_pr_count}" != "0" ]]; then |
| 64 | + should_run=false |
| 65 | + fi |
| 66 | + fi |
| 67 | +
|
| 68 | + echo "should_run=${should_run}" >> "$GITHUB_OUTPUT" |
| 69 | +
|
28 | 70 | validate-and-detect: |
| 71 | + needs: dedupe |
| 72 | + if: needs.dedupe.outputs.should_run == 'true' |
29 | 73 | runs-on: ubuntu-latest |
30 | 74 | outputs: |
31 | 75 | plugins: ${{ steps.detect.outputs.plugins }} |
|
76 | 120 | fi |
77 | 121 |
|
78 | 122 | build-test: |
79 | | - needs: validate-and-detect |
80 | | - if: needs.validate-and-detect.outputs.has_plugins == 'true' |
| 123 | + needs: [dedupe, validate-and-detect] |
| 124 | + if: needs.dedupe.outputs.should_run == 'true' && needs.validate-and-detect.outputs.has_plugins == 'true' |
81 | 125 | strategy: |
82 | 126 | fail-fast: false |
83 | 127 | matrix: |
|
0 commit comments