Skip to content

Commit b82196f

Browse files
committed
github actions: Add upstream commit checker
This github actions checks the PR commits for references to upstream linux commits (lines starting with "commit <hash>") and does two things: 1. Checks that this hash exists in the upstream linux kernel history 2. Checks if there are any Fixes: references for the referenced commit in the upstream linux kernel history If either of those are found to be true a comment is added to the PR with the pertinent information. The logic for the check is provided by the check_upstream_commits.py script from kernel-src-tree-tools
1 parent 096902b commit b82196f

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Check Kernel Commits for Upstream Fixes
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
check-upstream-fixes:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout PR branch
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
ref: ${{ github.head_ref }}
21+
22+
- name: Checkout base branch
23+
run: |
24+
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
25+
26+
- name: Download check_kernel_commits.py
27+
run: |
28+
curl -sL \
29+
https://raw.githubusercontent.com/ctrliq/kernel-src-tree-tools/check_kernel_commits/check_kernel_commits.py \
30+
-o check_kernel_commits.py
31+
chmod +x check_kernel_commits.py
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: '3.x'
37+
38+
- name: Run upstream fixes check
39+
id: checkkernel
40+
run: |
41+
python3 check_kernel_commits.py . "${{ github.head_ref }}" "${{ github.base_ref }}" --pretty | tee result.txt
42+
# Save non-empty results for PR comment
43+
if grep -q -v "All referenced commits exist upstream and have no Fixes: tags." result.txt; then
44+
echo "has_findings=true" >> $GITHUB_OUTPUT
45+
fi
46+
47+
- name: Comment on PR if issues found
48+
if: steps.checkkernel.outputs.has_findings == 'true'
49+
env:
50+
GH_TOKEN: ${{ github.token }}
51+
run: |
52+
gh pr comment ${{ github.event.pull_request.number }} \
53+
--body "$(cat result.txt)" \
54+
--repo ${{ github.repository }}

0 commit comments

Comments
 (0)