Skip to content
Open
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
106 changes: 82 additions & 24 deletions .github/scripts/create-pr-body.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
#!/bin/bash

# Script to create PR body
# Arguments: build_time total_time passed failed run_id comparison_section repo commit_message_file
# Arguments: arch build_time total_time passed failed run_id comparison_section repo commit_message_file [build_time_aarch64 total_time_aarch64 passed_aarch64 failed_aarch64]

set -euo pipefail

# Check number of arguments
if [ $# -lt 7 ] || [ $# -gt 8 ]; then
echo "Error: Expected 7 or 8 arguments, got $#" >&2
echo "Usage: $0 <build_time> <total_time> <passed> <failed> <run_id> <comparison_section> <repo> [commit_message_file]" >&2
# Check number of arguments (8-9 for single arch, 13 for multi-arch)
if [ $# -lt 8 ] || ([ $# -gt 9 ] && [ $# -ne 13 ]); then
echo "Error: Expected 8-9 arguments (single arch) or 13 arguments (multi-arch), got $#" >&2
echo "Usage: $0 <arch> <build_time> <total_time> <passed> <failed> <run_id> <comparison_section> <repo> [commit_message_file] [build_time_aarch64 total_time_aarch64 passed_aarch64 failed_aarch64]" >&2
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this confusing.
So arch can be x86_64,aarch64 or just one of them right?

But then, buil_time, total time etc do not seem to be arch specific based on the name, even though it is because they represent the first arch given.
Also, the optional params are named after aarch64. What if x86 is the optional arch?
I may be missing something, but I personally find this hard to read.

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}"
ARCH="$1"
BUILD_TIME_ARCH1="$2"
TOTAL_TIME_ARCH1="$3"
PASSED_ARCH1="$4"
FAILED_ARCH1="$5"
RUN_ID="$6"
COMPARISON_SECTION="$7"
REPO="$8"
COMMIT_MESSAGE_FILE="${9:-/tmp/commit_message.txt}"

# Multi-arch parameters (optional)
MULTIARCH=false
if [ $# -eq 13 ]; then
MULTIARCH=true
BUILD_TIME_ARCH2="${10}"
TOTAL_TIME_ARCH2="${11}"
PASSED_ARCH2="${12}"
FAILED_ARCH2="${13}"
fi

# 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
if [ -z "$ARCH" ] || [ -z "$BUILD_TIME_ARCH1" ] || [ -z "$TOTAL_TIME_ARCH1" ] || [ -z "$PASSED_ARCH1" ] || [ -z "$FAILED_ARCH1" ] || [ -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
echo "Usage: $0 <arch> <build_time> <total_time> <passed> <failed> <run_id> <comparison_section> <repo> [commit_message_file] [build_time_aarch64 total_time_aarch64 passed_aarch64 failed_aarch64]" >&2
exit 1
fi

Expand All @@ -42,8 +53,20 @@ convert_time() {
echo "${minutes}m ${remaining_seconds}s"
}

BUILD_TIME_READABLE=$(convert_time "$BUILD_TIME")
TOTAL_TIME_READABLE=$(convert_time "$TOTAL_TIME")
BUILD_TIME_ARCH1_READABLE=$(convert_time "$BUILD_TIME_ARCH1")
TOTAL_TIME_ARCH1_READABLE=$(convert_time "$TOTAL_TIME_ARCH1")

if [ "$MULTIARCH" = true ]; then
BUILD_TIME_ARCH2_READABLE=$(convert_time "$BUILD_TIME_ARCH2")
TOTAL_TIME_ARCH2_READABLE=$(convert_time "$TOTAL_TIME_ARCH2")

# Parse architecture names from ARCH variable (e.g., "x86_64,aarch64")
ARCH1_NAME=$(echo "$ARCH" | cut -d',' -f1)
ARCH2_NAME=$(echo "$ARCH" | cut -d',' -f2)
else
# Single architecture case
ARCH1_NAME="$ARCH"
fi

cat << EOF
## Summary
Expand All @@ -56,23 +79,31 @@ EOF
cat "$COMMIT_MESSAGE_FILE"
echo ""

cat << EOF
if [ "$MULTIARCH" = true ]; then
cat << EOF
## Test Results
### ✅ Build Stage
- Status: Passed
- Build Time: ${BUILD_TIME_READABLE}
- Total Time: ${TOTAL_TIME_READABLE}
| Architecture | Build Time | Total Time |
|--------------|------------|------------|
| ${ARCH1_NAME} | ${BUILD_TIME_ARCH1_READABLE} | ${TOTAL_TIME_ARCH1_READABLE} |
| ${ARCH2_NAME} | ${BUILD_TIME_ARCH2_READABLE} | ${TOTAL_TIME_ARCH2_READABLE} |
- [View build logs](https://github.com/${REPO}/actions/runs/${RUN_ID})
### ✅ Boot Verification
- Status: Passed
- Status: Passed (both architectures)
- [View boot logs](https://github.com/${REPO}/actions/runs/${RUN_ID})
### ✅ Kernel Selftests
- **Passed:** ${PASSED}
- **Failed:** ${FAILED}
| Architecture | Passed | Failed |
|--------------|---------|--------|
| ${ARCH1_NAME} | ${PASSED_ARCH1} | ${FAILED_ARCH1} |
| ${ARCH2_NAME} | ${PASSED_ARCH2} | ${FAILED_ARCH2} |
- [View kselftest logs](https://github.com/${REPO}/actions/runs/${RUN_ID})
${COMPARISON_SECTION}
Expand All @@ -81,3 +112,30 @@ ${COMPARISON_SECTION}
🤖 This PR was automatically generated by GitHub Actions
Run ID: ${RUN_ID}
EOF
else
cat << EOF
## Test Results
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a lot of duplication.

I prefer to just add 3 ifs if MULTIARCH and add the second arch there.

### ✅ Build Stage
- Status: Passed (${ARCH1_NAME})
- Build Time: ${BUILD_TIME_ARCH1_READABLE}
- Total Time: ${TOTAL_TIME_ARCH1_READABLE}
- [View build logs](https://github.com/${REPO}/actions/runs/${RUN_ID})
### ✅ Boot Verification
- Status: Passed (${ARCH1_NAME})
- [View boot logs](https://github.com/${REPO}/actions/runs/${RUN_ID})
### ✅ Kernel Selftests (${ARCH1_NAME})
- **Passed:** ${PASSED_ARCH1}
- **Failed:** ${FAILED_ARCH1}
- [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
fi
Loading