diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index b5a7f37..0352153 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -17,12 +17,13 @@ runs: with: components: clippy, rustfmt, rust-src toolchain: ${{ inputs.toolchain }} + cache: "false" # We set up our own cache manually in the next step rustflags: "" - name: Set up Rust cache uses: Swatinem/rust-cache@v2 with: - shared-key: rust3ds + cache-on-failure: "true" - name: Install build tools for host shell: bash diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index b4d6f2f..98dffea 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -7,27 +7,37 @@ description: > inputs: args: - description: > - Extra arguments to pass to `cargo 3ds test` + description: Extra arguments to pass to `cargo 3ds test` required: false default: '' + runner-image: + description: The name of the container image to build for running tests in + required: false + default: test-runner-3ds + runs: using: composite steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build test-runner image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: - tags: test-runner-3ds:latest + tags: ${{ inputs.runner-image }}:latest push: false - shell: bash - env: - # Set a custom runner for `cargo test` commands to use - CARGO_TARGET_ARMV6K_NINTENDO_3DS_RUNNER: |- - docker run --rm \ - -v /tmp:/tmp \ - -v ${{ github.workspace }}/target:/app/target \ - -v ${{ github.workspace }}:${{ github.workspace }} \ - test-runner-3ds:latest - run: cargo 3ds test ${{ inputs.args }} + # Set a custom runner for `cargo test` commands to use. + # Use ${GITHUB_WORKSPACE} due to + # 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" + env + cargo 3ds -v test ${{ inputs.args }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa7ee03..5016854 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,11 @@ jobs: continue-on-error: ${{ matrix.toolchain == 'nightly' }} runs-on: ubuntu-latest + container: + image: devkitpro/devkitarm + volumes: + - '/var/run/docker.sock:/var/run/docker.sock' + steps: - name: Checkout branch uses: actions/checkout@v3 @@ -52,6 +57,8 @@ jobs: - name: Build and run tests (unit + integration) uses: ./.github/actions/test + with: + args: -- -v - name: Build and run doc tests # Let's still run doc tests even if lib/integration tests fail: @@ -62,7 +69,7 @@ jobs: RUSTDOCFLAGS: " --persist-doctests target/armv6k-nintendo-3ds/debug/doctests" uses: ./.github/actions/test with: - args: --doc + args: --doc -- -v - name: Upload citra logs and capture videos uses: actions/upload-artifact@v3 diff --git a/Dockerfile b/Dockerfile index f183e67..1e81737 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,12 @@ FROM buildpack-deps:latest as builder -ARG CITRA_CHANNEL=nightly -ARG CITRA_RELEASE=1962 - WORKDIR /tmp COPY ./docker/download_citra.sh /usr/local/bin/download_citra RUN apt-get update -y && apt-get install -y jq -RUN download_citra ${CITRA_CHANNEL} ${CITRA_RELEASE} -FROM devkitpro/devkitarm:latest as devkitarm +ARG CITRA_CHANNEL=nightly +ARG CITRA_RELEASE=1995 +RUN download_citra ${CITRA_CHANNEL} ${CITRA_RELEASE} FROM ubuntu:latest @@ -21,8 +19,13 @@ RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ libavfilter7 \ xvfb -COPY --from=devkitarm /opt/devkitpro /opt/devkitpro -ENV PATH=/opt/devkitpro/devkitARM/bin:${PATH} +COPY --from=devkitpro/devkitarm:latest /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: +ENV DEVKITPRO=/opt/devkitpro +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/ diff --git a/docker/download_citra.sh b/docker/download_citra.sh index ec6699c..fd12cea 100755 --- a/docker/download_citra.sh +++ b/docker/download_citra.sh @@ -9,7 +9,7 @@ RELEASE_API="https://api.github.com/repos/citra-emu/citra-${CITRA_CHANNEL}/relea curl "${RELEASE_API}" | jq --raw-output '.assets[].browser_download_url' | - grep -E 'citra-linux-.*.tar.gz' | + grep -E 'citra-linux-.*[.]tar.gz' | xargs wget -O citra-linux.tar.gz tar --strip-components 1 -xvf citra-linux.tar.gz