Skip to content

Commit c395bb1

Browse files
Add PR creation step
Signed-off-by: Shreeya Patel <[email protected]>
1 parent 74ba259 commit c395bb1

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed

.github/workflows/kernel-build-and-test-x86_64.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,133 @@ jobs:
262262
else
263263
echo "::warning::No previous successful test results found for branch ${{ github.ref_name }}, skipping comparison"
264264
fi
265+
266+
create-pr:
267+
name: Create Pull Request
268+
runs-on: kernel-build
269+
needs: [build, boot, test-kselftest, compare-results]
270+
if: success()
271+
272+
steps:
273+
- name: Checkout kernel source
274+
uses: actions/checkout@v4
275+
with:
276+
fetch-depth: 0
277+
token: ${{ secrets.GITHUB_TOKEN }}
278+
279+
- name: Download kernel compilation logs
280+
uses: actions/download-artifact@v4
281+
with:
282+
name: kernel-compilation-logs-x86_64
283+
path: artifacts/build
284+
285+
- name: Download boot logs
286+
uses: actions/download-artifact@v4
287+
with:
288+
name: boot-logs-x86_64
289+
path: artifacts/boot
290+
291+
- name: Download kselftest logs
292+
uses: actions/download-artifact@v4
293+
with:
294+
name: kselftest-logs-x86_64
295+
path: artifacts/test
296+
297+
- name: Extract test statistics
298+
id: stats
299+
run: |
300+
PASSED=$(grep -a '^ok' artifacts/test/kselftests-*.log | wc -l || echo "0")
301+
FAILED=$(grep -a '^not ok' artifacts/test/kselftests-*.log | wc -l || echo "0")
302+
echo "passed=$PASSED" >> $GITHUB_OUTPUT
303+
echo "failed=$FAILED" >> $GITHUB_OUTPUT
304+
305+
- name: Extract build timers
306+
id: build_info
307+
run: |
308+
BUILD_TIME=$(grep -oP '\[TIMER\]\{BUILD\}:\s*\K[0-9]+' artifacts/build/kernel-build.log | head -1 || echo "N/A")
309+
TOTAL_TIME=$(grep -oP '\[TIMER\]\{TOTAL\}\s*\K[0-9]+' artifacts/build/kernel-build.log | head -1 || echo "N/A")
310+
echo "build_time=${BUILD_TIME}s" >> $GITHUB_OUTPUT
311+
echo "total_time=${TOTAL_TIME}s" >> $GITHUB_OUTPUT
312+
313+
- name: Get commit information
314+
id: commit_msg
315+
run: |
316+
# Count commits since origin/main (or appropriate base branch)
317+
BASE_BRANCH="main"
318+
if ! git rev-parse origin/$BASE_BRANCH >/dev/null 2>&1; then
319+
# Try other common base branch names
320+
for branch in master lts-9.2 lts-9; do
321+
if git rev-parse origin/$branch >/dev/null 2>&1; then
322+
BASE_BRANCH=$branch
323+
break
324+
fi
325+
done
326+
fi
327+
328+
COMMIT_COUNT=$(git rev-list --count origin/$BASE_BRANCH..HEAD 2>/dev/null || echo "1")
329+
330+
if [ "$COMMIT_COUNT" -eq "1" ]; then
331+
# Single commit: use commit subject
332+
COMMIT_SUBJECT=$(git log -1 --pretty=%s)
333+
echo "commit_subject=$COMMIT_SUBJECT" >> $GITHUB_OUTPUT
334+
335+
COMMIT_MSG=$(git log -1 --pretty=%B)
336+
echo "commit_message<<EOF" >> $GITHUB_OUTPUT
337+
echo "$COMMIT_MSG" >> $GITHUB_OUTPUT
338+
echo "EOF" >> $GITHUB_OUTPUT
339+
else
340+
# Multiple commits: create summary
341+
echo "commit_subject=Multiple patches tested ($COMMIT_COUNT commits)" >> $GITHUB_OUTPUT
342+
343+
# Get all commit messages
344+
ALL_COMMITS=$(git log origin/$BASE_BRANCH..HEAD --pretty=format:"### %s%n%n%b%n---")
345+
echo "commit_message<<EOF" >> $GITHUB_OUTPUT
346+
echo "$ALL_COMMITS" >> $GITHUB_OUTPUT
347+
echo "EOF" >> $GITHUB_OUTPUT
348+
fi
349+
350+
- name: Create Pull Request
351+
uses: peter-evans/create-pull-request@v6
352+
with:
353+
token: ${{ secrets.GITHUB_TOKEN }}
354+
commit-message: "Automated PR: All tests passed"
355+
title: "[${{ github.ref_name }}] ${{ steps.commit_msg.outputs.commit_subject }}"
356+
body: |
357+
## Summary
358+
This PR has been automatically created after successful completion of all CI stages.
359+
360+
## Commit Message
361+
```
362+
${{ steps.commit_msg.outputs.commit_message }}
363+
```
364+
365+
## Test Results
366+
367+
### ✅ Build Stage
368+
- Status: Passed
369+
- Build Time: ${{ steps.build_info.outputs.build_time }}
370+
- Total Time: ${{ steps.build_info.outputs.total_time }}
371+
- [View build logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
372+
373+
### ✅ Boot Verification
374+
- Status: Passed
375+
- [View boot logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
376+
377+
### ✅ Kernel Selftests
378+
- **Passed:** ${{ steps.stats.outputs.passed }}
379+
- **Failed:** ${{ steps.stats.outputs.failed }}
380+
- [View kselftest logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
381+
382+
### ✅ Test Comparison
383+
- Comparison against previous run: Within acceptable threshold (±3 tests)
384+
- Branch: ${{ github.ref_name }}
385+
386+
---
387+
🤖 This PR was automatically generated by GitHub Actions
388+
Run ID: ${{ github.run_id }}
389+
branch: pr/${{ github.ref_name }}-tested
390+
delete-branch: true
391+
labels: |
392+
automated
393+
tested
394+
ready-for-review

0 commit comments

Comments
 (0)