name: CI

on:
  push:
    branches: [ main ]
  pull_request:

jobs:
  checks:
    name: Cargo checks
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4

      - name: Sync Rustup toolchain
        run: rustup show

      - name: Run cargo fmt
        run: cargo fmt --all -- --check

      - name: Run cargo clippy
        run: cargo clippy --all-features --all-targets --workspace --locked -- --deny warnings

  tests:
    name: Run tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4

      - name: Sync Rustup toolchain
        run: rustup show

      - name: Run cargo test
        run: cargo test --all-features --all-targets --workspace --locked

  test-docker-build:
    name: Verify docker image can build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Sources
        uses: actions/checkout@v4

      - name: Build Image
        run: |
          docker build .
