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: Improve output of CHANGELOG CI check #49779

Merged
merged 4 commits into from
Apr 19, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions .github/workflows/check-components-changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Verify @wordpress/components CHANGELOG update
name: OPTIONAL - Verify @wordpress/components CHANGELOG update

on:
pull_request:
Expand Down Expand Up @@ -26,10 +26,39 @@ jobs:
fetch-depth: ${{ env.PR_COMMIT_COUNT }}
- name: 'Fetch relevant history from origin'
run: git fetch origin ${{ github.event.pull_request.base.ref }}
- name: Run git diff
- name: Check CHANGELOG status
env:
PR_NUMBER: ${{ github.event.number }}
run: |
changelog_path="packages/components/CHANGELOG.md"
optional_check_notice="This isn't a required check, so if you think your changes are small enough that they don't warrant a CHANGELOG entry, please go ahead and merge without one."

# Fail if the PR doesn't touch the changelog
if git diff --quiet ${{ github.event.pull_request.base.sha }} HEAD -- "$changelog_path"; then
echo "Please add a CHANGELOG entry to $changelog_path"
echo
echo "${optional_check_notice}"
exit 1
fi

pr_link_pattern="\(\[#${PR_NUMBER}\]\(https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER}\)\)"
pr_link_grep_pattern="(\[#${PR_NUMBER}\](https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER}))"

unreleased_section=$(sed -n '/^## Unreleased$/,/^## /p' "${changelog_path}")

# Confirm that the CHANGELOG has an entry for the current PR
if ! grep -nq -e "${pr_link_grep_pattern}" "${changelog_path}"; then
echo "Please make sure your CHANGELOG entry has a link to the current PR."
chad1008 marked this conversation as resolved.
Show resolved Hide resolved
echo
echo "${optional_check_notice}"
exit 1
fi

# Confirm that there is an 'Unreleased' section and that the relevant entry is in that section
if ! grep -nq -e '^## Unreleased' "${changelog_path}" || \
! [[ $unreleased_section = *${pr_link_pattern}* ]]; then
echo "Please make sure your CHANGELOG entry is in the \`## Unreleased\` section"
echo
echo "${optional_check_notice}"
exit 1
fi