Skip to content

ci: check newly-added CHANGELOGs in CI #2364

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

Merged
merged 7 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
42 changes: 42 additions & 0 deletions .github/actions/check_changelog/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Check CHANGELOG'
description: 'Check CHANGELOG kind and PR number'

runs:
using: "composite"
steps:
- name: Get newly added CHANGELOGs
id: new-changelogs
uses: tj-actions/changed-files@v44
with:
# Only checek the files under the `changelog` directory
files: changelog/**

- name: List added CHANGELOGs
Copy link
Member Author

Choose a reason for hiding this comment

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

Should be something like Check them

shell: bash
if: steps.new-changelogs.outputs.added_files_count != 0
env:
NEW_CHANGELOGS: ${{ steps.new-changelogs.outputs.added_files }}
PR_NUMBER: ${{ github.event.number }}
run: |
for cl in ${NEW_CHANGELOGS}; do
# parse it
IFS='.' read id kind file_extension <<< "${cl}"

# Check the kind field
if [ "$kind" != "added" ] && [ "$kind" != "changed" ] && [ "$kind" != "fixed" ] && [ "$kind" != "removed" ]; then
echo "Invalid CHANGELOG kind [${kind}] from [${cl}], available options are [added, changed, fixed, removed]";
exit 1;
fi

# Check the file extension
if [ "$file_extension" != "md" ]; then
echo "Invalid file extension [${file_extension}] from [${cl}], it should be [md]";
exit 1;
fi

# Check PR number
if [ "$id" != "$PR_NUMBER" ]; then
echo "Mismatched PR number [${id}] from [${cl}], it should be ${PR_NUMBER}";
exit 1;
fi
done
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ env:
MSRV: 1.69.0

jobs:
check_changelog:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v4

- name: check CHANGELOG
uses: ./.github/actions/check_changelog

macos:
runs-on: macos-13
Expand Down