Skip to content

Commit 08dd153

Browse files
authored
Merge pull request #82 from fcefyn-testbed/feat/collect-lime-results
ci(dashboard): pull lime-packages test reports from another side
2 parents 00a937d + 7caf8e3 commit 08dd153

1 file changed

Lines changed: 139 additions & 0 deletions

File tree

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Collect lime-packages test results
2+
3+
# Pulls JUnit `report.xml` files from recent CI runs of
4+
# fcefyn-testbed/lime-packages and commits them under
5+
# `docs/ci-results/results/` so the dashboard can render them
6+
# (otherwise the per-job "Report ↗" links 404).
7+
#
8+
# This is the "pull from another side" approach: lime-packages does
9+
# not need to push results to this repo. Requires the secret
10+
# `LIME_PACKAGES_TOKEN` (fine-grained PAT scoped to lime-packages,
11+
# Actions: Read).
12+
13+
on:
14+
schedule:
15+
- cron: '17 */6 * * *' # every 6h, off-peak minute
16+
workflow_dispatch:
17+
inputs:
18+
runs:
19+
description: 'How many recent CI runs to scan'
20+
required: false
21+
default: '10'
22+
23+
permissions:
24+
contents: write
25+
26+
concurrency:
27+
group: collect-lime-results
28+
cancel-in-progress: false
29+
30+
jobs:
31+
collect:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout develop
35+
uses: actions/checkout@v4
36+
with:
37+
ref: develop
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
persist-credentials: true
40+
41+
- name: Download lime-packages report.xml artifacts
42+
env:
43+
GH_TOKEN: ${{ secrets.LIME_PACKAGES_TOKEN }}
44+
SRC_REPO: fcefyn-testbed/lime-packages
45+
RUNS: ${{ github.event.inputs.runs || '10' }}
46+
run: |
47+
set -euo pipefail
48+
mkdir -p docs/ci-results/results
49+
50+
# Scan build-firmware.yml (physical, mesh, qemu) and tests.yml (unit).
51+
workflows=(build-firmware.yml tests.yml)
52+
new_files=0
53+
54+
for wf in "${workflows[@]}"; do
55+
echo "::group::Workflow: $wf"
56+
run_ids=$(gh api \
57+
"repos/${SRC_REPO}/actions/workflows/${wf}/runs?status=completed&per_page=${RUNS}" \
58+
--jq '.workflow_runs[].id' || echo "")
59+
60+
for run_id in $run_ids; do
61+
echo "Run $run_id"
62+
artifacts=$(gh api \
63+
"repos/${SRC_REPO}/actions/runs/${run_id}/artifacts?per_page=100" \
64+
--jq '.artifacts[] | select(.expired == false) | select(.name | startswith("test-results-")) | "\(.id) \(.name)"' \
65+
|| echo "")
66+
67+
while IFS= read -r line; do
68+
[ -z "$line" ] && continue
69+
artifact_id="${line%% *}"
70+
name="${line#* }"
71+
72+
# Map artifact name -> results subpath
73+
dest=""
74+
if [[ "$name" == "test-results-unit" ]]; then
75+
dest="unit"
76+
elif [[ "$name" =~ ^test-results-qemu-single-(.+)-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
77+
dest="qemu-single/${BASH_REMATCH[1]}-${BASH_REMATCH[2]}"
78+
elif [[ "$name" =~ ^test-results-qemu-mesh-(.+)-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
79+
dest="qemu-mesh/${BASH_REMATCH[1]}-${BASH_REMATCH[2]}"
80+
elif [[ "$name" =~ ^test-results-mesh-pairs-(.+)-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
81+
dest="mesh-pairs/${BASH_REMATCH[1]}-${BASH_REMATCH[2]}"
82+
elif [[ "$name" =~ ^test-results-mesh-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
83+
dest="mesh/${BASH_REMATCH[1]}"
84+
elif [[ "$name" =~ ^test-results-(.+)-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
85+
# Catch-all physical: test-results-{place}-{release}
86+
dest="physical/${BASH_REMATCH[1]}-${BASH_REMATCH[2]}"
87+
else
88+
echo " skip $name (unrecognized pattern)"
89+
continue
90+
fi
91+
92+
outdir="docs/ci-results/results/${dest}"
93+
if [[ -f "${outdir}/report.xml" ]]; then
94+
# Already collected from an earlier (more recent) run.
95+
continue
96+
fi
97+
98+
tmp=$(mktemp -d)
99+
if ! gh api \
100+
"repos/${SRC_REPO}/actions/artifacts/${artifact_id}/zip" \
101+
> "$tmp/a.zip" 2>/dev/null; then
102+
echo " download failed: $name"
103+
rm -rf "$tmp"
104+
continue
105+
fi
106+
107+
# report.xml is at the artifact root for unit jobs and
108+
# under the logs dir for lab/qemu jobs — try both.
109+
mkdir -p "$outdir"
110+
if unzip -j -q -o "$tmp/a.zip" "report.xml" -d "$outdir" 2>/dev/null \
111+
|| unzip -j -q -o "$tmp/a.zip" "*/report.xml" -d "$outdir" 2>/dev/null; then
112+
echo " collected $name -> $outdir/report.xml"
113+
new_files=$((new_files + 1))
114+
else
115+
echo " no report.xml inside $name"
116+
rmdir "$outdir" 2>/dev/null || true
117+
fi
118+
rm -rf "$tmp"
119+
done <<< "$artifacts"
120+
done
121+
echo "::endgroup::"
122+
done
123+
124+
echo "Collected $new_files new report.xml file(s)."
125+
echo "NEW_FILES=$new_files" >> "$GITHUB_ENV"
126+
127+
- name: Commit and push results
128+
if: env.NEW_FILES != '0'
129+
run: |
130+
set -euo pipefail
131+
git config user.name "github-actions[bot]"
132+
git config user.email "github-actions[bot]@users.noreply.github.com"
133+
git add docs/ci-results/results/
134+
if git diff --cached --quiet; then
135+
echo "Nothing to commit."
136+
exit 0
137+
fi
138+
git commit -m "ci: collect lime-packages test results ($NEW_FILES new)"
139+
git push origin develop

0 commit comments

Comments
 (0)