diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ed14c54 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,91 @@ +name: CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true + +env: + # Reduce compile time and cache size. + RUSTFLAGS: -Dwarnings -Zshare-generics=y -Zthreads=0 + RUSTDOCFLAGS: -Dwarnings -Zshare-generics=y -Zthreads=0 + # Use the same Rust toolchain across jobs so they can share a cache. + toolchain: nightly-2025-04-03 + +jobs: + # Check formatting. + format: + name: Format + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.toolchain }} + components: rustfmt + + - name: Check formatting + run: cargo fmt --all -- --check + + # Run Clippy lints. + clippy-lints: + name: Clippy lints + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.toolchain }} + components: clippy + + - name: Restore Rust cache + id: cache + uses: Swatinem/rust-cache@v2 + with: + shared-key: ci + save-if: ${{ github.ref == 'refs/heads/main' }} + + - name: Install build dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev + + - name: Run Clippy lints + run: cargo clippy --locked --all-targets --all-features + + # Run Bevy lints. + bevy-lints: + name: Bevy lints + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain (plus bevy_lint) + uses: TheBevyFlock/bevy_cli/bevy_lint@lint-v0.3.0 + + - name: Restore Rust cache + id: cache + uses: Swatinem/rust-cache@v2 + with: + shared-key: ci + save-if: false + + - name: Install build dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev + + - name: Run Bevy lints + run: bevy_lint --locked --all-targets --all-features \ No newline at end of file