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

Components: Update CHANGELOG CI check to support forked repos #49906

Merged
merged 1 commit into from
Apr 19, 2023

Conversation

chad1008
Copy link
Contributor

Fixes #49817

What?

Update the Components Package CHANGELOG check to support forked repos

Why?

Without this change the check will always fail because it doesn't know what upstream repo to checkout from

How?

Add a repo declaration!

Testing Instructions

  1. Fork Gutenberg
  2. Make a change to any file in the components package that isn't a unit test, storybook file, or mobile/native file. Don't modify the CHANGELOG
  3. Commit and push your changes
  4. Create a PR from the modified branch on your fork
  5. Confirm that the CI check runs, and fails because the CHANGELOG has not been updated.
  6. Confirm the error output does not reference an error while fetching the repository
  7. Update the CHANGELOG with an entry in the Unreleased section
  8. Commit and push
  9. Confirm the check runs and passes

@chad1008 chad1008 self-assigned this Apr 18, 2023
@chad1008 chad1008 requested review from mirka and t-hamano April 18, 2023 20:57
@chad1008 chad1008 added [Package] Components /packages/components GitHub Actions Pull requests that update GitHub Actions code labels Apr 18, 2023
@chad1008 chad1008 marked this pull request as ready for review April 18, 2023 20:57
@t-hamano
Copy link
Contributor

Thanks for the PR, @chad1008!

I would like to test this from the actual forked repository. Check out this PR (component-changelog-ci-forked-repos) in my forked repository, make changes, and submit the PR to trunk. Is this procedure correct?

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM!

I have confirmed that you have tested with #49905 and it is working as expected 👍

I have another concern. My understanding is that if there is a difference in the packages/components/CHANGELOG.md file between trunk and PR, the file is considered changed and passes the test:

if git diff --quiet ${{ github.event.pull_request.base.sha }} HEAD -- "$changelog_path"; then
echo "Please add a CHANGELOG entry to $changelog_path"
exit 1
fi

However, the trunk may be ahead of the PR and the changelog may be updated in the trunk.
In this case, I'm concerned that even if the PR doesn't contain the updated CHANGELOG, a difference will still occur and pass the test.

Perhaps it would be better to use an action such as changed-files and check if a particular file has been updated in the PR.

What do you think about this?

@chad1008
Copy link
Contributor Author

Thanks for reviewing @t-hamano!

trunk may be ahead of the PR and the changelog may be updated in the trunk.
In this case, I'm concerned that even if the PR doesn't contain the updated CHANGELOG, a difference will still occur and pass the test.

Great minds think alike... I noticed the exact same thing yesterday!

The short version of that comment is that the Github context we're using for the diff command is meant to look at the current branch's fork point, but for some reason it's returning the latest commit on the base branch... leading to the false positives you've described when trunk is ahead.

In that PR, I'm also introducing some new checks to make the feedback more specific/meaningful, and those new checks will still catch cases like this, so I think we're okay. The error message would be a little off ("make sure you've linked the right PR" instead of "add an entry") but it will accomplish the same goal of giving the author a heads-up that the CHANGELOG needs attention 😄

@chad1008 chad1008 merged commit 1b7da79 into trunk Apr 19, 2023
@chad1008 chad1008 deleted the component-changelog-ci-forked-repos branch April 19, 2023 17:05
@github-actions github-actions bot added this to the Gutenberg 15.7 milestone Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GitHub Actions Pull requests that update GitHub Actions code [Package] Components /packages/components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workflows: Component CHAGELOG update check fails on PR from forked repository
2 participants