From 224865854e44ca5fe87146c360e049fc1d23dd4b Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Sun, 24 Sep 2023 13:08:19 -0400 Subject: [PATCH] Move actions to top-level for nicer call syntax For external repos this will be a lot simpler --- .github/workflows/ci.yml | 15 +++++++------ Dockerfile | 21 +++++++++++++++++-- README.md | 4 +++- .../actions/test => run-tests}/action.yml | 11 +++++----- {.github/actions/setup => setup}/action.yml | 0 5 files changed, 37 insertions(+), 14 deletions(-) rename {.github/actions/test => run-tests}/action.yml (82%) rename {.github/actions/setup => setup}/action.yml (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5016854..7f9cf4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Checkout branch uses: actions/checkout@v2 - - uses: ./.github/actions/setup + - uses: ./actions/setup with: toolchain: ${{ matrix.toolchain }} @@ -45,18 +45,20 @@ jobs: container: image: devkitpro/devkitarm volumes: + # So the test action can `docker run` the runner: - '/var/run/docker.sock:/var/run/docker.sock' - + # So the built test artifacts end up on the host, not just inside the action container + - '/tmp:/tmp' steps: - name: Checkout branch uses: actions/checkout@v3 - - uses: ./.github/actions/setup + - uses: ./setup with: toolchain: ${{ matrix.toolchain }} - name: Build and run tests (unit + integration) - uses: ./.github/actions/test + uses: ./run-tests with: args: -- -v @@ -67,9 +69,10 @@ jobs: # This ensures the citra logs and video output gets put in a directory # where we can upload as artifacts RUSTDOCFLAGS: " --persist-doctests target/armv6k-nintendo-3ds/debug/doctests" - uses: ./.github/actions/test + uses: ./run-tests with: - args: --doc -- -v + # TODO(#4): run them suckers + args: --doc --no-run -- -v - name: Upload citra logs and capture videos uses: actions/upload-artifact@v3 diff --git a/Dockerfile b/Dockerfile index 1e81737..c250038 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,15 @@ ARG CITRA_CHANNEL=nightly ARG CITRA_RELEASE=1995 RUN download_citra ${CITRA_CHANNEL} ${CITRA_RELEASE} +FROM devkitpro/devkitarm as devkitarm + +# For some reason, citra isn't always happy when you try to run it for the first time, +# so we build a simple dummy program to force it to create its directory structure +RUN cd /opt/devkitpro/examples/3ds/graphics/printing/hello-world && \ + echo 'int main(int, char**) {}' > source/main.c && \ + make && \ + mv hello-world.3dsx /tmp/ + FROM ubuntu:latest RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ @@ -19,7 +28,7 @@ RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ libavfilter7 \ xvfb -COPY --from=devkitpro/devkitarm:latest /opt/devkitpro /opt/devkitpro +COPY --from=devkitarm /opt/devkitpro /opt/devkitpro # There's no way to copy ENV values from other stages properly: # https://github.com/moby/moby/issues/37345 # Luckily in this case we know exactly what the values should be: @@ -28,7 +37,15 @@ ENV DEVKITARM=${DEVKITPRO}/devkitARM ENV PATH=${DEVKITARM}/bin:${PATH} COPY --from=builder /tmp/citra.AppImage /usr/local/bin/citra -COPY ./docker/sdl2-config.ini /app/ +COPY --from=devkitarm /tmp/hello-world.3dsx /tmp/ +# We run citra once before copying our config file, so it should create its +# necessary directory structure and run once with defaults +RUN xvfb-run citra --appimage-extract-and-run /tmp/hello-world.3dsx; \ + rm -f /tmp/hello-world.3dsx +# Initial run seems to miss this one directory so just make it manually +RUN mkdir -p /root/.local/share/citra-emu/log + +COPY ./docker/sdl2-config.ini /root/.config/citra-emu/ COPY ./docker/test-runner.gdb /app/ COPY ./docker/entrypoint.sh /app/ diff --git a/README.md b/README.md index 6141473..956e201 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,6 @@ A set of tools for running automated Rust tests against Citra (3DS emulator). * `.github/actions/citra`: action for running test executables with Citra in workflows - +## Usage + + diff --git a/.github/actions/test/action.yml b/run-tests/action.yml similarity index 82% rename from .github/actions/test/action.yml rename to run-tests/action.yml index d28d518..b957bb4 100644 --- a/.github/actions/test/action.yml +++ b/run-tests/action.yml @@ -40,10 +40,11 @@ runs: # https://github.com/actions/runner/issues/2058, which also means # we have to export this instead of using the env: key run: | - export CARGO_TARGET_ARMV6K_NINTENDO_3DS_RUNNER="docker run --rm - -v /tmp:/tmp - -v ${GITHUB_WORKSPACE}/target:/app/target - -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE} - ${{ inputs.runner-image }}:latest" + export CARGO_TARGET_ARMV6K_NINTENDO_3DS_RUNNER=" + docker run --rm + -v /tmp:/tmp + -v ${{ github.workspace }}/target:/app/target + -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE} + ${{ inputs.runner-image }}:latest" env cargo 3ds -v test ${{ inputs.args }} diff --git a/.github/actions/setup/action.yml b/setup/action.yml similarity index 100% rename from .github/actions/setup/action.yml rename to setup/action.yml