name: ci

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

env:
  CARGO_TERM_COLOR: always

jobs:
  format:
    name: Check code formatting
    runs-on: ubuntu-22.04
    steps:
    - name: Checkout repository
      uses: actions/checkout@v3
    - name: Install Rust
      uses: dtolnay/rust-toolchain@984d158d699777abbaa79de23de3134e60c187fa # stable branch
    - name: Run cargo fmt
      run: |
        cargo fmt --all -- --check

  build:
    runs-on: ubuntu-22.04
    steps:
    - uses: actions/checkout@v3
    - name: Install Rust
      uses: dtolnay/rust-toolchain@984d158d699777abbaa79de23de3134e60c187fa # stable branch
    - name: Build
      run: cargo build --release --locked
    - name: Run tests
      run: cargo test --release --locked
