Skip to content

Commit f631eb1

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 f631eb1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/clippy_pr.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,41 @@ 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+
if [[ "$output" = "none" ]]; then
45+
echo "WARNING: changelog is 'none'"
46+
else
47+
echo "changelog: $output"
48+
fi
49+
env:
50+
PYTHONIOENCODING: 'utf-8'
51+
PR_NUMBER: '${{ github.event.number }}'
2052
base:
2153
# NOTE: If you modify this job, make sure you copy the changes to clippy_mq.yml
54+
needs: changelog
2255
runs-on: ubuntu-latest
2356

2457
steps:

0 commit comments

Comments
 (0)