diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..eba7c1e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + RUSTFLAGS: -D warnings + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - run: cargo test --all-targets + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all-targets -- -D warnings + + rustfmt: + name: Rust Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - run: cargo fmt --all --check + + rue: + name: Rue Format & Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - name: Install Rue + run: | + RUE_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Rue.toml) + cargo install rue-cli --version "$RUE_VERSION" --locked + - name: Check formatting + run: rue fmt --check + - name: Check compiled puzzles are up to date + run: | + rue build -a -s -x -h + git status --porcelain puzzles + test -z "$(git status --porcelain puzzles)" diff --git a/README.md b/README.md index 32c4ec3..280f814 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ The compiled puzzles are checked into the repository next to their sources (as ` rue build -a -s -x -h ``` -CI should run the same command followed by `git diff --exit-code puzzles` to ensure that the compiled puzzles are up to date. Then run the tests with: +CI runs the same command and fails if anything in `puzzles` changes, to ensure that the compiled puzzles are up to date. Then run the tests with: ```bash cargo test