Skip to content

Commit

Permalink
Set up reusable workflow and add doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-h-chamberlain committed Apr 3, 2023
1 parent 474cb2e commit 158e6a5
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 33 deletions.
50 changes: 17 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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.
48 changes: 48 additions & 0 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 158e6a5

Please sign in to comment.