ci: cancel PR workflows on close (#4323)

This commit is contained in:
Zhengchao An
2026-07-06 22:38:00 +08:00
committed by GitHub
parent 83edafb11f
commit 5f1759eb3c
6 changed files with 79 additions and 8 deletions
@@ -16,6 +16,7 @@ name: Architecture Migration Rules
on: on:
pull_request: pull_request:
types: [ opened, synchronize, reopened, closed ]
branches: [ main ] branches: [ main ]
paths: paths:
- "ARCHITECTURE.md" - "ARCHITECTURE.md"
@@ -27,9 +28,22 @@ on:
permissions: permissions:
contents: read contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
cancel-closed-pr-runs:
name: Cancel Closed PR Runs
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Explain cancellation run
run: echo "PR closed; this run only cancels older runs in the same concurrency group."
architecture-migration-rules: architecture-migration-rules:
name: Architecture Migration Rules name: Architecture Migration Rules
if: github.event_name != 'pull_request' || github.event.action != 'closed'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
+17 -1
View File
@@ -25,6 +25,7 @@ on:
- '.github/workflows/**' - '.github/workflows/**'
- 'scripts/security/check_workflow_pins.sh' - 'scripts/security/check_workflow_pins.sh'
pull_request: pull_request:
types: [ opened, synchronize, reopened, closed ]
branches: [ main ] branches: [ main ]
paths: paths:
- '**/Cargo.toml' - '**/Cargo.toml'
@@ -40,12 +41,25 @@ on:
permissions: permissions:
contents: read contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
jobs: jobs:
cancel-closed-pr-runs:
name: Cancel Closed PR Runs
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Explain cancellation run
run: echo "PR closed; this run only cancels older runs in the same concurrency group."
security-audit: security-audit:
name: Security Audit name: Security Audit
if: github.event_name != 'pull_request' || github.event.action != 'closed'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15 timeout-minutes: 15
steps: steps:
@@ -71,6 +85,7 @@ jobs:
cargo-deny: cargo-deny:
name: Cargo Deny name: Cargo Deny
if: github.event_name != 'pull_request' || github.event.action != 'closed'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 20 timeout-minutes: 20
steps: steps:
@@ -92,6 +107,7 @@ jobs:
workflow-pin-report: workflow-pin-report:
name: Workflow Pin Report name: Workflow Pin Report
if: github.event_name != 'pull_request' || github.event.action != 'closed'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 5 timeout-minutes: 5
steps: steps:
@@ -104,7 +120,7 @@ jobs:
dependency-review: dependency-review:
name: Dependency Review name: Dependency Review
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request' && github.event.action != 'closed'
permissions: permissions:
contents: read contents: read
pull-requests: write pull-requests: write
+11 -1
View File
@@ -35,6 +35,7 @@ on:
- ".github/workflows/audit.yml" - ".github/workflows/audit.yml"
- ".github/workflows/performance.yml" - ".github/workflows/performance.yml"
pull_request: pull_request:
types: [ opened, synchronize, reopened, closed ]
branches: [ main ] branches: [ main ]
paths-ignore: paths-ignore:
- "**.md" - "**.md"
@@ -63,7 +64,7 @@ permissions:
contents: read contents: read
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true cancel-in-progress: true
env: env:
@@ -72,8 +73,17 @@ env:
jobs: jobs:
cancel-closed-pr-runs:
name: Cancel Closed PR Runs
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Explain cancellation run
run: echo "PR closed; this run only cancels older runs in the same concurrency group."
skip-check: skip-check:
name: Skip Duplicate Actions name: Skip Duplicate Actions
if: github.event_name != 'pull_request' || github.event.action != 'closed'
permissions: permissions:
actions: write actions: write
contents: read contents: read
+14 -2
View File
@@ -16,7 +16,7 @@ name: CLA Check
on: on:
pull_request_target: pull_request_target:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened, closed]
merge_group: merge_group:
types: [checks_requested] types: [checks_requested]
issue_comment: issue_comment:
@@ -28,9 +28,21 @@ permissions:
issues: write issues: write
checks: write checks: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
cancel-closed-pr-runs:
name: Cancel Closed PR Runs
if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Explain cancellation run
run: echo "PR closed; this run only cancels older runs in the same concurrency group."
cla: cla:
if: ${{ github.event_name != 'issue_comment' || github.event.issue.pull_request }} if: ${{ (github.event_name != 'issue_comment' || github.event.issue.pull_request) && (github.event_name != 'pull_request_target' || github.event.action != 'closed') }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Report CLA result for merge queue - name: Report CLA result for merge queue
+12 -3
View File
@@ -16,6 +16,7 @@ name: Fuzz
on: on:
pull_request: pull_request:
types: [ opened, synchronize, reopened, closed ]
paths: paths:
- "fuzz/**" - "fuzz/**"
- "scripts/fuzz/**" - "scripts/fuzz/**"
@@ -41,7 +42,7 @@ permissions:
contents: read contents: read
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true cancel-in-progress: true
env: env:
@@ -50,13 +51,21 @@ env:
RUSTFLAGS: "--cfg tokio_unstable -C target-feature=-crt-static" RUSTFLAGS: "--cfg tokio_unstable -C target-feature=-crt-static"
jobs: jobs:
cancel-closed-pr-runs:
name: Cancel Closed PR Runs
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Explain cancellation run
run: echo "PR closed; this run only cancels older runs in the same concurrency group."
# ────────────────────────────────────────────────────────────── # ──────────────────────────────────────────────────────────────
# Phase 1: Build all fuzz harness binaries once. # Phase 1: Build all fuzz harness binaries once.
# ────────────────────────────────────────────────────────────── # ──────────────────────────────────────────────────────────────
fuzz-build: fuzz-build:
name: Build Fuzz Harness name: Build Fuzz Harness
if: > if: >
github.event_name == 'pull_request' || (github.event_name == 'pull_request' && github.event.action != 'closed') ||
github.event_name == 'schedule' || github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' github.event_name == 'workflow_dispatch'
runs-on: sm-standard-4 runs-on: sm-standard-4
@@ -110,7 +119,7 @@ jobs:
name: "Smoke / ${{ matrix.target }}" name: "Smoke / ${{ matrix.target }}"
needs: fuzz-build needs: fuzz-build
if: > if: >
github.event_name == 'pull_request' || (github.event_name == 'pull_request' && github.event.action != 'closed') ||
(github.event_name == 'workflow_dispatch' && (github.event_name == 'workflow_dispatch' &&
(github.event.inputs.profile == 'smoke' || github.event.inputs.profile == 'both')) (github.event.inputs.profile == 'smoke' || github.event.inputs.profile == 'both'))
runs-on: sm-standard-4 runs-on: sm-standard-4
+11 -1
View File
@@ -24,6 +24,7 @@ on:
- 'Cargo.lock' - 'Cargo.lock'
- '.github/workflows/nix.yml' - '.github/workflows/nix.yml'
pull_request: pull_request:
types: [ opened, synchronize, reopened, closed ]
branches: [ "main" ] branches: [ "main" ]
paths: paths:
- 'flake.nix' - 'flake.nix'
@@ -34,15 +35,24 @@ on:
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true cancel-in-progress: true
permissions: permissions:
contents: read contents: read
id-token: write id-token: write
jobs: jobs:
cancel-closed-pr-runs:
name: Cancel Closed PR Runs
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Explain cancellation run
run: echo "PR closed; this run only cancels older runs in the same concurrency group."
nix-validation: nix-validation:
name: Nix Build & Check name: Nix Build & Check
if: github.event_name != 'pull_request' || github.event.action != 'closed'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 60 timeout-minutes: 60
permissions: permissions: