Skip to content

Commit

Permalink
add github ci PR concurrency cancellation (#864)
Browse files Browse the repository at this point in the history
**Background**

When creating pull requests and pushing multiple commits one after
another, previous pipelines are not cancelld and continue to run, even
if they are now useless

**Changes**

- Here added concurrency for pull requests commits
- When new pull request is pushed, the old pipelines of this PR will be
cancelled

**Test plan**

- See this PR
- See after few pushes previous jobs is cancelled
  • Loading branch information
makeevrserg authored May 23, 2024
1 parent 8c39d27 commit a8cb40c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,30 @@ on:
- 'dev'
merge_group:

# Concurrency strategy:
# github.workflow: distinguish this workflow from others
# github.event_name: distinguish `push` event from `pull_request` event
# github.ref_name: distinguish branch
# github.repository: distinguish owner+repository
#
# Reference:
# https://docs.github.com/en/actions/using-jobs/using-concurrency
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{github.ref_name}}-${{github.repository}}
cancel-in-progress: true


jobs:
info:
name: "Display concurrency info"
runs-on: ubuntu-latest
steps:
- run: |
echo "github.workflow=${{ github.workflow }}"
echo "github.event_name=${{ github.event_name }}"
echo "github.ref_name=${{ github.ref_name }}"
echo "github.repository=${{ github.repository }}"
test:
name: "Run unit tests"
runs-on: ubuntu-latest
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pr_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ on:
branches:
- 'dev'

# Concurrency strategy:
# github.workflow: distinguish this workflow from others
# github.event_name: distinguish `push` event from `pull_request` event
# github.ref_name: distinguish branch
# github.repository: distinguish owner+repository
#
# Reference:
# https://docs.github.com/en/actions/using-jobs/using-concurrency
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{github.ref_name}}-${{github.repository}}
cancel-in-progress: true

jobs:
changelog_changes:
name: "Checking that changelog has changed"
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pr_gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ on:
- 'gradle.properties'
merge_group:

# Concurrency strategy:
# github.workflow: distinguish this workflow from others
# github.event_name: distinguish `push` event from `pull_request` event
# github.ref_name: distinguish branch
# github.repository: distinguish owner+repository
#
# Reference:
# https://docs.github.com/en/actions/using-jobs/using-concurrency
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{github.ref_name}}-${{github.repository}}
cancel-in-progress: true

jobs:
release_build:
name: "Build release"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [Feature] Check app exist on apps catalog manifest loading
- [Feature] First version of device orchestrator
- [Feature] Add sample for flipper reconnecting
- [Feature] Cancel previous pipelines on Github CI after push new commits to PR
- [Refactor] Use https://github.com/IlyaGulya/anvil-utils to automatically generate and contribute assisted factories.
- [Refactor] Add test for Progress Tracker logic

Expand Down

0 comments on commit a8cb40c

Please sign in to comment.