mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-09 00:09:55 +00:00
Add formatting, linting, and testing to CI checks (#44)
This PR adds `cargo fmt -- --check`, `nx lint ...` and `nx test ...` as GitHub Actions. This will cause future PRs to automatically fail when formatting issues, Clippy warnings, or test failures are present in the changed code.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
name: Run formatter, linter and tests
|
||||
on:
|
||||
merge_group:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
rustfmt:
|
||||
timeout-minutes: 5
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Check Rust formatting
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
lint-and-test:
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
max-parallel: 1
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
target/
|
||||
key: ${{ runner.os }}-cargo-lint-and-test-${{ hashFiles('**/Cargo.toml') }}
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Install Linux dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
libasound2-dev \
|
||||
libudev-dev \
|
||||
git
|
||||
- name: Install JS dependencies
|
||||
run: npm ci
|
||||
- name: Ensure unambiguous `main`
|
||||
if: github.ref != 'refs/heads/main'
|
||||
run: |
|
||||
git remote set-branches origin main
|
||||
git fetch --depth 1 origin main
|
||||
git branch main origin/main
|
||||
- name: Run Nx-configured `lint` and `test` targets
|
||||
run: npx nx affected -t lint test --base=main --head=HEAD
|
||||
Reference in New Issue
Block a user