Skip to content

Add flake.nix and test on CI #71

Add flake.nix and test on CI

Add flake.nix and test on CI #71

Workflow file for this run

on: [pull_request]
name: build
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# Always keep in sync with the tested-with section in the cabal file
ghc: ['8.4.4', '8.6.5', '8.8.4', '8.10.7', '9.0.2', '9.2.2', '9.4.2', '9.6.6', '9.8.1', '9.10.1', '9.12.1']
name: Haskell GHC ${{ matrix.ghc }} cabal
env:
cabal_project_freeze: cabal.project.${{ matrix.ghc }}.freeze
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/setup@v2
id: setup-haskell-build
with:
ghc-version: ${{ matrix.ghc }}
- name: Cache Cabal build artifacts
uses: actions/cache@v4
with:
path: |
${{ steps.setup-haskell-build.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-cabal-${{ matrix.ghc }}-${{ hashFiles(env.cabal_project_freeze) }}
restore-keys: |
${{ runner.os }}-cabal-${{ matrix.ghc }}
- name: Cabal build dependencies
run: |
cabal build all --enable-tests --only-dependencies --project-file=cabal.project.${{ matrix.ghc }}
- name: Cabal build packages
run: |
cabal build all --enable-tests --project-file=cabal.project.${{ matrix.ghc }}
- name: Cabal test
run: |
cabal test all --enable-tests --test-show-details=Always --project-file=cabal.project.${{ matrix.ghc }}
generate-flake-ghc-matrix:
name: Generate GHC versions for nix flake build matrix
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.generate-versions.outputs.versions }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Generate versions
id: generate-versions
run: |
echo -n "versions=" >> "$GITHUB_OUTPUT"
nix eval .#supportedGhcs --json >> "$GITHUB_OUTPUT"
check-flake:
name: Check Flake
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: nix flake check
- name: Check whether .nix files are formatted
run: |
nix fmt
git diff --exit-code
build-flake:
name: Nix Flake
needs:
- generate-flake-ghc-matrix
strategy:
matrix:
version: ${{ fromJSON(needs.generate-flake-ghc-matrix.outputs.versions) }}
os:
- ubuntu-latest
- macos-latest
fail-fast: false # So the cache is still filled
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: nix build .#${{ matrix.version }}
- run: nix develop .#${{ matrix.version }} -c cabal update
- run: nix develop .#${{ matrix.version }} -c cabal test