---
name: CI

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  library:
    name: Library
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
      - uses: DeterminateSystems/nix-installer-action@v22

      - name: Clippy
        run: |
          set -x
          nix develop --command cargo clippy -- -Dwarnings

      - name: Tests
        run: |
          set -x
          nix develop --command cargo test

      - name: Build
        run: |
          set -x
          nix develop --command cargo build

  examples:
    name: Examples
    runs-on: ubuntu-latest
    needs:
      - library

    strategy:
      matrix:
        example:
          - pi-pico-hexpansion-devkit

    steps:
      - uses: actions/checkout@v6
      - uses: DeterminateSystems/nix-installer-action@v22

      - name: Build
        run: |
          set -x
          cd ./examples/${{ matrix.example }}
          nix develop --command cargo build --release
