name: Run tests

on:
  push:
    branches: [main]
  pull_request:

jobs:
  build:

    runs-on: docker

    steps:
    - uses: actions/checkout@v2
    - name: Install Rust toolchain
      uses: https://codeberg.org/wackbyte/rust-toolchain@trunk
      with:
        toolchain: stable
        components: rustfmt, clippy
    - name: Check formatting
      run: cargo fmt --check
    - name: Clippy
      run: cargo clippy -- -D warnings
    - name: Build default (AES)
      run: cargo build --verbose
    - name: Build explicit AES
      run: cargo build --verbose --no-default-features --features aes
    - name: Build explicit OpenSSL
      run: cargo build --verbose --no-default-features --features openssl
    - name: Run default tests (AES)
      run: cargo test --verbose
    - name: Run explicit AES tests
      run: cargo test --verbose --no-default-features --features aes
    - name: Run explicit OpenSSL tests
      run: cargo test --verbose --no-default-features --features openssl

  msrv:

    runs-on: docker

    steps:
    - uses: actions/checkout@v2
    - name: Install MSRV toolchain
      uses: https://codeberg.org/wackbyte/rust-toolchain@trunk
      with:
        toolchain: "1.85"
    - name: Build default (AES) with MSRV
      run: cargo build --verbose
    - name: Build explicit OpenSSL with MSRV
      run: cargo build --verbose --no-default-features --features openssl
