Browse Source

Overhaul the test-runner entrypoint for one file

Make sure docker is installed in our custom action
pull/7/head
Ian Chamberlain 1 year ago
parent
commit
0f7be6f691
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 8
      .github/actions/test/action.yml
  2. 90
      docker/entrypoint.sh

8
.github/actions/test/action.yml

@ -27,8 +27,14 @@ runs:
with: with:
tags: ${{ inputs.runner-image }}:latest tags: ${{ inputs.runner-image }}:latest
push: false push: false
load: true
- shell: bash - name: Ensure docker is installed in the container
shell: bash
run: apt-get update -y && apt-get install docker.io -y
- name: Run cargo 3ds test
shell: bash
# Set a custom runner for `cargo test` commands to use. # Set a custom runner for `cargo test` commands to use.
# Use ${GITHUB_WORKSPACE} due to # Use ${GITHUB_WORKSPACE} due to
# https://github.com/actions/runner/issues/2058, which also means # https://github.com/actions/runner/issues/2058, which also means

90
docker/entrypoint.sh

@ -1,50 +1,64 @@
#!/bin/bash #!/bin/bash
# Clean up child processes on exit: https://stackoverflow.com/a/2173421/14436105 set -x
trap "pkill -P $$" EXIT INT TERM
function cleanup_jobs() {
mkdir -p ~/.config/citra-emu # shellcheck disable=SC2317 # Unreachable because it's only used in trap
cp /app/sdl2-config.ini ~/.config/citra-emu if [ -n "$(jobs -p)" ]; then
# For some reason, log file is only written when this dir already exists, sleep 5 &
# but it is only created after the first run of citra (our only run, in the container) wait -n
mkdir -p ~/.local/share/citra-emu/ # shellcheck disable=SC2046 # We want to expand jobs here and for `wait`
kill -9 $(jobs -p)
ERRS=0 # shellcheck disable=SC2046
# shellcheck disable=SC2068 wait $(jobs -p) &>/dev/null
for EXE in $@; do fi
VIDEO_OUT="$(dirname "$EXE")/$(basename "$EXE" .elf)_capture.webm" }
# colored logs would be nice, but we can always just grab the plaintext log file trap cleanup_jobs EXIT
xvfb-run citra \
EXE_ELF=$1
EXE_3DSX="$(dirname "$EXE")/$(basename "$EXE" .elf).3dsx"
EXE_TO_RUN="$EXE_ELF"
if [ -f "$EXE_3DSX" ]; then
echo >&2 "Found $(basename "$EXE_3DSX"), it will be run instead of $(basename "$EXE_ELF")"
EXE_TO_RUN="$EXE_3DSX"
fi
VIDEO_OUT="$(dirname "$EXE_ELF")/$(basename "$EXE_ELF" .elf)_capture.webm"
CITRA_LOG_DIR=~/.local/share/citra-emu/log
CITRA_OUT="$CITRA_LOG_DIR/citra_output.txt"
xvfb-run --auto-servernum \
citra \
--appimage-extract-and-run \ --appimage-extract-and-run \
--dump-video="$VIDEO_OUT" \ --dump-video="$VIDEO_OUT" \
"$EXE" \ "$EXE_TO_RUN" \
&>/dev/null & &>"$CITRA_OUT" &
PID=$! CITRA_PID=$!
# Citra takes a little while to start up, so wait a little before we try to connect # Citra takes a little while to start up, so wait a little before we try to connect
sleep 3 sleep 5
arm-none-eabi-gdb --silent --batch-silent --command /app/test-runner.gdb "$EXE" arm-none-eabi-gdb --silent --batch-silent --command /app/test-runner.gdb "$EXE_ELF"
STATUS=$? STATUS=$?
if [ $STATUS -ne 0 ]; then
echo >&2 "FAILED (exit status $STATUS): $EXE"
ERRS=$(( ERRS + 1 ))
fi
kill -INT $PID &>/dev/null kill $CITRA_PID
sleep 1 cleanup_jobs
if kill -0 $PID &>/dev/null; then
kill -KILL $PID &>/dev/null
fi
CITRA_LOG=~/.local/share/citra-emu/log/citra_log.txt CITRA_LOG="$CITRA_LOG_DIR/citra_log.txt"
CITRA_LOG_OUT="$(dirname "$EXE")/$(basename "$EXE" .elf)_citra_log.txt"
if test -f "$CITRA_LOG"; then for f in "$CITRA_LOG" "$CITRA_OUT"; do
cp "$CITRA_LOG" "$CITRA_LOG_OUT" OUT="$(dirname "$EXE_ELF")/$(basename "$EXE_ELF" .elf)_$(basename "$f")"
if test -f "$f"; then
cp "$f" "$OUT"
if [ $STATUS -ne 0 ]; then
echo >&2 "$(basename $f) copied to $OUT"
fi
else else
echo "WARNING: citra log not found" echo >&2 "WARNING: $(basename "$f") not found"
fi fi
done done
exit $ERRS exit $STATUS

Loading…
Cancel
Save