Skip to content

Commit aac89a5

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 aac89a5

File tree

1 file changed

+66
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)