Files
GeoLibre/scripts/select-single-appimage.sh
Siddik 0b0f6b6ba2 fix(tests): make the local quality gate pass off Linux (#2214)
CONTRIBUTING asks contributors to run `npm run ci` before opening a pull
request, but on macOS `npm run test:frontend` fails with 5 errors and
cancels 4 more tests, none of them the contributor's. CI does not catch
this because it runs Linux with GNU coreutils and bash 5.

Three independent causes, all in test-only or Linux-only helper code:

select-single-appimage.sh used `mapfile`, a builtin that arrived in bash
4. macOS still ships bash 3.2 as /bin/bash, where it is simply missing,
so all three of its tests failed. Read the lines with a `while IFS= read
-r` loop instead, which behaves identically on both shells.

render-linux-metainfo.sh validated its DATE with GNU `date -d`. BSD date
rejects that flag outright, so the check failed for every date and the
script always exited 1. Try GNU first, then BSD's `-j -f` spelling. BSD
date normalises an out-of-range day instead of rejecting it (2026-02-31
comes back as 2026-03-03 with a zero exit), so the result is compared
against the input rather than trusting the exit status. That is stricter
than the previous check on both implementations, and leaves the rendered
XML byte-identical.

The desktop-settings-url timeout test is not macOS-specific: it asserts
that AbortSignal.timeout fires, but Node leaves that timer unref'd, and
the stalled fetch it races settles only on that abort. With nothing else
pending the event loop drains first and the promise never settles, which
fails the test and cancels the three after it. Hold a ref'd timer across
the assertion so the abort is guaranteed to land.

macOS goes from 5 failed / 4 cancelled to 1 failed / 0 cancelled. The
remaining failure is the _frontend.js module-classification issue in
#2213, left out deliberately: its fix touches Python packaging.

Refs #2213
2026-09-02 11:51:58 -04:00

35 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Print the one .AppImage path out of tauri-action's `artifactPaths` output.
#
# Both release.yml and test-build.yml have to hand exactly that path to
# scripts/embed-appimage-update-info.sh. Reading the action's own output beats
# globbing the bundle directory, which also holds the AppImage-packaged build
# tools, and keeping the selection in one place stops the two workflows from
# drifting apart.
#
# Usage:
# image="$(scripts/select-single-appimage.sh "$ARTIFACT_PATHS")"
#
# The argument is the JSON array tauri-action emits. Exits non-zero unless
# exactly one entry ends in .AppImage, so a bundler change that stops producing
# one (or starts producing several) fails the build rather than silently
# patching the wrong file.
set -euo pipefail
# No apostrophe in the message: bash parses quotes inside ${var:?word}, so one
# there would swallow the rest of the file.
artifacts="${1:?Pass the artifactPaths JSON array from tauri-action}"
# Read with a loop rather than `mapfile`: that builtin arrived in bash 4, and
# macOS still ships bash 3.2 as /bin/bash, where it is simply missing.
images=()
while IFS= read -r image; do
images+=("$image")
done < <(jq -r '.[] | select(endswith(".AppImage"))' <<<"$artifacts")
if [[ ${#images[@]} -ne 1 ]]; then
echo "Expected exactly one .AppImage in artifactPaths, found ${#images[@]}" >&2
exit 1
fi
printf '%s\n' "${images[0]}"