-
Notifications
You must be signed in to change notification settings - Fork 37
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
Improve build and deployment concurrency handling #284
Improve build and deployment concurrency handling #284
Conversation
The commit history shows my tests to reduce the scope of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, an oversight. Thanks for looking into this.
Left some comments.
concurrency: | ||
group: pages | ||
cancel-in-progress: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you also consider removing this setting completely? What's the downside of deploying twice?
If I understand correctly, what's happening is:
- PR-1 merged => master is built & deployed
- PR-2 is merged => master is built & deployed
Where PR-2 is somehow faster and thus first PR-2 is deployed, after which PR-1 is deployed and thus leading to an outdated website. Additionally, the current setup is cancelling the build across multiple branches/PRs, which then requires one to manually re-run to fix the build.
Now, we're still grouping globally (group: pages
), and this works because the if
is on a single branch, but could still lead to issues across multiple branches I think.
Looking at the docs, an alternative would be moving this up again, but grouping differently. Arguably, if we merge the two PRs (from the above example), there's no need in building twice. Additionally, if you push 2 commits on a branch, we should be able to cancel them as - again - there's no use in building twice.
concurrency: | |
group: pages | |
cancel-in-progress: true | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, if you push 2 commits on a branch, we should be able to cancel them as - again - there's no use in building twice.
This part I agree with (and also crossed my mind).
Arguably, if we merge the two PRs (from the above example), there's no need in building twice.
Strictly speaking true, but IMHO it's a nice feature that each merged commit has a "complete" build status, and that if a merge breaks the build, that the preceding commit still has a "build passed" check mark. (That said, generally @rickie and I don't merge a second PR until the first passed, so in practice there's limited difference.) (And perhaps we should require that PRs are up-to-date with the base branch before merging, but that's yet another discussion.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with this change, as this is undesirable:
Additionally, the current setup is cancelling the build across multiple branches/PRs, which then requires one to manually re-run to fix the build.
Based on the linked docs, I'd say that this would be even safer (and be prepared on possible future usages of concurrency
as well): group: ${{ github.workflow }}-${{ github.ref }}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say that dropping cancel-in-progress
would be fine as well.
Did you also consider removing this setting completely?
However, I'd say that it is nice if you do multiple commits that pending
builds will get cancelled:
When a concurrent job or workflow is queued, if another job or workflow using the same concurrency group in the repository is in progress, the queued job or workflow will be pending. Any previously pending job or workflow in the concurrency group will be canceled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this was an old comment that I hadn't flushed yet, hence the funny ordering. Anyway, the question is whether we're okay with the PR as-is, or want to add cancel-in-progress: true
again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested some possible tweaks / asked some questions :).
d557ce8
to
5484f24
Compare
Rebased and resolved conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concurrency: | ||
group: pages | ||
cancel-in-progress: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, if you push 2 commits on a branch, we should be able to cancel them as - again - there's no use in building twice.
This part I agree with (and also crossed my mind).
Arguably, if we merge the two PRs (from the above example), there's no need in building twice.
Strictly speaking true, but IMHO it's a nice feature that each merged commit has a "complete" build status, and that if a merge breaks the build, that the preceding commit still has a "build passed" check mark. (That said, generally @rickie and I don't merge a second PR until the first passed, so in practice there's limited difference.) (And perhaps we should require that PRs are up-to-date with the base branch before merging, but that's yet another discussion.)
concurrency: | ||
group: pages | ||
cancel-in-progress: true | ||
group: ${{ github.workflow }}-${{ github.ref }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively we could do this, but as discussed it'd be nice not to cancel non-PR builds. I tried to specify cancel-in-progress: ${{ github.head_ref != null }}
, but that doesn't seem to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice discussions! This looks good to me!
it's a nice feature that each merged commit has a "complete" build status
Completely agree.
Rebased. Anything else from your side @japborst 😄? |
Building the website can happen concurrently, but deployment should not.
af8fa31
to
c2d4fcf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went through the comments. Makes sense 👍 Thanks!
Suggested commit message: