Skip to content

Commit be7aa3a

Browse files
shreeya-patel98roxanan1996
authored andcommitted
Add PR body generation script
Script to generate detailed PR descriptions with kselftest results. Signed-off-by: Shreeya Patel <spatel@ciq.com>
1 parent bf14f10 commit be7aa3a

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/scripts/create-pr-body.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
3+
# Script to create PR body
4+
# Arguments: build_time total_time passed failed run_id comparison_section repo commit_message_file
5+
6+
set -euo pipefail
7+
8+
# Check number of arguments
9+
if [ $# -lt 7 ] || [ $# -gt 8 ]; then
10+
echo "Error: Expected 7 or 8 arguments, got $#" >&2
11+
echo "Usage: $0 <build_time> <total_time> <passed> <failed> <run_id> <comparison_section> <repo> [commit_message_file]" >&2
12+
exit 1
13+
fi
14+
15+
BUILD_TIME="$1"
16+
TOTAL_TIME="$2"
17+
PASSED="$3"
18+
FAILED="$4"
19+
RUN_ID="$5"
20+
COMPARISON_SECTION="$6"
21+
REPO="$7"
22+
COMMIT_MESSAGE_FILE="${8:-/tmp/commit_message.txt}"
23+
24+
# Validate required arguments are not empty
25+
if [ -z "$BUILD_TIME" ] || [ -z "$TOTAL_TIME" ] || [ -z "$PASSED" ] || [ -z "$FAILED" ] || [ -z "$RUN_ID" ] || [ -z "$COMPARISON_SECTION" ] || [ -z "$REPO" ]; then
26+
echo "Error: One or more required arguments are empty" >&2
27+
echo "Usage: $0 <build_time> <total_time> <passed> <failed> <run_id> <comparison_section> <repo> [commit_message_file]" >&2
28+
exit 1
29+
fi
30+
31+
# Check if commit message file exists
32+
if [ ! -f "$COMMIT_MESSAGE_FILE" ]; then
33+
echo "Error: Commit message file not found: $COMMIT_MESSAGE_FILE" >&2
34+
exit 1
35+
fi
36+
37+
# Convert seconds to minutes for better readability
38+
convert_time() {
39+
local seconds="${1%s}" # Remove 's' suffix if present
40+
local minutes=$((seconds / 60))
41+
local remaining_seconds=$((seconds % 60))
42+
echo "${minutes}m ${remaining_seconds}s"
43+
}
44+
45+
BUILD_TIME_READABLE=$(convert_time "$BUILD_TIME")
46+
TOTAL_TIME_READABLE=$(convert_time "$TOTAL_TIME")
47+
48+
cat << EOF
49+
## Summary
50+
This PR has been automatically created after successful completion of all CI stages.
51+
52+
## Commit Message(s)
53+
EOF
54+
55+
cat "$COMMIT_MESSAGE_FILE"
56+
echo ""
57+
58+
cat << EOF
59+
60+
## Test Results
61+
62+
### ✅ Build Stage
63+
- Status: Passed
64+
- Build Time: ${BUILD_TIME_READABLE}
65+
- Total Time: ${TOTAL_TIME_READABLE}
66+
- [View build logs](https://github.com/${REPO}/actions/runs/${RUN_ID})
67+
68+
### ✅ Boot Verification
69+
- Status: Passed
70+
- [View boot logs](https://github.com/${REPO}/actions/runs/${RUN_ID})
71+
72+
### ✅ Kernel Selftests
73+
- **Passed:** ${PASSED}
74+
- **Failed:** ${FAILED}
75+
- [View kselftest logs](https://github.com/${REPO}/actions/runs/${RUN_ID})
76+
77+
${COMPARISON_SECTION}
78+
79+
---
80+
🤖 This PR was automatically generated by GitHub Actions
81+
Run ID: ${RUN_ID}
82+
EOF

0 commit comments

Comments
 (0)