Skip to content

Commit

Permalink
Prevent duplicate actions from running. (#252)
Browse files Browse the repository at this point in the history
* Use
skip-duplicate-actions
 to avoid running same actions multiple times concurrently.

* Fix test workflow to only run on Ubuntu (latest).
  • Loading branch information
AjayKMehta authored Feb 24, 2025
1 parent f513ab7 commit ea1fac8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 6 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,24 @@ permissions:
contents: write

jobs:

pre_job:
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: 'true'
skip_after_successful_duplicate: 'true'
concurrent_skipping: same_content_newer

analyze:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
name: Analyze (${{ matrix.language }})
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@ concurrency:
cancel-in-progress: true

jobs:
pre_job:
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: 'true'
skip_after_successful_duplicate: 'true'
concurrent_skipping: same_content_newer

dependency-review:
if: github.actor != 'dependabot[bot]'
needs: pre_job
if: github.actor != 'dependabot[bot]' && needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,27 @@ on:
description: "The reason for running the workflow"
required: true
default: "Manual run"

name: Semgrep

jobs:
pre_job:
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: 'true'
skip_after_successful_duplicate: 'true'
concurrent_skipping: same_content_newer

semgrep:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
name: Semgrep/CI
runs-on: ubuntu-latest
env:
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,26 @@ concurrency:
cancel-in-progress: true

jobs:
pre_job:
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: 'true'
skip_after_successful_duplicate: 'true'
concurrent_skipping: same_content_newer

test:
name: test-${{matrix.os}}
runs-on: ${{ matrix.os }}
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
name: test
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
os: [ubuntu-latest]
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
DOTNET_NOLOGO: true
Expand Down

0 comments on commit ea1fac8

Please sign in to comment.