name: Build

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

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
          fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          override: true
          components: rustfmt, clippy
      - name: Lint (fmt)
        run: cargo fmt --check
      - name: Lint (clippy)
        run: cargo clippy -- -D warnings
      - name: Install cargo-hack
        run: cargo install cargo-hack
      - name: Test (feature power-set)
        run: cargo hack test --feature-powerset
