Skip to content

Commit afef289

Browse files
committed
fixups
1 parent 661e984 commit afef289

1 file changed

Lines changed: 74 additions & 14 deletions

File tree

.github/workflows/daily.yml

Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,12 @@ jobs:
143143
export firmware=openwrt-${{ matrix.target }}-${{ matrix.device }}-${{ matrix.firmware }}
144144
145145
mkdir -p /tmp/tftp/${{ matrix.device }}
146-
wget $UPSTREAM_URL/${target/-/\/}/$firmware \
147-
--output-document /tmp/tftp/${{ matrix.device }}/$firmware
146+
if ! wget $UPSTREAM_URL/${target/-/\/}/$firmware \
147+
--output-document /tmp/tftp/${{ matrix.device }}/$firmware; then
148+
echo "::warning::Failed to download firmware $firmware. Skipping CI test."
149+
echo "SKIP_TEST=true" >> $GITHUB_ENV
150+
exit 0
151+
fi
148152
(cd /tmp/tftp/ && gzip -df ${{ matrix.device }}/$firmware) || true
149153
150154
FIRMWARE_VERSION=$(curl $UPSTREAM_URL/${target/-/\/}/version.buildinfo)
@@ -157,6 +161,13 @@ jobs:
157161
profiles_url="$UPSTREAM_URL/${target/-/\/}/profiles.json"
158162
profiles_json=$(curl -s "$profiles_url")
159163
164+
# Check if profiles.json was successfully downloaded
165+
if [ -z "$profiles_json" ] || [ "$profiles_json" = "{}" ] || ! echo "$profiles_json" | jq empty 2>/dev/null; then
166+
echo "::warning::Could not download or parse profiles.json from $profiles_url. Skipping CI test."
167+
echo "SKIP_TEST=true" >> $GITHUB_ENV
168+
exit 0
169+
fi
170+
160171
# Find the kernel image for the device
161172
if [ "${{ matrix.device }}" = "generic" ]; then
162173
profile_key="generic"
@@ -165,6 +176,14 @@ jobs:
165176
profile_key="${{ matrix.device }}"
166177
fi
167178
179+
# Check if the profile exists in profiles.json
180+
profile_exists=$(echo "$profiles_json" | jq -r --arg profile "$profile_key" '.profiles | has($profile)')
181+
if [ "$profile_exists" != "true" ]; then
182+
echo "::warning::Profile '$profile_key' not found in profiles.json. Skipping CI test."
183+
echo "SKIP_TEST=true" >> $GITHUB_ENV
184+
exit 0
185+
fi
186+
168187
# Extract the kernel/combined image filename based on firmware type
169188
case "${{ matrix.firmware }}" in
170189
*squashfs-combined*)
@@ -209,8 +228,12 @@ jobs:
209228
echo "Using firmware: $firmware_filename"
210229
211230
mkdir -p /tmp/tftp/${{ matrix.device }}
212-
wget "$UPSTREAM_URL/${target/-/\/}/$firmware_filename" \
213-
--output-document /tmp/tftp/${{ matrix.device }}/$firmware_filename
231+
if ! wget "$UPSTREAM_URL/${target/-/\/}/$firmware_filename" \
232+
--output-document /tmp/tftp/${{ matrix.device }}/$firmware_filename; then
233+
echo "::warning::Failed to download firmware $firmware_filename. Skipping CI test."
234+
echo "SKIP_TEST=true" >> $GITHUB_ENV
235+
exit 0
236+
fi
214237
(cd /tmp/tftp/ && gzip -df ${{ matrix.device }}/$firmware_filename) || true
215238
216239
FIRMWARE_VERSION=$(echo "$profiles_json" | jq -r '.version_code')
@@ -225,10 +248,18 @@ jobs:
225248
eval $(uv run labgrid-client reserve --wait --shell device=${{ matrix.device }})
226249
echo "LG_TOKEN=$LG_TOKEN" >> $GITHUB_ENV
227250
echo "LG_PLACE=+" >> $GITHUB_ENV
228-
uv run labgrid-client -p +$LG_TOKEN lock
251+
if [ "$SKIP_TEST" != "true" ]; then
252+
uv run labgrid-client -p +$LG_TOKEN lock
253+
fi
229254
echo "LG_ENV=targets/${{ matrix.device }}.yaml" >> $GITHUB_ENV
230255
256+
- name: Skip test notification
257+
if: env.SKIP_TEST == 'true'
258+
run: |
259+
echo "::notice::Skipping CI test for ${{ matrix.device }} (${{ matrix.version_name }}) due to profiles.json issues"
260+
231261
- name: Run test
262+
if: env.SKIP_TEST != 'true'
232263
run: |
233264
mkdir -p ${{ matrix.device }}-${{ matrix.version_name }}/
234265
uv run pytest tests/ \
@@ -238,14 +269,14 @@ jobs:
238269
--log-cli-level=CONSOLE
239270
240271
- name: Poweroff and unlock device
241-
if: always()
272+
if: always() && env.SKIP_TEST != 'true'
242273
run: |
243274
uv run labgrid-client power off || true
244-
uv run labgrid-client unlock
275+
uv run labgrid-client -p +$LG_TOKEN unlock
245276
246277
- name: Upload results
247278
uses: actions/upload-artifact@v4
248-
if: always()
279+
if: always() && env.SKIP_TEST != 'true'
249280
with:
250281
name: results-${{ matrix.device }}-${{ matrix.version_name }}
251282
path: ${{ matrix.device }}-${{ matrix.version_name }}/*
@@ -290,14 +321,33 @@ jobs:
290321
291322
# Snapshot logic
292323
firmware_name="openwrt-$target-${{ matrix.firmware }}"
293-
wget "$UPSTREAM_URL/${target/-/\/}/$firmware_name" \
294-
--output-document "$firmware_name"
324+
if ! wget "$UPSTREAM_URL/${target/-/\/}/$firmware_name" \
325+
--output-document "$firmware_name"; then
326+
echo "::warning::Failed to download firmware $firmware_name. Skipping CI test."
327+
echo "SKIP_TEST=true" >> $GITHUB_ENV
328+
exit 0
329+
fi
295330
FIRMWARE_VERSION=$(curl "$UPSTREAM_URL/${target/-/\/}/version.buildinfo")
296331
else
297332
# Stable release logic
298333
profiles_url="$UPSTREAM_URL/${target/-/\/}/profiles.json"
299334
profiles_json=$(curl -s "$profiles_url")
300335
336+
# Check if profiles.json was successfully downloaded
337+
if [ -z "$profiles_json" ] || [ "$profiles_json" = "{}" ] || ! echo "$profiles_json" | jq empty 2>/dev/null; then
338+
echo "::warning::Could not download or parse profiles.json from $profiles_url. Skipping CI test."
339+
echo "SKIP_TEST=true" >> $GITHUB_ENV
340+
exit 0
341+
fi
342+
343+
# Check if the generic profile exists in profiles.json
344+
profile_exists=$(echo "$profiles_json" | jq -r '.profiles | has("generic")')
345+
if [ "$profile_exists" != "true" ]; then
346+
echo "::warning::Profile 'generic' not found in profiles.json. Skipping CI test."
347+
echo "SKIP_TEST=true" >> $GITHUB_ENV
348+
exit 0
349+
fi
350+
301351
# Find the appropriate image for QEMU
302352
case "${{ matrix.firmware }}" in
303353
*squashfs-combined*)
@@ -339,15 +389,25 @@ jobs:
339389
fi
340390
341391
echo "Using firmware: $firmware_name"
342-
wget "$UPSTREAM_URL/${target/-/\/}/$firmware_name" \
343-
--output-document "$firmware_name"
392+
if ! wget "$UPSTREAM_URL/${target/-/\/}/$firmware_name" \
393+
--output-document "$firmware_name"; then
394+
echo "::warning::Failed to download firmware $firmware_name. Skipping CI test."
395+
echo "SKIP_TEST=true" >> $GITHUB_ENV
396+
exit 0
397+
fi
344398
FIRMWARE_VERSION=$(echo "$profiles_json" | jq -r '.version_code')
345399
fi
346400
347401
echo "FIRMWARE_VERSION=$FIRMWARE_VERSION" >> $GITHUB_ENV
348402
echo "FIRMWARE_FILE=$firmware_name" >> $GITHUB_ENV
349403
404+
- name: Skip test notification
405+
if: env.SKIP_TEST == 'true'
406+
run: |
407+
echo "::notice::Skipping CI test for ${{ matrix.target }} (${{ matrix.version_name }}) due to profiles.json issues"
408+
350409
- name: Run test
410+
if: env.SKIP_TEST != 'true'
351411
run: |
352412
gunzip $FIRMWARE_FILE || true
353413
firmware_file=${FIRMWARE_FILE/.gz/}
@@ -363,9 +423,9 @@ jobs:
363423
364424
- name: Upload results
365425
uses: actions/upload-artifact@v4
366-
if: always()
426+
if: always() && env.SKIP_TEST != 'true'
367427
with:
368-
name: results-qemu_${{ matrix.target }}-${{ matrix.version_name }}
428+
name: qemu-results-${{ matrix.target }}-${{ matrix.version_name }}
369429
path: ${{ matrix.target }}-${{ matrix.version_name }}/*
370430

371431
results:

0 commit comments

Comments
 (0)