From c8f22d48c4c3827ffa547246ff20ea5741ed9a58 Mon Sep 17 00:00:00 2001 From: Phi Date: Tue, 16 Sep 2025 08:14:08 +0200 Subject: [PATCH 1/3] feat: GHA workflow to enforce changelog updates feat: GHA workflow to enforce changelog updates --- .github/workflows/changelog.yml | 90 +++++++++++++++++++++++++++++++++ README.md | 5 +- 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/changelog.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..6e8cf5c --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,90 @@ +name: Changelog Check + +on: + pull_request: + branches: + - main + - master + types: [opened, synchronize, reopened, edited, labeled, unlabeled] + +jobs: + check-changelog: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check if changelog should be skipped + id: skip_check + run: | + # Check for skip/changelog label + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'skip/changelog') }}" == "true" ]]; then + echo "skip=true" >> $GITHUB_OUTPUT + echo "Changelog check skipped due to 'skip/changelog' label" + exit 0 + fi + + # Check for skip indicators in PR title + PR_TITLE="${{ github.event.pull_request.title }}" + if echo "$PR_TITLE" | grep -iqE '\[(skip|no).?changelog\]'; then + echo "skip=true" >> $GITHUB_OUTPUT + echo "Changelog check skipped due to skip indicator in PR title: $PR_TITLE" + exit 0 + fi + + # Check for skip indicators in PR description + PR_BODY="${{ github.event.pull_request.body }}" + if echo "$PR_BODY" | grep -iqE '\[(skip|no).?changelog\]'; then + echo "skip=true" >> $GITHUB_OUTPUT + echo "Changelog check skipped due to skip indicator in PR description" + exit 0 + fi + + echo "skip=false" >> $GITHUB_OUTPUT + echo "Changelog check required" + + - name: Check for CHANGELOG.md changes + if: steps.skip_check.outputs.skip != 'true' + id: changelog_check + run: | + # Get the list of changed files in this PR + CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) + + echo "Changed files in this PR:" + echo "$CHANGED_FILES" + + # Check if CHANGELOG.md is in the list of changed files + if echo "$CHANGED_FILES" | grep -q "^CHANGELOG.md$"; then + echo "✅ CHANGELOG.md has been updated" + echo "changelog_updated=true" >> $GITHUB_OUTPUT + else + echo "❌ CHANGELOG.md has not been updated" + echo "changelog_updated=false" >> $GITHUB_OUTPUT + fi + + - name: Fail if changelog not updated + if: steps.skip_check.outputs.skip != 'true' && steps.changelog_check.outputs.changelog_updated != 'true' + run: | + echo "::error title=Changelog Required::CHANGELOG.md must be updated for this pull request. Please add an entry describing your changes under the [Unreleased] section." + echo "" + echo "If this PR doesn't require a changelog entry (e.g., documentation-only changes, CI changes), you can skip this check by:" + echo "• Adding the 'skip/changelog' label to this PR, OR" + echo "• Including '[skip changelog]' or '[no changelog]' in the PR title or description" + echo "" + echo "Examples:" + echo " Title: 'Fix typo in README [skip changelog]'" + echo " Description: 'This is a minor documentation fix [no changelog]'" + echo "" + echo "For more information about our changelog format, see: https://keepachangelog.com/en/1.0.0/" + exit 1 + + - name: Success message + if: steps.skip_check.outputs.skip == 'true' || steps.changelog_check.outputs.changelog_updated == 'true' + run: | + if [[ "${{ steps.skip_check.outputs.skip }}" == "true" ]]; then + echo "✅ Changelog check skipped (via label or PR title/description)" + else + echo "✅ Changelog check passed - CHANGELOG.md has been updated" + fi diff --git a/README.md b/README.md index de391be..622c862 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,12 @@ Follow the existing code style and patterns. Write clear, descriptive commit mes ### Pull Requests Use descriptive PR titles that summarize the change. Include a clear description of the changes and their purpose, reference any related issues, and ensure all tests pass and code is properly linted. +### Changelog +All notable changes must be documented in [CHANGELOG.md](CHANGELOG.md). Add your changes under the `[Unreleased]` section. If your PR doesn't require a changelog entry, you can skip this by adding the `skip/changelog` label or including `[skip changelog]` in your PR title or description. + ### Getting Help If you need assistance, feel free to open a issue or reach out to the maintainers of the contract in the #fil-pdp channel on [Filecoin Slack](https://filecoin.io/slack). ## License -Dual-licensed under [MIT](https://github.com/filecoin-project/lotus/blob/master/LICENSE-MIT) + [Apache 2.0](https://github.com/filecoin-project/lotus/blob/master/LICENSE-APACHE) +Dual-licensed under [MIT](https://github.com/FilOzone/pdp/blob/main/LICENSE.md) + [Apache 2.0](https://github.com/FilOzone/pdp/blob/main/LICENSE.md) From e18b1e03534ecda777eed5753e919eaa29fe200a Mon Sep 17 00:00:00 2001 From: Phi-rjan Date: Tue, 16 Sep 2025 08:24:11 +0200 Subject: [PATCH 2/3] Update .github/workflows/changelog.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/changelog.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 6e8cf5c..fecd21e 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -49,6 +49,8 @@ jobs: if: steps.skip_check.outputs.skip != 'true' id: changelog_check run: | + # Ensure the base branch exists locally + git fetch origin ${{ github.base_ref }} # Get the list of changed files in this PR CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) From 7e9b63c2fad0f6cb15d10163c4de2fe46649265f Mon Sep 17 00:00:00 2001 From: Phi Date: Tue, 16 Sep 2025 08:27:01 +0200 Subject: [PATCH 3/3] fix: update regex pattern to avoid false positives fix: update regex pattern to avoid false positives --- .github/workflows/changelog.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 6e8cf5c..3182b19 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -28,7 +28,7 @@ jobs: # Check for skip indicators in PR title PR_TITLE="${{ github.event.pull_request.title }}" - if echo "$PR_TITLE" | grep -iqE '\[(skip|no).?changelog\]'; then + if echo "$PR_TITLE" | grep -iqE '\[(skip|no)\s?changelog\]'; then echo "skip=true" >> $GITHUB_OUTPUT echo "Changelog check skipped due to skip indicator in PR title: $PR_TITLE" exit 0 @@ -36,7 +36,7 @@ jobs: # Check for skip indicators in PR description PR_BODY="${{ github.event.pull_request.body }}" - if echo "$PR_BODY" | grep -iqE '\[(skip|no).?changelog\]'; then + if echo "$PR_BODY" | grep -iqE '\[(skip|no)\s?changelog\]'; then echo "skip=true" >> $GITHUB_OUTPUT echo "Changelog check skipped due to skip indicator in PR description" exit 0