name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.93.0"
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.93.0"
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --all-targets
check:
name: Check
if: always()
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- name: All jobs passed
run: |
if [[ "${{ needs.lint.result }}" != "success" ]]; then
echo "Lint failed"
exit 1
fi
if [[ "${{ needs.test.result }}" != "success" ]]; then
echo "Test failed"
exit 1
fi
echo "All checks passed"