Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(workflows): cancel in progress workflows on new trigger #11370

Merged
merged 2 commits into from
Aug 24, 2022

Conversation

y3rsh
Copy link
Member

@y3rsh y3rsh commented Aug 19, 2022

Overview

Given I push, make a PR, or merge a PR
When a workflow "on" condition is matched
Then the workflow will queue to run
But already running workflows from the same trigger, that may now be redundant, continue running

I make a PR but immediately see a typo so I fix it and push. All the triggered workflows from my PR creation keep running but don't need to, I only want the workflows running against my new commit to run.

image

GitHub Workflow Concurrency Documentation

Review requests

Questions

  • Are there exceptions to this where we don't want to cancel previously running workflows?
    • On a merge to edge, if a subsequent merge to edge happens before the workflows to build finish, they will be cancelled. This results in states of the edge branch with no built assets. Do we want to make an exceptions for edge?
    • Scenarios with the release* branches where this may have side effects?
    • Side effects from re-running a workflow?
  • Other considerations?
  • Instead of doing this in all workflows, pick a couple to prove the concurrency group is restrictive enough?

Risk assessment

Medium, this needs 👀 as it is hard to map all the workflows and triggers conceptually to understand any side effects.

@y3rsh y3rsh requested a review from a team as a code owner August 19, 2022 14:07
@codecov
Copy link

codecov bot commented Aug 19, 2022

Codecov Report

Merging #11370 (6bfb16c) into edge (d45a2d4) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             edge   #11370   +/-   ##
=======================================
  Coverage   74.74%   74.74%           
=======================================
  Files        2046     2046           
  Lines       56966    56966           
  Branches     5545     5545           
=======================================
  Hits        42580    42580           
  Misses      13128    13128           
  Partials     1258     1258           
Flag Coverage Δ
app 75.28% <ø> (ø)
components 53.05% <ø> (ø)
g-code-testing 97.13% <ø> (ø)
hardware 59.95% <ø> (ø)
labware-library 49.74% <ø> (ø)
protocol-designer 45.81% <ø> (ø)
react-api-client 82.98% <ø> (ø)
shared-data 86.08% <ø> (ø)
step-generation 88.39% <ø> (ø)
update-server 73.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes for devs but we should definitely not apply them to tag builds and probably edge builds. i think we should apply them to release-branch builds because the "oh god i made a typo" thing is extremely common in, for instance, release-branch bump commits.

@y3rsh
Copy link
Member Author

y3rsh commented Aug 19, 2022

I like these changes for devs but we should definitely not apply them to tag builds and probably edge builds. i think we should apply them to release-branch builds because the "oh god i made a typo" thing is extremely common in, for instance, release-branch bump commits.

Makes sense. I have added expressions to detect when the branch name is edge and for any push of a tag. When these are detected, the github.run_id is added to the concurrency group string. The only time a github.run_id would stay the same between runs is on a re-run. If you somehow started 2 re-runs one after another (which doesn't seem possible) a cancellation on an edge or tag triggered workflow run might happen.

I proved the expressions out in this repo

@SyntaxColoring
Copy link
Contributor

I like these changes for devs but we should definitely not apply them to tag builds

Just curious: why don't we want to auto-cancel tag builds?

@y3rsh y3rsh requested a review from sfoster1 August 22, 2022 16:55
@sfoster1
Copy link
Member

I like these changes for devs but we should definitely not apply them to tag builds

Just curious: why don't we want to auto-cancel tag builds?

Everything about nonstandard or surprising aspects of release management should be manual, in my opinion. It's fine and a good idea to automate happy paths, but anything that gets weird really needs human oversight.

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@y3rsh y3rsh merged commit 8a03639 into edge Aug 24, 2022
@y3rsh y3rsh deleted the RQA-166-Add-concurrency-to-build-test-deploy branch August 24, 2022 15:44
y3rsh added a commit that referenced this pull request Sep 1, 2022
* use run_id to exclude edge branch and tags from concurrency group
y3rsh added a commit that referenced this pull request Sep 7, 2022
* use run_id to exclude edge branch and tags from concurrency group
y3rsh added a commit that referenced this pull request Sep 14, 2022
* use run_id to exclude edge branch and tags from concurrency group
y3rsh added a commit that referenced this pull request Oct 6, 2022
* use run_id to exclude edge branch and tags from concurrency group
y3rsh added a commit that referenced this pull request Oct 6, 2022
* use run_id to exclude edge branch and tags from concurrency group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants