name: CI

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

jobs:
  build:

    runs-on: ubuntu-22.04

    strategy:
      matrix:
        toolchain:
          - stable
          - "1.65"

    steps:
      - uses: actions/checkout@v3

      - name: Install Rust ${{ matrix.toolchain }}
        run: |
          rustup toolchain install ${{ matrix.toolchain }} --component rustfmt,clippy --target wasm32-unknown-unknown
          rustup default ${{ matrix.toolchain }}

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

      - name: Check
        run: |
          cargo check --release

      - name: Test
        run: |
          cargo test --release --features time

      - name: Install binstall
        run: |
          curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash

      - name: Install cargo-all-features
        run: |
          cargo binstall -y cargo-all-features

      - name: Check all features
        run: |
          cargo check-all-features
