-
Notifications
You must be signed in to change notification settings - Fork 0
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 - Stop triggering two CI events when PR commits are pushed #110
Conversation
.github/workflows/dotnet.yml
Outdated
pull_request: | ||
push: | ||
branches: | ||
- master |
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.
this matches the behavior in SpacetimeDB (https://github.com/clockworklabs/SpacetimeDB/blob/master/.github/workflows/ci.yml)
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 think SpacetimeDB has somewhat different constraints because it's so large / expensive to build, whereas this repo takes less than a minute.
I love being able to run CI on branches even before I make a PR. Could we preserve that?
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.
updated to run on push
events but not synchronize
events
push
events only trigger on master
push
events only trigger on pushes to master
push
events only trigger on pushes to master
pull_request
events don't also trigger on push
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 don't fully understand the change in behaviour after this PR, but sounds good.
on: | ||
push: | ||
pull_request: | ||
types: [opened, reopened] |
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.
The default (i.e. if types
isn't specified) is [opened, reopened, synchronized]
.
The synchronized
event happens whenever commits are pushed to a PR, which was redundant with us also triggering on all push
es.
See also https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
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.
The
synchronized
event happens whenever commits are pushed to a PR, which was redundant with us also triggering on allpush
es.
IIRC they do that intentionally because the commit on the branch itself might be different from a merge commit when PR is out of date (not rebased), so the test result might be different as well? Admittedly, it's an edge case, but sometimes it might potentially catch issues early.
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.
Good point.. but it seems like this repo requires PRs to be up to date with master before merging, so I think it might not apply here?
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.
actually.. based on https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=synchronize#pull_request, it looks like synchronize
is probably only triggered when the head branch is pushed.
I think there might be a different option/event type for testing the merge commits? IIRC they're pushed to some other ref that gets CI tested.
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.
Oh huh. I probably confused the event types. But yeah, either way the base branch requirement takes care of that.
@RReverser Added a hopefully-clarifying comment here: https://github.com/clockworklabs/spacetimedb-csharp-sdk/pull/110/files#r1693270679 |
pull_request
events don't also trigger on push
Description of Changes
Currently, a push to a PR triggers our
dotnet
workflows twice: once for thepush
event, and once for thepull_request
event.This PR sets the
pull_request
events to only beopened
andreopened
, so that a push to the branch only triggers thepush
event and not the PRsynchronize
event as well.Testing