|
| 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 | +\`\`\` |
| 54 | +EOF |
| 55 | + |
| 56 | +cat "$COMMIT_MESSAGE_FILE" |
| 57 | +echo "" |
| 58 | + |
| 59 | +cat << EOF |
| 60 | +\`\`\` |
| 61 | +
|
| 62 | +## Test Results |
| 63 | +
|
| 64 | +### ✅ Build Stage |
| 65 | +- Status: Passed |
| 66 | +- Build Time: ${BUILD_TIME_READABLE} |
| 67 | +- Total Time: ${TOTAL_TIME_READABLE} |
| 68 | +- [View build logs](https://github.com/${REPO}/actions/runs/${RUN_ID}) |
| 69 | +
|
| 70 | +### ✅ Boot Verification |
| 71 | +- Status: Passed |
| 72 | +- [View boot logs](https://github.com/${REPO}/actions/runs/${RUN_ID}) |
| 73 | +
|
| 74 | +### ✅ Kernel Selftests |
| 75 | +- **Passed:** ${PASSED} |
| 76 | +- **Failed:** ${FAILED} |
| 77 | +- [View kselftest logs](https://github.com/${REPO}/actions/runs/${RUN_ID}) |
| 78 | +
|
| 79 | +${COMPARISON_SECTION} |
| 80 | +
|
| 81 | +--- |
| 82 | +🤖 This PR was automatically generated by GitHub Actions |
| 83 | +Run ID: ${RUN_ID} |
| 84 | +EOF |
0 commit comments