Skip to content

Commit 025c28b

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
1 parent 7030739 commit 025c28b

File tree

1 file changed

+68
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)