name: CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable
          components: rustfmt, clippy

      - name: Check format
        run: cargo fmt --all -- --check

      - name: Run clippy
        run: cargo clippy --all -- -D warnings

      - name: Build
        run: cargo build --verbose

      - name: Build release
        run: cargo build --release --verbose

      - name: Run tests
        run: cargo test --verbose

      - name: Run tests (release)
        run: cargo test --release --verbose

      - name: Run examples
        run: |
          cargo run --example mpvss_all
          cargo run --example mpvss_sub
