diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d37d46..7751f86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,45 +1,79 @@ +# Adapted from https://github.com/bevyengine/bevy_github_ci_template name: CI on: - pull_request: - branches: [master] push: branches: [master] + pull_request: + branches: [master] env: CARGO_TERM_COLOR: always jobs: - - build: - strategy: - matrix: - toolchain: [stable, nightly] - os: [windows-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} + # Run cargo test + test: + name: Test Suite + runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@master + - name: Checkout sources + uses: actions/checkout@v4 + - name: Cache + uses: actions/cache@v4 with: - toolchain: ${{ matrix.toolchain }} - components: rustfmt, clippy - - name: fmt - if: ${{ matrix.toolchain == 'nightly' && runner.os == 'linux' }} - run: cargo fmt --all -- --check - - - name: Install alsa and udev + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@stable + - name: Install Dependencies run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - if: runner.os == 'linux' - - - name: lint - uses: actions-rs/clippy-check@v1 + - name: Run cargo test + run: cargo test + + # Run cargo clippy -- -D warnings + clippy_check: + name: Clippy + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.toml') }} + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@stable with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-targets --all-features -- -D warnings -A unknown-lints + components: clippy + - name: Install Dependencies + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev + - name: Run clippy + run: cargo clippy -- -D warnings - - name: Build & run tests - run: cargo test --workspace - env: - CARGO_INCREMENTAL: 0 - RUSTFLAGS: "-C debuginfo=0 -D warnings" + # Run cargo fmt --all -- --check + format: + name: Format + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@nightly # Unstable formatter options used. + with: + components: rustfmt + - name: Run cargo fmt + run: cargo fmt --all -- --check