Skip to content

feat: make CI workflows run on the exact PR branch#114

Closed
davidbtadokoro wants to merge 1 commit intokworkflow:unstablefrom
davidbtadokoro:feat/make-workflows-run-on-pr-branch
Closed

feat: make CI workflows run on the exact PR branch#114
davidbtadokoro wants to merge 1 commit intokworkflow:unstablefrom
davidbtadokoro:feat/make-workflows-run-on-pr-branch

Conversation

@davidbtadokoro
Copy link
Collaborator

The project's CI relies heavily on the checkout action from GitHub Actions that, essentially, deals with checking out to the correct commit on which to run the workflow. By default, PRs check out to the temporary merge commit resulting from the PR branch HEAD and the target branch HEAD (unstable here in patch-hub). This logic is sound to "assure" that the workflows run on a version of the PR that considers the latest state of the branch it intends to merge.

However, it can cause strange side effects, such as when GitHub can successfully merge, but the PR branch conflicts in other ways. In this example 1, the PR #100 changed the function install_hooks() to expect an argument, but in unstable, there was a commit that introduced a test that used install_hooks() without arguments. The merge was done seamlessly, but it generated a compilation error.

In this sense, change the workflows to check out to PR branch HEAD commit instead of merge commit 3 to avoid us guessing what happened when debugging failing workflows. This has the upside down of "wasting" CI on "stale" PR branches, but demanding updated branches is a maintainer's job (besides being a good practice from contributors).

The project's CI relies heavily on the `checkout` action from GitHub
Actions that, essentially, deals with checking out to the correct commit
on which to run the workflow. By default, PRs check out to the temporary
merge commit resulting from the PR branch HEAD and the target branch
HEAD (`unstable` here in `patch-hub`). This logic is sound to "assure"
that the workflows run on a version of the PR that considers the latest
state of the branch it intends to merge.

However, it can cause strange side effects, such as when GitHub can
successfully merge, but the PR branch conflicts in other ways. In this
example [1][2], the PR kworkflow#100 changed the function `install_hooks()` to
expect an argument, but in `unstable`, there was a commit that
introduced a test that used `install_hooks()` without arguments. The
merge was done seamlessly, but it generated a compilation error.

In this sense, change the workflows to check out to PR branch HEAD
commit instead of merge commit [3] to avoid us guessing what happened
when debugging failing workflows. This has the upside down of "wasting"
CI on "stale" PR branches, but demanding updated branches is
a maintainer's job (besides being a good practice from contributors).

[1]: https://github.com/kworkflow/patch-hub/actions/runs/13722146202/job/38391557671
[2]: https://github.com/kworkflow/patch-hub/actions/runs/13722146239/job/38379854217
[3]: https://github.com/actions/checkout/blob/main/README.md#Checkout-pull-request-HEAD-commit-instead-of-merge-commit

Signed-off-by: David Tadokoro <davidbtadokoro@usp.br>
@davidbtadokoro
Copy link
Collaborator Author

davidbtadokoro commented Mar 7, 2025

@OJarrisonn, this PR addresses the problem we talked about offline, where the CI job was failing due to unexistent code. I've run multiple tests, and I am confident that this solves the issue, i.e., PR workflows will be run using the exact PR branch whilst not messing with direct pushes to target branches.

Could you please review this PR (and leave your Reviewed-by in case you agree)?

@nahharris
Copy link
Contributor

Sorry for the wait

On my end it seems to be alright, but I don't know much about github CI

I agree with the changes, how do i leave my Reviewed-By?

@davidbtadokoro
Copy link
Collaborator Author

Sorry for the wait

No worries! You didn't made me wait 😸

On my end it seems to be alright, but I don't know much about github CI

No problems. I did some heavy testing and study of this to make sure I wasn't mistaken. I wanted your input as I value your perception, so if you think nothing stands out, I am pleased.

I agree with the changes, how do i leave my Reviewed-By?

Usually you write it in the response (here in GitHub, as a comment) with a line like

Reviewed-by: David Tadokoro davidbtadokoro@usp.br

if you consider that the change is good to go (or with minimal adjustments). As I can fetch your Reviewed-by sign, no need to put it here.

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