forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MM-52712: Prevent CI cancellation in master (round 2) (mattermost#23293)
We discovered that cancel-in-progress only controls in-progress jobs. Which means that pending jobs will _always_ be cancelled regardless. There is an open discussion: https://github.com/orgs/community/discussions/5435 which was closed saying this is how the feature is designed. We try to work around this by refactoring into separate reusable workflows and having concurrency only for PR workflows. ```release-note NONE ``` Co-authored-by: Mattermost Build <[email protected]>
- Loading branch information
1 parent
11b08ed
commit 77a24f9
Showing
12 changed files
with
114 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
### Background | ||
|
||
This document aims to explain the bunch of server and webapp yaml files and their functionality. | ||
|
||
The context behind this complexity is that we want new pushes to PR branches to cancel older in-progress and pending CI runs, _but_ we don't want that to happen in master branch. Unfortunately, there is no config knob to control pending workflows and if you set a concurrency group, then pending workflows will _always_ be canceled. Refer to https://github.com/orgs/community/discussions/5435 for discussion. | ||
|
||
Therefore, we have a template yaml file which is actually the main CI code. That is then imported by `{server|webapp}-ci-master.yml` and `{server|webapp}-ci-pr.yml`. The `-master.yml` files don't have any concurrency limits, but `-pr.yml` files do. | ||
|
||
### Folder structure | ||
|
||
server-ci-pr | ||
| | ||
---server-ci-template | ||
| | ||
---server-test-template (common code for postgres and mysql tests) | ||
|
||
server-ci-master | ||
| | ||
---server-ci-template | ||
| | ||
---server-test-template (common code for postgres and mysql tests) | ||
|
||
webapp-ci-pr | ||
| | ||
---webapp-ci-template | ||
|
||
webapp-ci-master | ||
| | ||
---webapp-ci-template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Server CI Master | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- cloud | ||
- release-* | ||
- mono-repo* | ||
env: | ||
go-version: "1.19.5" | ||
|
||
jobs: | ||
master-ci: | ||
uses: ./.github/workflows/server-ci-template.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Server CI PR | ||
on: | ||
pull_request: | ||
|
||
env: | ||
go-version: "1.19.5" | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
# This file just imports the template yml | ||
# and runs it with concurrency. We have to do this in this way | ||
# because the concurrency label cannot be added conditionally | ||
# and it _always_ cancels pending workflows. So master CI builds | ||
# always kept getting canceled. | ||
|
||
jobs: | ||
pr-ci: | ||
uses: ./.github/workflows/server-ci-template.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Web App CI Master | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- cloud | ||
- release-* | ||
- mono-repo* | ||
|
||
jobs: | ||
master-ci: | ||
uses: ./.github/workflows/webapp-ci-template.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Web App CI PR | ||
on: | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
# This file just imports the template yml | ||
# and runs it with concurrency. We have to do this in this way | ||
# because the concurrency label cannot be added conditionally | ||
# and it _always_ cancels pending workflows. So master CI builds | ||
# always kept getting canceled. | ||
|
||
jobs: | ||
pr-ci: | ||
uses: ./.github/workflows/webapp-ci-template.yml |
15 changes: 6 additions & 9 deletions
15
.github/workflows/webapp-ci.yml → .github/workflows/webapp-ci-template.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters