diff --git a/.github/actions/citra/action.yml b/.github/actions/citra/action.yml deleted file mode 100644 index 18441f0..0000000 --- a/.github/actions/citra/action.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'Run 3DS Executable' -description: 'Run a given 3DS executable with citra and GDB' -inputs: - executable: - description: > - The 3DS executable(s) to run. Globs and space separated lists allowed. - required: true -runs: - using: docker - image: ../../../Dockerfile - args: - - ${{ inputs.executable }} diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 95629df..b5a7f37 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -10,14 +10,6 @@ inputs: runs: using: composite steps: - # https://github.com/nektos/act/issues/917#issuecomment-1074421318 - - if: ${{ env.ACT }} - shell: bash - name: Hack container for local development - run: | - curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - - sudo apt-get install -y nodejs - - name: Setup default Rust toolchain # Use this helper action so we get matcher support # https://github.com/actions-rust-lang/setup-rust-toolchain/pull/15 @@ -25,6 +17,7 @@ runs: with: components: clippy, rustfmt, rust-src toolchain: ${{ inputs.toolchain }} + rustflags: "" - name: Set up Rust cache uses: Swatinem/rust-cache@v2 @@ -38,7 +31,7 @@ runs: - name: Install cargo-3ds shell: bash # TODO: replace with crates.io version once published - run: cargo install --git https://github.com/rust3ds/cargo-3ds --branch feature/verbose-flag + run: cargo install --locked --git https://github.com/rust3ds/cargo-3ds - name: Set PATH to include devkitARM shell: bash diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml new file mode 100644 index 0000000..b4d6f2f --- /dev/null +++ b/.github/actions/test/action.yml @@ -0,0 +1,33 @@ +name: Cargo 3DS Test +description: > + Run `cargo 3ds test` executables using Citra. Note that to use this action, + you must mount `/var/run/docker.sock:/var/run/docker.sock` and `/tmp:/tmp` into + the container so that the runner image can be built and doctest artifacts can + be found, respectively. + +inputs: + args: + description: > + Extra arguments to pass to `cargo 3ds test` + required: false + default: '' + +runs: + using: composite + steps: + - name: Build test-runner image + uses: docker/build-push-action@v2 + with: + tags: test-runner-3ds: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 }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04d0614..aa7ee03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,10 +9,6 @@ on: - main workflow_dispatch: -env: - # actions-rust-lang/setup-rust-toolchain sets some default RUSTFLAGS, which we don't want to use - RUSTFLAGS: "" - jobs: lint: strategy: @@ -34,8 +30,7 @@ jobs: run: cargo fmt --all --verbose -- --check - name: Run clippy - # We have to build the test crate here since it's not included in build-std by default - run: cargo 3ds clippy -Zbuild-std=std,test --color=always --verbose --all-targets + run: cargo 3ds clippy --color=always --verbose --all-targets test: strategy: @@ -47,7 +42,6 @@ jobs: continue-on-error: ${{ matrix.toolchain == 'nightly' }} runs-on: ubuntu-latest - container: devkitpro/devkitarm steps: - name: Checkout branch uses: actions/checkout@v3 @@ -56,29 +50,26 @@ jobs: with: toolchain: ${{ matrix.toolchain }} - - name: Build lib tests - run: cargo 3ds test --no-run --lib - - - name: Build integration tests - run: cargo 3ds test --no-run --test integration - - - name: Build doc tests - run: cargo 3ds test --no-run --doc - - - name: Run lib + integration tests - uses: ./.github/actions/citra + - name: Build and run tests (unit + integration) + uses: ./.github/actions/test + + - name: Build and run doc tests + # Let's still run doc tests even if lib/integration tests fail: + if: ${{ !cancelled() }} + env: + # 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 with: - executable: ./target/armv6k-nintendo-3ds/debug/deps/*.elf - - # TODO: run doc tests. We might be able to do something with e.g. - # cargo's "runner" configuration, but it seems we also need a test - # runtime and stuff for that to work. + args: --doc - name: Upload citra logs and capture videos uses: actions/upload-artifact@v3 - if: success() || failure() + # We always want to upload artifacts regardless of previous success/failure + if: ${{ !cancelled() }} with: name: citra-logs-${{ matrix.toolchain }} path: | - target/armv6k-nintendo-3ds/debug/deps/*.txt - target/armv6k-nintendo-3ds/debug/deps/*.webm + target/armv6k-nintendo-3ds/debug/**/*.txt + target/armv6k-nintendo-3ds/debug/**/*.webm