|
| 1 | +name: "ChangeLog Check" |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [master] |
| 6 | + |
| 7 | +jobs: |
| 8 | + changelog: |
| 9 | + name: Verify ChangeLog updated |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout repository |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + |
| 17 | + - name: Check for ChangeLog update |
| 18 | + run: | |
| 19 | + # Get list of changed files |
| 20 | + changed_files=$(git diff --name-only origin/master...HEAD) |
| 21 | +
|
| 22 | + if [ -z "$changed_files" ]; then |
| 23 | + echo "No files changed." |
| 24 | + exit 0 |
| 25 | + fi |
| 26 | +
|
| 27 | + # Check if only exempt files were changed |
| 28 | + # Exempt: .github/*, CLAUDE.md, README*, CONTRIBUTING*, CODE_OF_CONDUCT*, |
| 29 | + # .gitignore, CPPLINT.cfg, *.md in root |
| 30 | + has_non_exempt=false |
| 31 | + changelog_modified=false |
| 32 | +
|
| 33 | + while IFS= read -r file; do |
| 34 | + # Check if ChangeLog itself was modified |
| 35 | + if [ "$file" = "ChangeLog" ]; then |
| 36 | + changelog_modified=true |
| 37 | + continue |
| 38 | + fi |
| 39 | +
|
| 40 | + # Check exempt patterns |
| 41 | + case "$file" in |
| 42 | + .github/*) continue ;; |
| 43 | + CLAUDE.md) continue ;; |
| 44 | + README*) continue ;; |
| 45 | + CONTRIBUTING*) continue ;; |
| 46 | + CODE_OF_CONDUCT*) continue ;; |
| 47 | + .gitignore) continue ;; |
| 48 | + CPPLINT.cfg) continue ;; |
| 49 | + esac |
| 50 | +
|
| 51 | + # Check for *.md files in repo root (no slashes in path) |
| 52 | + if echo "$file" | grep -qE '^[^/]+\.md$'; then |
| 53 | + continue |
| 54 | + fi |
| 55 | +
|
| 56 | + has_non_exempt=true |
| 57 | + done <<< "$changed_files" |
| 58 | +
|
| 59 | + if [ "$has_non_exempt" = "false" ]; then |
| 60 | + echo "Only exempt files changed — ChangeLog update not required." |
| 61 | + exit 0 |
| 62 | + fi |
| 63 | +
|
| 64 | + if [ "$changelog_modified" = "false" ]; then |
| 65 | + echo "::error::ChangeLog was not updated. All pull requests with code changes must include a ChangeLog entry." |
| 66 | + echo "" |
| 67 | + echo "Please add a tab-indented entry under the first 'Version X.Y.Z' header in ChangeLog." |
| 68 | + echo "See CONTRIBUTING.md for format details." |
| 69 | + echo "" |
| 70 | + echo "If this PR only changes documentation or CI files, add the [skip changelog] label or ensure" |
| 71 | + echo "only exempt paths are modified (.github/*, *.md in root, .gitignore, CPPLINT.cfg)." |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | +
|
| 75 | + echo "ChangeLog was modified — checking format." |
| 76 | +
|
| 77 | + # Validate first line matches Version header format |
| 78 | + first_line=$(head -n 1 ChangeLog) |
| 79 | + if ! echo "$first_line" | grep -qE '^Version [0-9]+\.[0-9]+\.[0-9]+'; then |
| 80 | + echo "::error::First line of ChangeLog must match 'Version X.Y.Z' format (got: '$first_line')." |
| 81 | + exit 1 |
| 82 | + fi |
| 83 | +
|
| 84 | + echo "ChangeLog format looks good." |
0 commit comments