|
| 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