name: CI

on:
    pull_request: {}
    push:
        branches:
            - main

permissions:
    contents: read

jobs:
    lint:
        name: Lint
        runs-on: ubuntu-latest

        env:
            RUSTFLAGS: '-Dwarnings'

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

            - name: Set up Rust toolchain
              uses: actions-rust-lang/setup-rust-toolchain@v1
              with:
                  components: clippy, rustfmt
                  target: wasm32-unknown-unknown

            - name: Install Cargo Binary Install
              uses: cargo-bins/cargo-binstall@main

            - name: Install crates
              run: cargo binstall -y --force cargo-deny cargo-machete cargo-sort

            - name: Lint
              run: cargo clippy --all-features --locked

            - name: Check dependencies
              run: cargo deny check

            - name: Check unused dependencies
              run: cargo machete

            - name: Check manifest formatting
              run: cargo sort --workspace --check

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

    # This repository has no tests, so save some time by skipping test builds for all components.
    # test:
    #     name: Test
    #     runs-on: ubuntu-latest

    #     steps:
    #         - name: Checkout
    #           uses: actions/checkout@v5

    #         - name: Set up Rust toolchain
    #           uses: actions-rust-lang/setup-rust-toolchain@v1
    #           with:
    #               components: clippy, rustfmt
    #               target: wasm32-unknown-unknown

    #         - name: Test
    #           run: cargo test --all-features --locked --release
