Skip to content

Commit

Permalink
Split CI jobs into GHC versions
Browse files Browse the repository at this point in the history
  • Loading branch information
turion committed Feb 8, 2025
1 parent 93b5619 commit f212210
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 36 deletions.
59 changes: 24 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,33 @@ jobs:
- name: Cabal bench
run: cabal bench all

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
- name: Generate versions
id: generate-versions
run: |
echo -n "versions=" >> "$GITHUB_OUTPUT"
nix eval .#supportedGhcs --json >> "$GITHUB_OUTPUT"
build-flake:
name: Nix Flake
needs: generate-flake-ghc-matrix
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
version: ${{ fromJSON(needs.generate-flake-ghc-matrix.outputs.versions) }}
fail-fast: false # So the cache is still filled
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Free disk space
run: |
if [ "$(uname --kernel-name)" = "Linux" ]; then
sudo rm -rf /usr/local/* /usr/share/* /opt/*
docker rmi $(docker image ls -aq)
fi
- uses: cachix/install-nix-action@v30
- uses: DeterminateSystems/magic-nix-cache-action@v8
- uses: cachix/cachix-action@v15
Expand All @@ -132,35 +143,13 @@ jobs:
- name: Flake check
run: nix flake check
- name: Build all packages
run: nix build --accept-flake-config

build-devshell:
name: Nix Flake Develop
needs:
- generateMatrix
- build-flake
strategy:
matrix: ${{ fromJSON(needs.generateMatrix.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Free disk space
run: |
if [ "$(uname --kernel-name)" = "Linux" ]; then
sudo rm -rf /usr/local/* /usr/share/* /opt/*
docker rmi $(docker image ls -aq)
fi
- uses: cachix/install-nix-action@v30
- uses: DeterminateSystems/magic-nix-cache-action@v8
- uses: cachix/cachix-action@v15
with:
name: rhine
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Run tests
run: nix build .#${{ matrix.version }} --accept-flake-config
- run: nix develop .#${{ matrix.version }} --accept-flake-config -c cabal update
- run: nix develop .#${{ matrix.version }} --accept-flake-config -c cabal test
- name: Check whether .nix files are formatted
run: |
ghc="ghc$(echo ${{ matrix.ghc }} | tr -d '.')" # Removes the dot from the ghc version and prepends "ghc"
nix develop .#${ghc} --accept-flake-config -c cabal update
nix develop .#${ghc} --accept-flake-config -c cabal test all
nix fmt
git diff --exit-code
cabal-check:
name: Check and format all cabal files
Expand Down
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
# Usage: nix build
packages = forAllPlatforms (system: pkgs: {
default = pkgs.rhine-all;
});
} // lib.mapAttrs (ghcVersion: haskellPackages: pkgs.linkFarm "rhine-all-${ghcVersion}" (lib.genAttrs pnames (pname: haskellPackages.${pname}))) (hpsFor pkgs));

# We re-export the entire nixpkgs package set with our overlay.
# Usage examples:
Expand All @@ -206,5 +206,7 @@
]);
})
(hpsFor pkgs));

inherit supportedGhcs;
};
}

0 comments on commit f212210

Please sign in to comment.