Skip to content

Commit 5d870f3

Browse files
committed
enhance
1 parent ac9b185 commit 5d870f3

2 files changed

Lines changed: 111 additions & 61 deletions

File tree

.github/workflows/pr-build-test.yaml

Lines changed: 111 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ on:
88
type: number
99
required: true
1010
host:
11-
description: 'Target host (x86_64-Linux, aarch64-Linux, or ALL)'
11+
description: 'Target host'
1212
type: choice
1313
options:
1414
- x86_64-Linux
1515
- aarch64-Linux
16+
- riscv64-Linux
1617
- ALL
1718
default: x86_64-Linux
1819

@@ -194,43 +195,137 @@ jobs:
194195
runs-on: ubuntu-latest
195196
permissions:
196197
pull-requests: write
198+
actions: read
197199
steps:
198-
- name: Post build result comment
200+
- name: Download build status artifacts
201+
uses: actions/download-artifact@v4
202+
with:
203+
pattern: build-status-*
204+
path: /tmp/build-status
205+
merge-multiple: false
206+
continue-on-error: true
207+
208+
- name: Generate detailed comment
199209
env:
200210
GH_TOKEN: ${{ github.token }}
201211
run: |
212+
set -euo pipefail
213+
202214
BUILD_STATUS="${{ needs.build.result }}"
203215
RECIPES='${{ needs.detect-changes.outputs.changed_recipes }}'
204216
HOST="${{ inputs.host }}"
205217
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
218+
REPO_OWNER="${{ github.repository_owner }}"
219+
220+
# Build results table header
221+
echo "| Recipe | Host | Status | Package |" > /tmp/results_table.md
222+
echo "|--------|------|--------|---------|" >> /tmp/results_table.md
223+
224+
# Process build status artifacts
225+
SUCCESS_COUNT=0
226+
FAILURE_COUNT=0
227+
SKIPPED_COUNT=0
228+
229+
if [ -d "/tmp/build-status" ]; then
230+
for status_dir in /tmp/build-status/build-status-*/; do
231+
[ -d "$status_dir" ] || continue
232+
status_file="${status_dir}build-status.json"
233+
[ -f "$status_file" ] || continue
234+
235+
host=$(jq -r '.host // "unknown"' "$status_file")
236+
status=$(jq -r '.status // "unknown"' "$status_file")
237+
recipe_url=$(jq -r '.recipe_url // ""' "$status_file")
238+
239+
# Extract recipe path from URL
240+
recipe_path=$(echo "$recipe_url" | grep -oE '(binaries|packages)/[^"]+\.yaml' || echo "unknown")
241+
pkg_family=$(echo "$recipe_path" | cut -d'/' -f2)
242+
recipe_name=$(basename "$recipe_path" .yaml)
243+
244+
# Determine cache type
245+
if echo "$recipe_path" | grep -q "^packages/"; then
246+
CACHE_TYPE="pkgcache"
247+
else
248+
CACHE_TYPE="bincache"
249+
fi
250+
251+
case "$status" in
252+
success)
253+
STATUS_ICON="✅"
254+
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
255+
GHCR_URL="https://github.com/${REPO_OWNER}/${CACHE_TYPE}/pkgs/container/${pkg_family}%2F${recipe_name}"
256+
PKG_LINK="[📦 View](${GHCR_URL})"
257+
;;
258+
failure)
259+
STATUS_ICON="❌"
260+
FAILURE_COUNT=$((FAILURE_COUNT + 1))
261+
PKG_LINK="-"
262+
;;
263+
skipped)
264+
STATUS_ICON="⏭️"
265+
SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
266+
PKG_LINK="-"
267+
;;
268+
*)
269+
STATUS_ICON="⚠️"
270+
PKG_LINK="-"
271+
;;
272+
esac
273+
274+
echo "| \`${recipe_path}\` | \`${host}\` | ${STATUS_ICON} ${status} | ${PKG_LINK} |" >> /tmp/results_table.md
275+
done
276+
fi
206277
278+
RESULTS_TABLE=$(cat /tmp/results_table.md)
279+
TOTAL=$((SUCCESS_COUNT + FAILURE_COUNT + SKIPPED_COUNT))
280+
281+
# Overall status header
207282
if [ "$BUILD_STATUS" == "success" ]; then
208-
EMOJI="✅"
209-
STATUS_TEXT="succeeded"
283+
HEADER_EMOJI="✅"
284+
HEADER_TEXT="Build Test Passed"
210285
elif [ "$BUILD_STATUS" == "failure" ]; then
211-
EMOJI="❌"
212-
STATUS_TEXT="failed"
286+
HEADER_EMOJI="❌"
287+
HEADER_TEXT="Build Test Failed"
288+
elif [ "$BUILD_STATUS" == "skipped" ]; then
289+
HEADER_EMOJI="⏭️"
290+
HEADER_TEXT="Build Test Skipped"
213291
else
214-
EMOJI="⚠️"
215-
STATUS_TEXT="completed with status: ${BUILD_STATUS}"
292+
HEADER_EMOJI="⚠️"
293+
HEADER_TEXT="Build Test: ${BUILD_STATUS}"
216294
fi
217295
218-
RECIPE_LIST=$(echo "$RECIPES" | jq -r '.[].path' | sed 's/^/- `/' | sed 's/$/`/')
296+
# Summary line
297+
SUMMARY="**${SUCCESS_COUNT}** passed"
298+
[ "$FAILURE_COUNT" -gt 0 ] && SUMMARY="${SUMMARY}, **${FAILURE_COUNT}** failed"
299+
[ "$SKIPPED_COUNT" -gt 0 ] && SUMMARY="${SUMMARY}, **${SKIPPED_COUNT}** skipped"
300+
301+
# Build the comment using heredoc for proper formatting
302+
cat > /tmp/comment.md << EOF
303+
## ${HEADER_EMOJI} ${HEADER_TEXT}
304+
305+
| | |
306+
|---|---|
307+
| **Target** | \`${HOST}\` |
308+
| **Commit** | \`${{ needs.detect-changes.outputs.pr_head_sha }}\` |
309+
| **Summary** | ${SUMMARY} |
310+
311+
### Build Results
312+
313+
${RESULTS_TABLE}
219314
220-
COMMENT_BODY="## ${EMOJI} Build Test ${STATUS_TEXT}
315+
<details>
316+
<summary>📋 View workflow logs</summary>
221317
222-
**Host:** \`${HOST}\`
223-
**Workflow Run:** [View Details](${RUN_URL})
318+
**Workflow Run:** [${RUN_URL}](${RUN_URL})
224319
225-
### Recipes tested:
226-
${RECIPE_LIST}
320+
</details>
227321
228322
---
229-
*Triggered manually via workflow_dispatch*"
323+
<sub>🤖 Triggered via workflow_dispatch by @${{ github.actor }}</sub>
324+
EOF
230325
231326
gh pr comment "${{ inputs.pr_number }}" \
232327
--repo "${{ github.repository }}" \
233-
--body "$COMMENT_BODY"
328+
--body-file /tmp/comment.md
234329
235330
no-changes:
236331
needs: detect-changes

binaries/jq/static.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)