1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 07:03:14 -04:00
Files
egui/scripts/update_snapshots_from_ci.sh
Lucas Meurer 903bd81313 Add script to update local snapshots from CI (#5816)
It seems like the thresholds are too low for all tests to pass when
snapshots are generated from windows / linux. We need a better solution
to this problem, but in the meantime this script should allow
contributors to update their snapshots by downloading them from the last
CI run.
2025-03-25 09:19:21 +01:00

37 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# This script searches for the last CI run with your branch name, downloads the test_results artefact
# and replaces your existing snapshots with the new ones.
# Make sure you have the gh cli installed and authenticated before running this script.
set -eu
BRANCH=$(git rev-parse --abbrev-ref HEAD)
RUN_ID=$(gh run list --branch "$BRANCH" --workflow "Rust" --json databaseId -q '.[0].databaseId')
ECHO "Downloading test results from run $RUN_ID from branch $BRANCH"
# remove any existing .new.png that might have been left behind
find . -type d -path "*/tests/snapshots*" | while read dir; do
find "$dir" -type f -name "*.new.png" | while read file; do
rm "$file"
done
done
gh run download "$RUN_ID" --name "test-results" --dir tmp_artefacts
# move the snapshots to the correct location, overwriting the existing ones
rsync -a tmp_artefacts/ .
rm -r tmp_artefacts
# rename the .new.png files to .png
find . -type d -path "*/tests/snapshots*" | while read dir; do
find "$dir" -type f -name "*.new.png" | while read file; do
mv -f "$file" "${file%.new.png}.png"
done
done
echo "Done!"