-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ci: only run tests once on push to pr #1242
Conversation
I feel that there are 2 ways to do this, and which we pick should probably be driven by our development style and preferences. Option 1 👎🏻 (not taken)
Option 2 👍🏻 (taken)
|
Can you please describe the differences between the two options in non-YAML language? :-) |
Option 1Runs GHA on push to the feature branch. The code tested is the exact contents of the branch. Downside: if the feature branch is out of date wrt. main, passing tests don't actually mean that Downside is probably minor, because we don't allow [mere mortals] to merge PR that's out of sync. Option 2Runs GHA on PR being updated. The code tested is what would be in Downside: CI is not ran on feature branches until the PR is opened. May be hard on developers, if we routinely rely on CI as opposed to local/unit tests. |
There's also a caveat wrt. external collaborators. GHA are not run / should not be run for "unknown" PRs, that is if someone opens a PR and adds The standard solution for this is for someone on the team to close and reopen the PR, as reopen even is then processed in the context of the privileged user. I'm not addressing this concern though. |
Thanks for the summaries. I vote for option 2, but also that we disable the GitHub thing that requires the branch to be up to date. I've never felt this gains us much (especially if we're running tests on a temporary merge-to-main branch), and it's a bit of a pain. Go ahead and cast your votes, and then we can discuss and try to come to consensus in Tuesday's daily sync. |
Option 2 sounds best to me as well - I don't think there's any need to run CI against branches before there's a PR (I never look at any - it's simple to run the framework ones locally, and if it seems likely that the charm ones might fail I'll run tests against many more charms first - opening a draft PR also solves this). I think this is the intention of the CI: what would happen when this branch is merged (not "what would happen if I force-pushed this branch to main"). +1 to removing the requirement to have the branch up-to-date before merging. It seems like even GitHub is moving away from this (in favour of merge queues, which seem like overkill for us). |
@IronCore864 cast your vote, please 🙇🏻 |
My preference:
If we don't trigger tests on every commit that is not to the main branch, we need a trigger phrase like "test it" so that users can decide to trigger another test in the PR after a few commits. |
Ok, looks like Option 2 got most votes. wrt. restricting PR target to run tests in addition to the above, I'm not sure yet, and that can be a separate change. So I'll leave that out for now. |
d152dd1
to
2f6da71
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.
Thanks for this. @dimaqq Please also update the PR description to match what's actually going in before merging.
I've noticed that when a new commit is pushed to a PR, the same tests are run twice: once triggered by `on: push` and another by `on: pull_request: synchronize` --- Note that the two runs are not exactly same, if the target (main) branch has received updates in the meantime, because: ### on: push Trigger: This workflow runs the tests on the new commit in the feature branch as it stands alone. It doesn't consider any changes that might have been merged into the main branch since the feature branch was last updated. ### on: pull_request: synchronize Trigger: This workflow runs the tests on the combined state of the feature branch and the main branch. It effectively simulates a merge between the feature branch and the main branch to see if the combined state would pass the tests. --- to do - [x] agree on approach - [x] apply to other workflows
I've noticed that when a new commit is pushed to a PR, the same tests are run twice: once triggered by
on: push
and another byon: pull_request: synchronize
Note that the two runs are not exactly same, if the target (main) branch has received updates in the meantime, because:
on: push Trigger:
This workflow runs the tests on the new commit in the feature branch as it stands alone.
It doesn't consider any changes that might have been merged into the main branch since the feature branch was last updated.
on: pull_request: synchronize Trigger:
This workflow runs the tests on the combined state of the feature branch and the main branch.
It effectively simulates a merge between the feature branch and the main branch to see if the combined state would pass the tests.
to do