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

Cancel previous workflow runs on newer refs #2027

Closed
aaemnnosttv opened this issue Sep 15, 2020 · 5 comments
Closed

Cancel previous workflow runs on newer refs #2027

aaemnnosttv opened this issue Sep 15, 2020 · 5 comments
Labels
P1 Medium priority QA: Eng Requires specialized QA by an engineer Type: Enhancement Improvement of an existing feature
Milestone

Comments

@aaemnnosttv
Copy link
Collaborator

aaemnnosttv commented Sep 15, 2020

Feature Description

Our GitHub Action workflows currently run until completed or fail for every commit they are triggered by.

In most cases however, it is usually undesirable for a workflow to continue running once another workflow for the same branch has started. In some cases, this can even cause a race condition where git-based deploy jobs fail due to upstream changes cause a push to fail. This can result in deployed assets not reflecting the latest state for their respective PR/branch or cause deployed artifacts to be left in the target repo longer than they should be due to a similar conflict in the prune/remove workflow job.

Travis has similar functionality available to automatically cancel builds for a branch/PR when a newer commit is pushed as it essentially "invalidates" the previous run. There's little benefit in letting the jobs finish as we have a limited number of concurrent jobs that can run. This is only manageable via the settings for the repository for Travis, but we should enable these as well:
image

For GitHub Actions, we can leverage the cancel-workflow-action to get similar behavior for our actions. (It's not quite as good as Travis' as it requires the job to run which in turn requires availability in the queue)

This (in combination with the settings above for Travis and the recently added fast_finish configuration) will help us to run our builds as efficiently as possible within our limits for maximum concurrent jobs/builds.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • GitHub Action workflows for queued/pending, or in progress runs should be automatically cancelled when a newer commit is pushed to the same branch

Implementation Brief

QA Brief

  • Review the Actions log for the repository
  • Check workflows for VRT, Plugin Zips, and Storybook to verify cancelled workflows are present (shown by the gray octagon with ❕ inside) - e.g.
    image

Changelog entry

  • N/A
@aaemnnosttv aaemnnosttv added P1 Medium priority Type: Enhancement Improvement of an existing feature QA: Eng Requires specialized QA by an engineer Next Up labels Sep 15, 2020
@aaemnnosttv aaemnnosttv self-assigned this Sep 15, 2020
@felixarntz
Copy link
Member

IB ✅

@felixarntz
Copy link
Member

@aaemnnosttv Not high priority to finish within this sprint, but since you already implemented it, and if this is good to go, we can just add Sprint 36 to it.

@aaemnnosttv
Copy link
Collaborator Author

aaemnnosttv commented Nov 11, 2020

👍 – there's one caveat to this which I read about when looking into this before which is that since the cancellation is triggered by your own workflow it won't work until that job runs; it sounds more obvious that it might seem if you're coming from another CI provider. Travis cancels all older job runs automatically, whereas this would potentially wait in the queue of other jobs (depending on our max concurrent job limit) before it could run and trigger others to be cancelled. It's not ideal, but better than nothing given the current options available with GHA.

Edit: apparently there is a decent workaround with the advanced usage if you know the workflow IDs, which we do 👍

@aaemnnosttv aaemnnosttv added this to the Sprint 36 milestone Nov 13, 2020
@aaemnnosttv
Copy link
Collaborator Author

@felixarntz I tweaked the ACs here to be more accurate to the desired outcome and less specific to the implementation which is slightly different now. Should be ready for review now 👍

@felixarntz felixarntz removed their assignment Nov 13, 2020
@eclarke1 eclarke1 removed the Next Up label Nov 17, 2020
@asvinb asvinb self-assigned this Nov 18, 2020
@asvinb
Copy link
Collaborator

asvinb commented Nov 18, 2020

VRT Test:
image
Cancelled workflow present ✔️

Plugin Zip:
image
Cancelled workflow present ✔️

Storybook:
image
Cancelled workflow present ✔️

QA: ✅

@asvinb asvinb removed their assignment Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 Medium priority QA: Eng Requires specialized QA by an engineer Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants