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

Skip earlier when run on forks #11212

Merged

Conversation

jeffwidman
Copy link
Member

@jeffwidman jeffwidman commented Jan 3, 2025

What are you trying to accomplish?

I found the original code confusing because it always checks if the PR is approved, even when run on forks. Yet the job still bails if run on a fork, even if the PR is approved.

So I pulled the if conditional that bypasses forks up into the first job. This works because if the approval job gets skipped, then the subsequent job will also be skipped since it needs: approval (docs).

So this should hopefully be both more readable within the code, more readable in CI output on PR's, and also more performant. 🥂

Anything you want to highlight for special attention from reviewers?

Originally, I wasn't 100% sure this works... perhaps there was a reason why the fork-check conditional needed to be attached to the second job.

However, when I checked git blame I see that originally this was a single job, and then split in two:

And looking at the commit history on that PR, I think these two commits indicate the author was focused on simplifying two steps into one, so didn't consider the possibility of skipping earlier:

In order to test this, I've opened this PR from my personal fork, rather than the main Dependabot repo...

@jeffwidman jeffwidman requested a review from a team as a code owner January 3, 2025 06:04
Copy link
Member Author

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

Reviewing this PR in order to trigger a pull_request_review event to trigger the job... let's see what happens!

@jeffwidman
Copy link
Member Author

It worked! 🎉

Screenshot 2025-01-02 at 10 15 22 PM Screenshot 2025-01-02 at 10 16 36 PM

@jeffwidman jeffwidman force-pushed the skip-earlier-when-run-on-forks branch 2 times, most recently from 0462149 to 2668296 Compare January 3, 2025 06:33
@jeffwidman
Copy link
Member Author

Once this is merged, I'll need to double-check that when run against a fork via workflow_dispatch it runs the approval job, and then fails the second job because the PR isn't approved... I can't actually test that though until this is merged.

I found the original code confusing because it _always_ checks if the PR is approved, even when run on forks. Yet the job still bails if run on a fork, _even if the PR is approved_.

So I pulled the `if` conditional that bypasses forks up into the first job. If that results in skipping the `approval` job, then the subsequent job that `needs: approval` will also be skipped ([docs](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds)).

So this should hopefully be both more readable within the code, more readable on PR's, and also more performant. 🥂

Originally, I wasn't 100% sure this would work... perhaps there was a reason why the fork-check conditional needed to be attached to the second job.

However, when I checked `git blame` I see that originally this was a single job, and then split in two:
* dependabot#8651

And looking at the commit history on that PR, I think these two commits indicate the author was focused on simplifying two steps into one, so didn't consider the possibility of skipping earlier:
* dependabot@ede644b
* dependabot@c7069e6
@jeffwidman jeffwidman force-pushed the skip-earlier-when-run-on-forks branch from 2668296 to 201c600 Compare January 3, 2025 18:18
@jeffwidman
Copy link
Member Author

I discussed this with @landongrindheim and @pavera and this change seemed sensible to them as well, so 🚢

@jeffwidman jeffwidman merged commit 4d2f901 into dependabot:main Jan 3, 2025
36 checks passed
@jeffwidman jeffwidman deleted the skip-earlier-when-run-on-forks branch January 3, 2025 18:50
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.

3 participants