Skip to content

Commit e6ae83a

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 7030739 commit e6ae83a

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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: Ensure origin/kernel-mainline exists
27+
run: |
28+
if ! git rev-parse --verify origin/kernel-mainline >/dev/null 2>&1; then
29+
echo "::error::origin/kernel-mainline ref is missing. Please ensure it exists and is up-to-date."
30+
exit 1
31+
fi
32+
33+
- name: Download check_kernel_commits.py
34+
run: |
35+
curl -sL \
36+
https://raw.githubusercontent.com/ctrliq/kernel-src-tree-tools/check_kernel_commits/check_kernel_commits.py \
37+
-o check_kernel_commits.py
38+
chmod +x check_kernel_commits.py
39+
40+
- name: Set up Python
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version: '3.x'
44+
45+
- name: Run upstream fixes check
46+
id: checkkernel
47+
run: |
48+
python3 check_kernel_commits.py . "${{ github.head_ref }}" "${{ github.base_ref }}" | tee result.txt
49+
# Save non-empty results for PR comment
50+
if grep -q -v "All referenced commits exist upstream and have no Fixes: tags." result.txt; then
51+
echo "has_findings=true" >> $GITHUB_OUTPUT
52+
fi
53+
54+
- name: Comment on PR if issues found
55+
if: steps.checkkernel.outputs.has_findings == 'true'
56+
env:
57+
GH_TOKEN: ${{ github.token }}
58+
run: |
59+
gh pr comment ${{ github.event.pull_request.number }} \
60+
--body "$(cat result.txt)" \
61+
--repo ${{ github.repository }}

0 commit comments

Comments
 (0)