photonic 0.1.1

Dynamic light controller and animator
Documentation
name: Check and build

on: [ "push", "pull_request" ]

env:
  CARGO_TERM_COLOR: always

permissions:
  id-token: "write"
  contents: "read"

jobs:
  prepare:
    runs-on: ubuntu-latest
    steps:
      - name: git checkout
        uses: actions/checkout@v5

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@main

      - name: Check Nix inputs
        uses: DeterminateSystems/flake-checker-action@main
        with:
          fail-mode: true

      - name: Load environment
        run: |
          nix develop --command \
              echo "All fine"

  check:
    needs: [ "prepare" ]
    runs-on: ubuntu-latest
    steps:
      - name: git checkout
        uses: actions/checkout@v5

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@main

      - name: Check Nix inputs
        uses: DeterminateSystems/flake-checker-action@main
        with:
          fail-mode: true

      - name: Setup rust cache
        uses: actions/cache@v4
        with:
          key: cargo-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            cargo-${{ runner.os }}-build-${{ env.cache-name }}-
            cargo-${{ runner.os }}-build-
            cargo-${{ runner.os }}-
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/

      - name: Check Formatting
        run: |
          nix develop --command \
              cargo fmt --all -- --check

      - name: Check Clippy
        run: |
          nix develop --command \
              cargo clippy

      - name: Check dependency usage
        run: |
          nix develop --command \
              cargo machete

      - name: Audit rust dependencies
        run: |
          nix develop --command \
              cargo deny check

  build:
    runs-on: ubuntu-latest
    needs: [ "check" ]
    steps:
      - uses: actions/checkout@v5

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@main

      - name: Setup rust cache
        uses: actions/cache@v4
        with:
          key: cargo-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            cargo-${{ runner.os }}-build-${{ env.cache-name }}-
            cargo-${{ runner.os }}-build-
            cargo-${{ runner.os }}-
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/

      - name: Build
        run: |
          nix develop --command \
              cargo build --all --verbose

      - name: Run tests
        run: |
          nix develop --command \
              cargo test --all --verbose

      - name: Run miri
        run: |
          nix develop --command \
              cargo miri test
        env:
          MIRIFLAGS: -Zmiri-strict-provenance

  package:
    runs-on: ubuntu-latest
    needs: [ "check" ]
    steps:
      - uses: actions/checkout@v5

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@main

      - name: Build package
        run: |
          nix build .#photonic