Skip to content

Commit

Permalink
Merge pull request #149 from pllim/fix-cancel-ci
Browse files Browse the repository at this point in the history
TST: Fix cancel workflow for PRs
  • Loading branch information
pllim authored Feb 26, 2021
2 parents 672828a + c45b3df commit 0780840
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/cancel_workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Cancel duplicate workflows

on:
workflow_run:
workflows: ["CI", "CodeQL"]
types:
- requested

# Note: This has to be in workflow_run so it works for PRs from forks.
jobs:
cancel:
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # 0.8.0
with:
workflow_id: ${{ github.event.workflow.id }}
11 changes: 3 additions & 8 deletions .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- cron: '0 6 * * 2'

jobs:
cancel_ci:
initial_checks:
name: Mandatory checks before CI
runs-on: ubuntu-latest
steps:
Expand All @@ -25,17 +25,12 @@ jobs:
} else {
core.info(`PR opened correctly against ${allowed_basebranch}`);
}
# TODO: Fix this for PRs
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@ce177499ccf9fd2aded3b0426c97e5434c2e8a73
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
# The rest only run if above are done

pep_and_audit:
runs-on: ubuntu-latest
needs: cancel_ci
needs: initial_checks
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -62,7 +57,7 @@ jobs:
link_check:
runs-on: ubuntu-latest
needs: cancel_ci
needs: initial_checks
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,8 @@ on:
branches: [ master ]

jobs:
cancel_ci:
name: Mandatory checks before CI
runs-on: ubuntu-latest
steps:
# TODO: Fix this for PRs
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@ce177499ccf9fd2aded3b0426c97e5434c2e8a73
with:
access_token: ${{ secrets.GITHUB_TOKEN }}

# The rest only run if above are done

analyze:
name: Analyze
needs: cancel_ci
runs-on: ubuntu-latest

strategy:
Expand Down

0 comments on commit 0780840

Please sign in to comment.