Skip to content

Commit 11f36fa

Browse files
committed
github actions: Add reusable workflow for validating kernel commits
Converts the upstream-commit-check workflow (from ciqlts9_2) to a reusable workflow that can be referenced from branches. This allows maintaining the workflow definition in one place while using it across many branches. The workflow uses workflow_call trigger and accepts all necessary context from the calling workflow via github context variables. We are renaming the workflow and some of the labels it uses to be more general. In the future, more kernel commit validation will happen in this workflow besides just the upstream fixes check
1 parent 6ffedb0 commit 11f36fa

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Validate Kernel Commits
2+
3+
on:
4+
workflow_call:
5+
# No inputs needed - uses github context from caller
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
validate-kernel-commits:
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/mainline/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: check-kernel-commits
40+
run: |
41+
set +e # Don't exit on error, we want to capture the output
42+
python3 check_kernel_commits.py --repo . --pr_branch "${{ github.head_ref }}" --base_branch "${{ github.base_ref }}" --markdown | tee result.txt
43+
EXIT_CODE=$?
44+
45+
# Check if the script failed
46+
if [ $EXIT_CODE -ne 0 ]; then
47+
echo "❌ Kernel commits check failed with exit code $EXIT_CODE"
48+
exit $EXIT_CODE
49+
fi
50+
51+
# Check for findings:
52+
# 1. Verify the success message exists
53+
# 2. If it exists, check if there are any OTHER lines (which would indicate issues)
54+
# 3. If success message doesn't exist, that's also a finding
55+
if grep -q "All referenced commits exist upstream and have no Fixes: tags." result.txt; then
56+
# Success message found, check if there are any other lines
57+
LINE_COUNT=$(wc -l < ../ckc_result.txt)
58+
if [ "$LINE_COUNT" -gt 1 ]; then
59+
echo "has_findings=true" >> $GITHUB_OUTPUT
60+
else
61+
echo "has_findings=false" >> $GITHUB_OUTPUT
62+
fi
63+
else
64+
# Success message not found, there must be findings
65+
echo "has_findings=true" >> $GITHUB_OUTPUT
66+
fi
67+
68+
set -e # Re-enable exit on error
69+
70+
- name: Comment on PR if issues found
71+
if: steps.check-kernel-commits.outputs.has_findings == 'true'
72+
env:
73+
GH_TOKEN: ${{ github.token }}
74+
run: |
75+
if ! gh pr comment ${{ github.event.pull_request.number }} \
76+
--body-file result.txt \
77+
--repo ${{ github.repository }}; then
78+
echo "❌ Failed to post check-kernel-commits comment to PR"
79+
exit 1
80+
fi

0 commit comments

Comments
 (0)