fix gh buildx cache and test appimage logging

This commit is contained in:
Logan Rawlins committed 2026-11-01 19:15:54 -07:00
1 parent d8a33b7547
commit 4ab32d7966
2 files changed
+166 -52

No files matched your search

+32 -24
View File
@@ -68,22 +68,26 @@ jobs:
- run: flutter pub get
- run: flutter build linux --release --no-pub
- uses: docker/setup-buildx-action@v3
- name: Read AppImage base image
id: appimage-base
run: echo "image=$(jq -r '.ubuntu' scripts/appimage-tools.json)" >> "$GITHUB_OUTPUT"
- name: Build cached x86_64 runtime test image
run: |
docker buildx build \
--platform linux/amd64 \
--target runtime-test \
--build-arg "BASE_IMAGE=$(jq -r '.ubuntu' scripts/appimage-tools.json)" \
--cache-from type=gha,scope=meshcore-appimage-runtime-amd64 \
--cache-to type=gha,mode=max,scope=meshcore-appimage-runtime-amd64 \
--tag meshcore-appimage-runtime:ci \
--load \
-f scripts/appimage/Dockerfile \
scripts
uses: docker/build-push-action@v6
with:
context: scripts
file: scripts/appimage/Dockerfile
target: runtime-test
platforms: linux/amd64
build-args: |
BASE_IMAGE=${{ steps.appimage-base.outputs.image }}
tags: meshcore-appimage-runtime:ci
cache-from: type=gha,scope=meshcore-appimage-runtime-amd64
cache-to: type=gha,mode=max,scope=meshcore-appimage-runtime-amd64
load: true
- name: Test AppImage in clean Ubuntu
run: |
mkdir -p build/appimage-runtime
docker run --rm --user "$(id -u):$(id -g)" --mount "type=bind,source=$PWD/build/linux/x64/release/meshcore-open-x86_64.AppImage,target=/artifact.AppImage,readonly" --mount "type=bind,source=$PWD/scripts/appimage/test_runtime.sh,target=/test_runtime.sh,readonly" --mount "type=bind,source=$PWD/build/appimage-runtime,target=/results" meshcore-appimage-runtime:ci xvfb-run -a bash /test_runtime.sh /artifact.AppImage /results
docker run --rm --stop-timeout 15 --user "$(id -u):$(id -g)" --mount "type=bind,source=$PWD/build/linux/x64/release/meshcore-open-x86_64.AppImage,target=/artifact.AppImage,readonly" --mount "type=bind,source=$PWD/scripts/appimage/test_runtime.sh,target=/test_runtime.sh,readonly" --mount "type=bind,source=$PWD/build/appimage-runtime,target=/results" meshcore-appimage-runtime:ci timeout --verbose --signal=TERM --kill-after=15s 300s xvfb-run -a bash /test_runtime.sh /artifact.AppImage /results
- uses: actions/upload-artifact@v4
if: always()
with:
@@ -140,22 +144,26 @@ jobs:
exit 1
fi
- uses: docker/setup-buildx-action@v3
- name: Read AppImage base image
id: appimage-base
run: echo "image=$(jq -r '.ubuntu' scripts/appimage-tools.json)" >> "$GITHUB_OUTPUT"
- name: Build cached ARM64 runtime test image
run: |
docker buildx build \
--platform linux/arm64 \
--target runtime-test \
--build-arg "BASE_IMAGE=$(jq -r '.ubuntu' scripts/appimage-tools.json)" \
--cache-from type=gha,scope=meshcore-appimage-runtime-arm64 \
--cache-to type=gha,mode=max,scope=meshcore-appimage-runtime-arm64 \
--tag meshcore-appimage-runtime-arm64:ci \
--load \
-f scripts/appimage/Dockerfile \
scripts
uses: docker/build-push-action@v6
with:
context: scripts
file: scripts/appimage/Dockerfile
target: runtime-test
platforms: linux/arm64
build-args: |
BASE_IMAGE=${{ steps.appimage-base.outputs.image }}
tags: meshcore-appimage-runtime-arm64:ci
cache-from: type=gha,scope=meshcore-appimage-runtime-arm64
cache-to: type=gha,mode=max,scope=meshcore-appimage-runtime-arm64
load: true
- name: Test ARM64 AppImage in clean Ubuntu
run: |
mkdir -p build/appimage-runtime
docker run --rm --platform linux/arm64 --user "$(id -u):$(id -g)" --mount "type=bind,source=$PWD/build/linux/arm64/release/meshcore-open-aarch64.AppImage,target=/artifact.AppImage,readonly" --mount "type=bind,source=$PWD/scripts/appimage/test_runtime.sh,target=/test_runtime.sh,readonly" --mount "type=bind,source=$PWD/build/appimage-runtime,target=/results" meshcore-appimage-runtime-arm64:ci xvfb-run -a bash /test_runtime.sh /artifact.AppImage /results
docker run --rm --stop-timeout 15 --platform linux/arm64 --user "$(id -u):$(id -g)" --mount "type=bind,source=$PWD/build/linux/arm64/release/meshcore-open-aarch64.AppImage,target=/artifact.AppImage,readonly" --mount "type=bind,source=$PWD/scripts/appimage/test_runtime.sh,target=/test_runtime.sh,readonly" --mount "type=bind,source=$PWD/build/appimage-runtime,target=/results" meshcore-appimage-runtime-arm64:ci timeout --verbose --signal=TERM --kill-after=15s 300s xvfb-run -a bash /test_runtime.sh /artifact.AppImage /results
- uses: actions/upload-artifact@v4
if: always()
with:
+134 -28
View File
@@ -4,73 +4,179 @@ set -euo pipefail
image="$(realpath "$1")"
mkdir -p "$2"
output="$(realpath "$2")"
exec > >(tee -a "$output/runtime-test.log") 2>&1
log() {
printf '[%s] %s\n' "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" "$*" >&2
}
run_timed() {
local label="$1" limit="$2" capture="$3" started status
shift 3
started=$SECONDS
log "START $label (timeout $limit)"
if timeout --signal=TERM --kill-after=5s "$limit" "$@" >"$capture" 2>&1; then
log "PASS $label ($((SECONDS - started))s)"
return 0
fi
status=$?
tail -n 40 "$capture" >&2 || true
log "FAIL $label (exit $status after $((SECONDS - started))s)"
return "$status"
}
case "$(uname -m)" in
x86_64) expected_machine='Advanced Micro Devices X86-64' ;;
aarch64) expected_machine='AArch64' ;;
*) printf 'Unsupported runtime-test architecture: %s\n' "$(uname -m)" >&2; exit 1 ;;
*) log "Unsupported runtime-test architecture: $(uname -m)"; exit 1 ;;
esac
log "Runtime test starting: architecture=$(uname -m) image=$image size=$(stat -c %s "$image") bytes"
if ! readelf -h "$image" | grep -Fq "$expected_machine"; then
printf 'AppImage runtime is not built for %s\n' "$(uname -m)" >&2
log "AppImage runtime is not built for $(uname -m)"
exit 1
fi
workspace="$(mktemp -d)"
app_pid=''
bus_pid=''
stop_process() {
local process_id="$1" attempt
[[ -n "$process_id" ]] || return 0
kill -0 "$process_id" 2>/dev/null || return 0
kill -TERM "$process_id" 2>/dev/null || true
for ((attempt = 0; attempt < 5; attempt++)); do
kill -0 "$process_id" 2>/dev/null || break
sleep 1
done
kill -KILL "$process_id" 2>/dev/null || true
wait "$process_id" 2>/dev/null || true
}
cleanup() {
[[ -z "$app_pid" ]] || kill "$app_pid" 2>/dev/null || true
[[ -z "$bus_pid" ]] || kill "$bus_pid" 2>/dev/null || true
log 'Cleanup: stopping application and D-Bus processes'
stop_process "$app_pid"
stop_process "$bus_pid"
rm -rf "$workspace"
}
trap cleanup EXIT
cd "$workspace"
printf 'AppImage runtime test: extracting image\n'
cp "$image" "$workspace/extractor"
printf '\0\0\0' | dd of="$workspace/extractor" bs=1 seek=8 count=3 conv=notrunc status=none
timeout 60 "$workspace/extractor" --appimage-extract > /dev/null
run_timed 'extract AppImage' 120s "$output/extract.log" \
"$workspace/extractor" --appimage-extract
appdir="$workspace/squashfs-root"
log 'Checking extracted AppImage structure'
[[ -x "$appdir/AppRun" && -f "$appdir/usr/bin/lib/libapp.so" && \
-f "$appdir/usr/bin/data/icudtl.dat" && -d "$appdir/usr/bin/data/flutter_assets" ]]
[[ -f "$appdir/usr/bin/lib/libonnxruntime.so.1" && \
-f "$appdir/usr/share/glib-2.0/schemas/gschemas.compiled" ]]
log 'Starting bundled ELF architecture audit'
elf_count=0
while IFS= read -r -d '' library; do
if readelf -h "$library" >/dev/null 2>&1 && \
! readelf -h "$library" | grep -Fq "$expected_machine"; then
printf 'Wrong ELF architecture in AppImage: %s\n' "${library#"$appdir/"}" >&2
exit 1
if readelf -h "$library" >/dev/null 2>&1; then
elf_count=$((elf_count + 1))
log "Checking ELF $elf_count: ${library#"$appdir/"}"
if ! readelf -h "$library" | grep -Fq "$expected_machine"; then
log "Wrong ELF architecture in AppImage: ${library#"$appdir/"}"
exit 1
fi
fi
done < <(find "$appdir/usr/bin" "$appdir/usr/lib" -type f -print0)
ldd "$appdir/usr/bin/meshcore_open" > "$output/dependencies.log" 2>&1
log "ELF architecture audit passed ($elf_count files)"
dependencies="$output/dependencies.log"
: > "$dependencies"
run_timed 'check application dependencies' 20s "$workspace/ldd.log" \
ldd "$appdir/usr/bin/meshcore_open"
cat "$workspace/ldd.log" >> "$dependencies"
while IFS= read -r -d '' library; do
printf '\n%s\n' "${library#"$appdir/"}" >> "$output/dependencies.log"
ldd "$library" >> "$output/dependencies.log" 2>&1 || true
relative="${library#"$appdir/"}"
if run_timed "check dependencies: $relative" 20s "$workspace/ldd.log" ldd "$library"; then
cat "$workspace/ldd.log" >> "$dependencies"
else
status=$?
cat "$workspace/ldd.log" >> "$dependencies"
if [[ "$status" == 124 || "$status" == 137 ]]; then
exit "$status"
fi
log "ldd returned $status for $relative; continuing unresolved-dependency scan"
fi
done < <(find "$appdir/usr/bin/lib" "$appdir/usr/lib" -type f -name '*.so*' -print0)
if grep 'not found' "$output/dependencies.log"; then
printf 'Unresolved AppImage dependencies\n' >&2
if grep 'not found' "$dependencies"; then
log 'Unresolved AppImage dependencies'
exit 1
fi
log 'Dependency audit passed'
mkdir -p "$workspace/home/Documents" "$workspace/home/config"
printf 'XDG_DOCUMENTS_DIR="%s/Documents"\n' "$workspace/home" > "$workspace/home/config/user-dirs.dirs"
bus_pid="$(dbus-daemon --session --address="unix:path=$workspace/system-bus" --fork --print-pid)"
printf 'AppImage runtime test: launching application\n'
run_timed 'start private D-Bus system bus' 10s "$output/dbus-daemon.log" \
dbus-daemon --session --address="unix:path=$workspace/system-bus" --fork --print-pid
bus_pid="$(<"$output/dbus-daemon.log")"
log "D-Bus system bus started: pid=$bus_pid"
log 'Starting AppRun'
env -u LD_LIBRARY_PATH -u GTK_PATH -u GSETTINGS_SCHEMA_DIR \
HOME="$workspace/home" XDG_CONFIG_HOME="$workspace/home/config" \
XDG_DATA_HOME="$workspace/home/data" XDG_CACHE_HOME="$workspace/home/cache" \
DBUS_SYSTEM_BUS_ADDRESS="unix:path=$workspace/system-bus" \
dbus-run-session -- "$appdir/AppRun" > "$output/startup.log" 2>&1 &
app_pid=$!
window="$(timeout 60 xdotool search --sync --onlyvisible --limit 1 --name 'MeshCore Open|meshcore_open')"
colors=0
deadline=$((SECONDS + 60))
while (( SECONDS < deadline )); do
kill -0 "$app_pid"
xwd -silent -id "$window" -out "$workspace/window.xwd"
convert "$workspace/window.xwd" "$output/startup.png"
colors="$(identify -format '%k' "$output/startup.png")"
(( colors < 20 )) || break
log "AppRun started: pid=$app_pid"
window=''
window_deadline=$((SECONDS + 90))
next_window_report=$((SECONDS + 10))
while ((SECONDS < window_deadline)); do
if ! kill -0 "$app_pid" 2>/dev/null; then
log 'AppRun exited before opening a visible window; startup.log follows'
tail -n 100 "$output/startup.log" >&2 || true
exit 1
fi
if window="$(timeout --signal=TERM --kill-after=2s 5s \
xdotool search --onlyvisible --limit 1 --name 'MeshCore Open|meshcore_open' 2>/dev/null)"; then
break
fi
if ((SECONDS >= next_window_report)); then
log "Still waiting for the application window (${SECONDS}s elapsed)"
next_window_report=$((SECONDS + 10))
fi
sleep 1
done
(( colors >= 20 )) || { printf 'Application window remained blank\n' >&2; exit 1; }
if [[ -z "$window" ]]; then
log 'Timed out waiting 90s for a visible application window; startup.log follows'
tail -n 100 "$output/startup.log" >&2 || true
exit 1
fi
log "Visible application window found: id=$window"
colors=0
screenshot_deadline=$((SECONDS + 60))
next_screenshot_report=$((SECONDS + 10))
while ((SECONDS < screenshot_deadline)); do
# shellcheck disable=SC2016
if timeout --signal=TERM --kill-after=5s 15s bash -e -c \
'xwd -silent -id "$1" -out "$2" && convert "$2" "$3" && identify -format "%k" "$3"' \
_ "$window" "$workspace/window.xwd" "$output/startup.png" \
> "$workspace/screenshot.log" 2>&1; then
colors="$(<"$workspace/screenshot.log")"
else
status=$?
tail -n 40 "$workspace/screenshot.log" >&2 || true
log "Screenshot capture failed (exit $status)"
exit "$status"
fi
[[ "$colors" =~ ^[0-9]+$ ]] || { log "Unexpected screenshot color count: $colors"; exit 1; }
((colors >= 20)) && break
if ((SECONDS >= next_screenshot_report)); then
log "Window still appears blank (${colors} colors, $((screenshot_deadline - SECONDS))s remaining)"
next_screenshot_report=$((SECONDS + 10))
fi
done
((colors >= 20)) || { log 'Application window remained blank after 60s'; exit 1; }
[[ -s "$output/startup.png" ]]
if grep -Ei 'error while loading shared libraries|cannot open shared object|failed to load asset|unhandled exception' "$output/startup.log"; then
exit 1
fi
printf 'Extracted AppImage startup passed; screenshot: %s/startup.png\n' "$output"
log "Runtime test passed; screenshot: $output/startup.png"