Skip to content

Commit 7de4d6b

Browse files
committed
summary and manifest scripts
1 parent fa17a5d commit 7de4d6b

3 files changed

Lines changed: 158 additions & 109 deletions

File tree

.github/workflows/docker.yml

Lines changed: 10 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,13 @@ jobs:
2525
name: Workflow Overview
2626
runs-on: ubuntu-latest
2727
steps:
28-
- name: Write overview
29-
shell: bash
30-
run: |
31-
: "${GITHUB_STEP_SUMMARY:=$RUNNER_TEMP/summary.md}"
32-
{
33-
echo "# GEMC Images — Overview"
34-
echo "Repository: [gemc images](https://github.com/gemc/src/pkgs/container/src)"
35-
echo "Except for archlinux (amd64-only), all images are built for both the *amd64* and *arm64* architectures."
36-
echo ""
37-
echo ""
38-
echo "Set these convenience variables for the interactive use below (choose your own password)"
39-
echo '```bash'
40-
echo 'VPORTS=(-p 6080:6080 -p 5900:5900)'
41-
echo 'VNC_PASS=(-e X11VNC_PASSWORD=change-me)'
42-
echo 'VNC_BIND=(-e VNC_BIND=0.0.0.0)'
43-
echo 'GEO_FLAGS=(-e GEOMETRY=1920x1200)'
44-
echo '```'
45-
echo ""
46-
echo "If your arch is arm64 and want to use the archlinux image, add this to all command lines:"
47-
echo '```bash'
48-
echo '--platform=linux/amd64'
49-
echo '```'
50-
echo "---"
51-
} >> "$GITHUB_STEP_SUMMARY"
28+
- name: Write overview
29+
shell: bash
30+
run: |
31+
: "${GITHUB_STEP_SUMMARY:=$RUNNER_TEMP/summary.md}"
32+
bash ci/summary.sh "$GITHUB_STEP_SUMMARY"
33+
34+
5235
5336
discover:
5437
if: ${{ github.event_name != 'pull_request' }}
@@ -234,103 +217,21 @@ jobs:
234217
merge-multiple: true
235218

236219
- name: Summary (manifest)
237-
if: ${{ always() }} # run regardless of earlier step outcomes
220+
if: ${{ always() }}
238221
shell: bash
239222
env:
240223
IMAGE: ${{ needs.discover.outputs.image }}
241224
TAG: ${{ env.TAG4 }}
242225
run: |
243226
SUMMARY_FILE="${GITHUB_STEP_SUMMARY:-$RUNNER_TEMP/manifest_summary.md}"
244227
echo "MANIFEST_SUMMARY_FILE=$SUMMARY_FILE" >> "$GITHUB_ENV"
245-
{
246-
echo "## \`${IMAGE}:${TAG}\`"
247-
echo ""
248-
echo "Includes:"
249-
if docker buildx imagetools inspect "${IMAGE}:${TAG}-amd64" >/dev/null 2>&1; then echo "- amd64"; fi
250-
if docker buildx imagetools inspect "${IMAGE}:${TAG}-arm64" >/dev/null 2>&1; then echo "- arm64"; else echo "- no arm64. Run with --platform=linux/amd64 in arm64 CPUs"; fi
251-
echo ""
252-
echo "### Pull"
253-
echo '```bash'
254-
echo "docker pull ${IMAGE}:${TAG}"
255-
echo '```'
256-
echo ""
257-
echo "### Run in batch mode"
258-
echo '```bash'
259-
echo "docker run --rm -it ${IMAGE}:${TAG} bash -l"
260-
echo '```'
261-
echo ""
262-
echo "### Run with VNC/noVNC"
263-
echo "_VNC → localhost:5900 (password: change-me)_"
264-
echo "_noVNC → http://localhost:6080/vnc.html (password: change-me)_"
265-
echo '```bash'
266-
echo "docker run --rm -it \$VPORTS \$VNC_BIND \$VNC_PASS \$GEO_FLAGS ${IMAGE}:${TAG}"
267-
echo '```'
268-
} >> "$SUMMARY_FILE"
269-
{
270-
echo ""
271-
echo "## Tests"
272-
echo ""
273-
274-
DL="${{ runner.temp }}/downloaded-logs"
275-
echo "_Logs downloaded to:_ \`$DL\`"
276-
echo ""
277-
278-
PATTERN="$DL/logs-${TAG}-*.tgz"
279-
280-
shopt -s nullglob
281-
TARS=( $PATTERN )
282-
shopt -u nullglob
283-
284-
if (( ${#TARS[@]} == 0 )); then
285-
echo "_No logs tarballs found matching:_ \`$PATTERN\`"
286-
else
287-
echo "_Found ${#TARS[@]} tarball(s)._"
288-
echo ""
289-
for tarball in "${TARS[@]}"; do
290-
base="$(basename "$tarball")"
291-
arch="${base#logs-${TAG}-}"
292-
arch="${arch%.tgz}"
293-
294-
work="$DL/extract-$arch"
295-
mkdir -p "$work"
296-
tar -xzf "$tarball" -C "$work"
297-
298-
TEST_LOG="$work/logs/test.log"
299-
300-
echo "### ${arch}"
301-
if [[ -f "$TEST_LOG" ]]; then
302-
echo '```'
303-
OK_FAIL="$(tail -n 2 "$TEST_LOG")"
304-
305-
if grep -q '^Summary of Failures:' "$TEST_LOG"; then
306-
sed -n '/^Summary of Failures:/,/^Ok:/p' "$TEST_LOG" | sed '$d'
307-
echo ""
308-
else
309-
echo "Summary of Failures:"
310-
echo "(none)"
311-
echo ""
312-
fi
313-
314-
echo "$OK_FAIL"
315-
echo '```'
316-
else
317-
echo "_No test log found at:_ \`$TEST_LOG\`"
318-
fi
319-
320-
echo ""
321-
done
322-
fi
323-
324-
} >> "$SUMMARY_FILE"
325-
326-
# Also save a copy inside the workspace for artifact upload
228+
bash ci/manifest.sh "$SUMMARY_FILE" "$IMAGE" "$TAG" "${{ runner.temp }}/downloaded-logs"
229+
327230
mkdir -p "$GITHUB_WORKSPACE/summaries"
328231
OUT="$GITHUB_WORKSPACE/summaries/summary-${TAG}-${{ job.status }}.md"
329232
cp "$SUMMARY_FILE" "$OUT" || true
330233
echo "Wrote $OUT"
331234
332-
ls -l "$GITHUB_WORKSPACE/summaries"
333-
334235
- name: Upload summary artifact (manifest)
335236
uses: actions/upload-artifact@v4
336237
with:

ci/manifest.sh

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Usage:
5+
# ci/manifest.sh SUMMARY_FILE IMAGE TAG [DOWNLOADED_LOGS_DIR]
6+
#
7+
# - SUMMARY_FILE: path to markdown summary file
8+
# - IMAGE: e.g. ghcr.io/gemc/src
9+
# - TAG: e.g. dev-11.4.0-ubuntu-24.04
10+
# - DOWNLOADED_LOGS_DIR (optional): contains logs-${TAG}-*.tgz
11+
12+
summary_file="${1:?missing SUMMARY_FILE}"
13+
image="${2:?missing IMAGE}"
14+
tag="${3:?missing TAG}"
15+
dl_dir="${4:-}"
16+
17+
{
18+
printf '## `%s:%s`\n' "${image}" "${tag}"
19+
printf '\n'
20+
printf 'Includes:\n'
21+
if docker buildx imagetools inspect "${image}:${tag}-amd64" >/dev/null 2>&1; then
22+
printf -- '- amd64\n'
23+
fi
24+
if docker buildx imagetools inspect "${image}:${tag}-arm64" >/dev/null 2>&1; then
25+
printf -- '- arm64\n'
26+
else
27+
printf -- '- no arm64. Run with --platform=linux/amd64 in arm64 CPUs\n'
28+
fi
29+
printf '\n'
30+
printf '### Pull\n'
31+
printf '```bash\n'
32+
printf 'docker pull %s:%s\n' "${image}" "${tag}"
33+
printf '```\n'
34+
printf '\n'
35+
printf '### Run in batch mode\n'
36+
printf '```bash\n'
37+
printf 'docker run --rm -it %s:%s bash -l\n' "${image}" "${tag}"
38+
printf '```\n'
39+
printf '\n'
40+
printf '### Run with VNC/noVNC\n'
41+
printf '_VNC → localhost:5900 (password: change-me)_\n'
42+
printf '_noVNC → http://localhost:6080/vnc.html (password: change-me)_\n'
43+
printf '```bash\n'
44+
printf 'docker run --rm -it $VPORTS $VNC_BIND $VNC_PASS $GEO_FLAGS %s:%s\n' "${image}" "${tag}"
45+
printf '```\n'
46+
printf '\n'
47+
printf '## Tests\n'
48+
printf '\n'
49+
} >> "${summary_file}"
50+
51+
# If no logs directory provided, stop here.
52+
if [[ -z "${dl_dir}" ]]; then
53+
printf '_No downloaded logs directory provided._\n' >> "${summary_file}"
54+
exit 0
55+
fi
56+
57+
if [[ ! -d "${dl_dir}" ]]; then
58+
printf '_Downloaded logs dir does not exist:_ `%s`\n' "${dl_dir}" >> "${summary_file}"
59+
exit 0
60+
fi
61+
62+
pattern="${dl_dir}/logs-${tag}-"*.tgz
63+
64+
# Collect tarballs safely when none match.
65+
shopt -s nullglob
66+
# shellcheck disable=SC2206 # intentional pathname expansion
67+
tars=( ${pattern} )
68+
shopt -u nullglob
69+
70+
if (( ${#tars[@]} == 0 )); then
71+
printf '_No logs tarballs found matching:_ `%s`\n' "${pattern}" >> "${summary_file}"
72+
exit 0
73+
fi
74+
75+
# Sort for stable output (amd64 then arm64, etc.)
76+
IFS=$'\n' sorted=( $(printf '%s\n' "${tars[@]}" | sort) )
77+
unset IFS
78+
79+
printf '_Found %d tarball(s)._\n\n' "${#sorted[@]}" >> "${summary_file}"
80+
81+
for tarball in "${sorted[@]}"; do
82+
base="$(basename "${tarball}")"
83+
arch="${base#logs-${tag}-}"
84+
arch="${arch%.tgz}"
85+
86+
work="${dl_dir}/extract-${arch}"
87+
mkdir -p "${work}"
88+
89+
# Extract only the test log (avoid unpacking everything).
90+
tar -xzf "${tarball}" -C "${work}" logs/test.log >/dev/null 2>&1 || true
91+
test_log="${work}/logs/test.log"
92+
93+
{
94+
printf '### %s\n' "${arch}"
95+
if [[ -f "${test_log}" ]]; then
96+
printf '```text\n'
97+
ok_fail="$(tail -n 2 "${test_log}")"
98+
99+
if grep -q '^Summary of Failures:' "${test_log}"; then
100+
sed -n '/^Summary of Failures:/,/^Ok:/p' "${test_log}" | sed '$d'
101+
printf '\n'
102+
else
103+
printf 'Summary of Failures:\n'
104+
printf '(none)\n'
105+
printf '\n'
106+
fi
107+
108+
printf '%s\n' "${ok_fail}"
109+
printf '```\n'
110+
else
111+
printf '_No test log found at:_ `%s`\n' "${test_log}"
112+
fi
113+
printf '\n'
114+
} >> "${summary_file}"
115+
done

ci/summary.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Usage:
5+
# ci/summary.sh [SUMMARY_FILE]
6+
# If SUMMARY_FILE is omitted, uses $GITHUB_STEP_SUMMARY.
7+
8+
summary_file="${1:-${GITHUB_STEP_SUMMARY:-}}"
9+
if [[ -z "${summary_file}" ]]; then
10+
printf 'ERROR: summary file not provided and GITHUB_STEP_SUMMARY is empty\n' >&2
11+
exit 2
12+
fi
13+
14+
{
15+
printf '# GEMC Images — Overview\n'
16+
printf 'Repository: [gemc images](https://github.com/gemc/src/pkgs/container/src)\n'
17+
printf 'Except for archlinux (amd64-only), all images are built for both the *amd64* and *arm64* architectures.\n'
18+
printf '\n'
19+
printf '\n'
20+
printf 'Set these convenience variables for the interactive use below (choose your own password)\n'
21+
printf '```bash\n'
22+
printf 'VPORTS=(-p 6080:6080 -p 5900:5900)\n'
23+
printf 'VNC_PASS=(-e X11VNC_PASSWORD=change-me)\n'
24+
printf 'VNC_BIND=(-e VNC_BIND=0.0.0.0)\n'
25+
printf 'GEO_FLAGS=(-e GEOMETRY=1920x1200)\n'
26+
printf '```\n'
27+
printf '\n'
28+
printf 'If your arch is arm64 and want to use the archlinux image, add this to all command lines:\n'
29+
printf '```bash\n'
30+
printf -- '--platform=linux/amd64\n'
31+
printf '```\n'
32+
printf -- '---\n'
33+
} >> "${summary_file}"

0 commit comments

Comments
 (0)