From 158e6a5924be034fe0f66003d6148074b68a1920 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Mon, 3 Apr 2023 13:12:40 -0400 Subject: [PATCH] Set up reusable workflow and add doctests --- .github/workflows/ci.yml | 50 +++++++++++++------------------------ .github/workflows/setup.yml | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/setup.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 102c704..fb4d218 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,10 +9,6 @@ on: - master workflow_dispatch: -env: - # https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html - CARGO_UNSTABLE_SPARSE_REGISTRY: "true" - jobs: lint: strategy: @@ -25,38 +21,10 @@ jobs: # But if latest nightly fails, allow the workflow to continue continue-on-error: ${{ matrix.toolchain == 'nightly' }} runs-on: ubuntu-latest - container: devkitpro/devkitarm steps: - # https://github.com/nektos/act/issues/917#issuecomment-1074421318 - - if: ${{ env.ACT }} - 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: Checkout branch - uses: actions/checkout@v2 - - - name: Setup default Rust toolchain - uses: actions-rs/toolchain@v1 + - uses: ./.github/workflows/setup.yml with: - components: clippy, rustfmt, rust-src - profile: minimal toolchain: ${{ matrix.toolchain }} - default: true - - - name: Install build tools for host - run: sudo apt-get update && sudo apt-get install -y build-essential - - - name: Install cargo-3ds - uses: actions-rs/cargo@v1 - with: - command: install - # TODO: this should probably just be a released version from crates.io - # once cargo-3ds gets published somewhere... - args: >- - --git https://github.com/rust3ds/cargo-3ds - --rev 7b70b6b26c4740b9a10ab85b832ee73c41142bbb - name: Check formatting run: cargo fmt --all --verbose -- --check @@ -68,5 +36,21 @@ jobs: # feature, but https://github.com/actions/runner/issues/2341 means we # can't have both that *and* colored output. + doctests: + strategy: + matrix: + toolchain: + - nightly-2023-01-13 + - nightly + continue-on-error: ${{ matrix.toolchain == 'nightly' }} + runs-on: ubuntu-latest + steps: + - uses: ./.github/workflows/setup.yml + with: + toolchain: ${{ matrix.toolchain }} + + - name: Build doc tests + run: cargo 3ds test --doc --verbose + # TODO: it would be nice to actually build 3dsx for examples/tests, etc. # and run it somehow, but exactly how remains to be seen. diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml new file mode 100644 index 0000000..bfdc8de --- /dev/null +++ b/.github/workflows/setup.yml @@ -0,0 +1,48 @@ +name: Setup + +on: + workflow_call: + inputs: + toolchain: + required: true + type: string + +env: + # https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html + CARGO_UNSTABLE_SPARSE_REGISTRY: "true" + +jobs: + setup: + runs-on: ubuntu-latest + container: devkitpro/devkitarm + steps: + # https://github.com/nektos/act/issues/917#issuecomment-1074421318 + - if: ${{ env.ACT }} + 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: Checkout branch + uses: actions/checkout@v2 + + - name: Setup default Rust toolchain + # Use this helper + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy, rustfmt, rust-src + toolchain: ${{ matrix.toolchain }} + + - name: Install build tools for host + run: sudo apt-get update && sudo apt-get install -y build-essential + + - name: Install cargo-3ds + uses: actions-rs/cargo@v1 + with: + command: install + # TODO: this should probably just be a released version from crates.io + # once cargo-3ds gets published somewhere... + # also switch to hash once feature/doctests gets merged + args: >- + --git https://github.com/rust3ds/cargo-3ds + --rev feature/doctests