---
name: CI

on:
  # Run the worflow for all pull requests.
  pull_request:

  # Only run the workflow for pushes to the default branch.
  push:
    branches:
      - main

  # Allow the workflow to be triggered manually from the Actions tab.
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  # Run style checks.
  lint:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 1

      - uses: pre-commit/action@v3.0.1
        env:
          SKIP: no-commit-to-branch

  # Build the project.
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 1

      - name: Build
        run: cargo build --verbose

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