Skip to content

Commit 7666376

Browse files
committed
CI: check the presence of the changelog line in each pull request
Checking it only in the merge queue leads to deferred failures once the decision to merge has been taken already.
1 parent 197d58d commit 7666376

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/clippy_pr.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,37 @@ concurrency:
1717
cancel-in-progress: true
1818

1919
jobs:
20+
changelog:
21+
runs-on: ubuntu-latest
22+
23+
defaults:
24+
run:
25+
shell: bash
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
# Unsetting this would make so that any malicious package could get our Github Token
32+
persist-credentials: false
33+
34+
# Run
35+
- name: Check Changelog
36+
run: |
37+
body=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR_NUMBER" | \
38+
python -c "import sys, json; print(json.load(sys.stdin)['body'])")
39+
output=$(grep "^changelog:\s*\S" <<< "$body" | sed "s/changelog:\s*//g") || {
40+
echo "ERROR: pull request message must contain 'changelog: ...'. Add it " \
41+
"and push (or force-push) the pull request to trigger a new check."
42+
exit 1
43+
}
44+
echo "changelog: $output"
45+
env:
46+
PYTHONIOENCODING: 'utf-8'
47+
PR_NUMBER: '${{ github.event.number }}'
2048
base:
2149
# NOTE: If you modify this job, make sure you copy the changes to clippy_mq.yml
50+
needs: changelog
2251
runs-on: ubuntu-latest
2352

2453
steps:

0 commit comments

Comments
 (0)