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 - Stop triggering two CI events when PR commits are pushed #110

Merged
merged 7 commits into from
Jul 26, 2024

Conversation

bfops
Copy link
Collaborator

@bfops bfops commented Jul 23, 2024

Description of Changes

Currently, a push to a PR triggers our dotnet workflows twice: once for the push event, and once for the pull_request event.

This PR sets the pull_request events to only be opened and reopened, so that a push to the branch only triggers the push event and not the PR synchronize event as well.

Testing

  • CI has only triggered once on this PR

Zeke Foppa added 2 commits July 23, 2024 09:35
pull_request:
push:
branches:
- master
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

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?

Copy link
Collaborator Author

@bfops bfops Jul 26, 2024

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

@bfops bfops requested a review from RReverser July 23, 2024 16:41
@bfops bfops marked this pull request as ready for review July 23, 2024 16:41
@bfops bfops changed the title CI - push events only trigger on master CI - push events only trigger on pushes to master Jul 23, 2024
@bfops bfops enabled auto-merge (squash) July 23, 2024 16:42
@bfops bfops changed the title CI - push events only trigger on pushes to master CI - pull_request events don't also trigger on push Jul 26, 2024
Copy link
Member

@RReverser RReverser left a 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]
Copy link
Collaborator Author

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 pushes.

See also https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request

Copy link
Member

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 all pushes.

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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.

Copy link
Member

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.

@bfops
Copy link
Collaborator Author

bfops commented Jul 26, 2024

I don't fully understand the change in behaviour after this PR, but sounds good.

@RReverser Added a hopefully-clarifying comment here: https://github.com/clockworklabs/spacetimedb-csharp-sdk/pull/110/files#r1693270679

@bfops bfops merged commit 2d27d1e into master Jul 26, 2024
1 check passed
@bfops bfops deleted the bfops/ci-triggers branch July 26, 2024 15:40
@bfops bfops changed the title CI - pull_request events don't also trigger on push CI - Stop triggering two CI events when PR commits are pushed Jul 26, 2024
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.

2 participants