Skip to content

Commit

Permalink
workflows: fix concurrency group names
Browse files Browse the repository at this point in the history
Improve concurrency group names uniqueness, in particular for allowing
testing workflow changes via `pull_request` events.

In the previous version, all `pull_request`-triggered runs would end up
in the same concurrency group as the `scheduled` events, due to not
having a `github.event.issue` object.

This new version proposes a new structure that should be unique for all
types of testing, while still allowing runs of the same type to override
each other:

Structure:
- Workflow name
- Event type
- A unique identifier depending on event type:
  - schedule: SHA
  - issue_comment: PR number + trigger phrase
  - pull_request: PR number + label name

Signed-off-by: Nicolas Busseneau <nicolas@isovalent.com>
  • Loading branch information
nbusseneau committed Jun 30, 2021
1 parent a12f4e4 commit f73977d
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 30 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/conformance-aks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@ on:
###

concurrency:
# In case of PR comment, we can't simply append the comment to the group name
# as that is too long and results in an error. Instead we check if it's a
# trigger phrase and append a simple 'trigger-phrase'.
# Structure:
# - Workflow name
# - Event type
# - A unique identifier depending on event type:
# - schedule: SHA
# - issue_comment: PR number + trigger phrase
# - pull_request: PR number + label name
#
# This structure ensures a unique concurrency group name is generated for each type of testing:
# - schedule: {name} schedule {SHA}
# - issue_comment: {name} issue_comment {PR number} {trigger phrase}
# - pull_request: {name} pull_request {PR number} {label name}
group: |
"${{ github.workflow }} ${{ github.event.issue.pull_request.url || 'scheduled' }}
${{ (startsWith(github.event.comment.body, 'ci-aks') ||
startsWith(github.event.comment.body, 'test-me-please')) && 'trigger-phrase' }}"
${{ github.workflow }}
${{ github.event_name }}
${{ github.event.issue.number || github.event.pull_request.number || github.sha }}
${{ github.event_name == 'issue_comment' && (
startsWith(github.event.comment.body, 'ci-aks') ||
startsWith(github.event.comment.body, 'test-me-please')
) && 'ci-aks' }}
${{ github.event_name == 'pull_request'
&& github.event.label.name == 'ci-run/aks'
&& 'ci-run/aks' }}
cancel-in-progress: true

env:
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/conformance-aws-cni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@ on:
###

concurrency:
# In case of PR comment, we can't simply append the comment to the group name
# as that is too long and results in an error. Instead we check if it's a
# trigger phrase and append a simple 'trigger-phrase'.
# Structure:
# - Workflow name
# - Event type
# - A unique identifier depending on event type:
# - schedule: SHA
# - issue_comment: PR number + trigger phrase
# - pull_request: PR number + label name
#
# This structure ensures a unique concurrency group name is generated for each type of testing:
# - schedule: {name} schedule {SHA}
# - issue_comment: {name} issue_comment {PR number} {trigger phrase}
# - pull_request: {name} pull_request {PR number} {label name}
group: |
"${{ github.workflow }} ${{ github.event.issue.pull_request.url || 'scheduled' }}
${{ (startsWith(github.event.comment.body, 'ci-awscni') ||
startsWith(github.event.comment.body, 'test-me-please')) && 'trigger-phrase' }}"
${{ github.workflow }}
${{ github.event_name }}
${{ github.event.issue.number || github.event.pull_request.number || github.sha }}
${{ github.event_name == 'issue_comment' && (
startsWith(github.event.comment.body, 'ci-awscni') ||
startsWith(github.event.comment.body, 'test-me-please')
) && 'ci-awscni' }}
${{ github.event_name == 'pull_request'
&& github.event.label.name == 'ci-run/awscni'
&& 'ci-run/awscni' }}
cancel-in-progress: true

env:
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/conformance-eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@ on:
###

concurrency:
# In case of PR comment, we can't simply append the comment to the group name
# as that is too long and results in an error. Instead we check if it's a
# trigger phrase and append a simple 'trigger-phrase'.
# Structure:
# - Workflow name
# - Event type
# - A unique identifier depending on event type:
# - schedule: SHA
# - issue_comment: PR number + trigger phrase
# - pull_request: PR number + label name
#
# This structure ensures a unique concurrency group name is generated for each type of testing:
# - schedule: {name} schedule {SHA}
# - issue_comment: {name} issue_comment {PR number} {trigger phrase}
# - pull_request: {name} pull_request {PR number} {label name}
group: |
"${{ github.workflow }} ${{ github.event.issue.pull_request.url || 'scheduled' }}
${{ (startsWith(github.event.comment.body, 'ci-eks') ||
startsWith(github.event.comment.body, 'test-me-please')) && 'trigger-phrase' }}"
${{ github.workflow }}
${{ github.event_name }}
${{ github.event.issue.number || github.event.pull_request.number || github.sha }}
${{ github.event_name == 'issue_comment' && (
startsWith(github.event.comment.body, 'ci-eks') ||
startsWith(github.event.comment.body, 'test-me-please')
) && 'ci-eks' }}
${{ github.event_name == 'pull_request'
&& github.event.label.name == 'ci-run/eks'
&& 'ci-run/eks' }}
cancel-in-progress: true

env:
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/conformance-gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@ on:
###

concurrency:
# In case of PR comment, we can't simply append the comment to the group name
# as that is too long and results in an error. Instead we check if it's a
# trigger phrase and append a simple 'trigger-phrase'.
# Structure:
# - Workflow name
# - Event type
# - A unique identifier depending on event type:
# - schedule: SHA
# - issue_comment: PR number + trigger phrase
# - pull_request: PR number + label name
#
# This structure ensures a unique concurrency group name is generated for each type of testing:
# - schedule: {name} schedule {SHA}
# - issue_comment: {name} issue_comment {PR number} {trigger phrase}
# - pull_request: {name} pull_request {PR number} {label name}
group: |
"${{ github.workflow }} ${{ github.event.issue.pull_request.url || 'scheduled' }}
${{ (startsWith(github.event.comment.body, 'ci-gke') ||
startsWith(github.event.comment.body, 'test-me-please')) && 'trigger-phrase' }}"
${{ github.workflow }}
${{ github.event_name }}
${{ github.event.issue.number || github.event.pull_request.number || github.sha }}
${{ github.event_name == 'issue_comment' && (
startsWith(github.event.comment.body, 'ci-gke') ||
startsWith(github.event.comment.body, 'test-me-please')
) && 'ci-gke' }}
${{ github.event_name == 'pull_request'
&& github.event.label.name == 'ci-run/gke'
&& 'ci-run/gke' }}
cancel-in-progress: true

env:
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/conformance-multicluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@ on:
###

concurrency:
# In case of PR comment, we can't simply append the comment to the group name
# as that is too long and results in an error. Instead we check if it's a
# trigger phrase and append a simple 'trigger-phrase'.
# Structure:
# - Workflow name
# - Event type
# - A unique identifier depending on event type:
# - schedule: SHA
# - issue_comment: PR number + trigger phrase
# - pull_request: PR number + label name
#
# This structure ensures a unique concurrency group name is generated for each type of testing:
# - schedule: {name} schedule {SHA}
# - issue_comment: {name} issue_comment {PR number} {trigger phrase}
# - pull_request: {name} pull_request {PR number} {label name}
group: |
"${{ github.workflow }} ${{ github.event.issue.pull_request.url || 'scheduled' }}
${{ (startsWith(github.event.comment.body, 'ci-multicluster') ||
startsWith(github.event.comment.body, 'test-me-please')) && 'trigger-phrase' }}"
${{ github.workflow }}
${{ github.event_name }}
${{ github.event.issue.number || github.event.pull_request.number || github.sha }}
${{ github.event_name == 'issue_comment' && (
startsWith(github.event.comment.body, 'ci-multicluster') ||
startsWith(github.event.comment.body, 'test-me-please')
) && 'ci-multicluster' }}
${{ github.event_name == 'pull_request'
&& github.event.label.name == 'ci-run/multicluster'
&& 'ci-run/multicluster' }}
cancel-in-progress: true

env:
Expand Down

0 comments on commit f73977d

Please sign in to comment.