Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/scripts/create-pr-body.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

# Script to create PR body
# Arguments: build_time total_time passed failed run_id comparison_section repo commit_message_file

set -euo pipefail

# Check number of arguments
if [ $# -lt 7 ] || [ $# -gt 8 ]; then
echo "Error: Expected 7 or 8 arguments, got $#" >&2
Comment on lines +9 to +10
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The argument validation checks for 7 or 8 arguments, but the 8th argument has a default value on line 22, making it effectively always present when accessed. This creates confusion about whether the argument is optional or required. Consider either removing the upper bound check (allow any number >= 7) or documenting more clearly that the 8th argument is optional with a default.

Suggested change
if [ $# -lt 7 ] || [ $# -gt 8 ]; then
echo "Error: Expected 7 or 8 arguments, got $#" >&2
if [ $# -lt 7 ]; then
echo "Error: Expected at least 7 arguments, got $#" >&2

Copilot uses AI. Check for mistakes.
echo "Usage: $0 <build_time> <total_time> <passed> <failed> <run_id> <comparison_section> <repo> [commit_message_file]" >&2
exit 1
fi

BUILD_TIME="$1"
TOTAL_TIME="$2"
PASSED="$3"
FAILED="$4"
RUN_ID="$5"
COMPARISON_SECTION="$6"
REPO="$7"
COMMIT_MESSAGE_FILE="${8:-/tmp/commit_message.txt}"

# Validate required arguments are not empty
if [ -z "$BUILD_TIME" ] || [ -z "$TOTAL_TIME" ] || [ -z "$PASSED" ] || [ -z "$FAILED" ] || [ -z "$RUN_ID" ] || [ -z "$COMPARISON_SECTION" ] || [ -z "$REPO" ]; then
echo "Error: One or more required arguments are empty" >&2
echo "Usage: $0 <build_time> <total_time> <passed> <failed> <run_id> <comparison_section> <repo> [commit_message_file]" >&2
exit 1
fi

# Check if commit message file exists
if [ ! -f "$COMMIT_MESSAGE_FILE" ]; then
echo "Error: Commit message file not found: $COMMIT_MESSAGE_FILE" >&2
exit 1
fi

# Convert seconds to minutes for better readability
convert_time() {
local seconds="${1%s}" # Remove 's' suffix if present
local minutes=$((seconds / 60))
local remaining_seconds=$((seconds % 60))
echo "${minutes}m ${remaining_seconds}s"
}
Comment on lines +38 to +43
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convert_time function assumes the input is numeric after removing the 's' suffix, but doesn't validate this. If BUILD_TIME or TOTAL_TIME are 'N/A' (as set in the workflow on line 447-448), the arithmetic operations on lines 40-41 will fail. Add validation to check if the input is 'N/A' or non-numeric before attempting conversion.

Copilot uses AI. Check for mistakes.

BUILD_TIME_READABLE=$(convert_time "$BUILD_TIME")
TOTAL_TIME_READABLE=$(convert_time "$TOTAL_TIME")

cat << EOF
## Summary
This PR has been automatically created after successful completion of all CI stages.

## Commit Message(s)

EOF

cat "$COMMIT_MESSAGE_FILE"
echo ""

cat << EOF

## Test Results

### ✅ Build Stage
- Status: Passed
- Build Time: ${BUILD_TIME_READABLE}
- Total Time: ${TOTAL_TIME_READABLE}
- [View build logs](https://github.com/${REPO}/actions/runs/${RUN_ID})

### ✅ Boot Verification
- Status: Passed
- [View boot logs](https://github.com/${REPO}/actions/runs/${RUN_ID})

### ✅ Kernel Selftests
- **Passed:** ${PASSED}
- **Failed:** ${FAILED}
- [View kselftest logs](https://github.com/${REPO}/actions/runs/${RUN_ID})

${COMPARISON_SECTION}

---
🤖 This PR was automatically generated by GitHub Actions
Run ID: ${RUN_ID}
EOF
Loading