cmprss 0.4.0

A compression multi-tool for the command line.
name: Nix

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

jobs:
  # Architecture-independent lints and formatting. Run once on x86_64.
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@7993355175c2765e5733dae74f3e0786fe0e5c4f # v12
      - name: Nix Cache
        uses: DeterminateSystems/magic-nix-cache-action@b46e247b898aa56e6d2d2e728dc6df6c84fdb738 # v7

      - name: Format
        run: nix build .#fmt

      - name: Format non-Rust
        run: nix build .#checks.x86_64-linux.treefmt

      - name: Deny (audit + licenses + bans)
        run: nix build .#deny

      - name: Clippy
        run: nix build .#clippy

      - name: Build docs
        run: nix build .#doc

  # Build and test on each supported architecture.
  build:
    name: Build (${{ matrix.arch }})
    runs-on: ${{ matrix.runner }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - runner: ubuntu-latest
            arch: x86_64
          - runner: ubuntu-24.04-arm
            arch: aarch64
    steps:
      - name: Checkout
        uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@7993355175c2765e5733dae74f3e0786fe0e5c4f # v12
      - name: Nix Cache
        uses: DeterminateSystems/magic-nix-cache-action@b46e247b898aa56e6d2d2e728dc6df6c84fdb738 # v7

      - name: Test
        run: nix build .#test

      - name: Build cmprss
        run: nix build .#cmprss

      - name: Build static musl binary
        run: nix build .#cmprss-static

        # Run any nix checks that aren't covered by the above
        # This should evaluate the nix expression and then do nothing
      - name: Forgotten checks
        run: nix flake check

  # Run this separately since
  #   1) it uses a separate set of deps, so no shared cache with the other build
  #   2) failures here shouldn't block merging
  coverage:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Checkout
        uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@7993355175c2765e5733dae74f3e0786fe0e5c4f # v12
      - name: Nix Cache
        uses: DeterminateSystems/magic-nix-cache-action@b46e247b898aa56e6d2d2e728dc6df6c84fdb738 # v7

      - name: Build Coverage
        # Build and ensure the output is linked in result/
        run: nix build -L .#coverage

      # Upload code coverage
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          file: ./result/lcov.info