Skip to content

Commit

Permalink
Actions: Enable MacOS runner, split checks across jobs (#34)
Browse files Browse the repository at this point in the history
* enable macos

* automatically generate github matrix

* compact ghc checks to reduce number of GHA jobs

* add back the magic cache action

* collapse nodejs checks into fewer jobs
  • Loading branch information
chris-martin authored May 30, 2024
1 parent 2aa5738 commit 94f2808
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 82 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@ on:
pull_request:

jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
matrix="$(nix eval --accept-flake-config --json './main#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
check:
needs: nix-matrix
strategy:
matrix:
runner:
- ubuntu-latest-4-cores
runs-on: ${{ matrix.runner }}
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
runs-on: ${{ matrix.os }}
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: DeterminateSystems/magic-nix-cache-action@v6
- uses: cachix/cachix-action@v14
with:
name: freckle
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Check
run: nix flake check --accept-flake-config ./main
run: nix build --accept-flake-config --print-build-logs --keep-going "./main#${{ matrix.attr }}"
21 changes: 21 additions & 0 deletions main/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions main/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
nixpkgs-unstable-2023-10-21.url = "github:nixos/nixpkgs/038b2922be3fc096e1d456f93f7d0f4090628729";
nixpkgs-unstable-2024-02-20.url = "github:nixos/nixpkgs/b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa";
flake-utils.url = "github:numtide/flake-utils";
nix-github-actions.url = "github:nix-community/nix-github-actions";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs-stable";
};
outputs = inputs:
(inputs.flake-utils.lib.eachDefaultSystem (system:
Expand All @@ -22,6 +24,14 @@
})
) // {
nixosModules = import ./nixos-modules.nix { inherit inputs; };
githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
checks =
inputs.nixpkgs-stable.lib.getAttrs [
"x86_64-linux"
"x86_64-darwin"
]
inputs.self.checks;
};
};
nixConfig = {
extra-substituters = [
Expand Down
78 changes: 29 additions & 49 deletions main/ghc/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,40 @@ let
inherit (nixpkgs.lib.attrsets) recursiveUpdate;
inherit (nixpkgs.testers) testEqualContents;

ghcVersionCheck = version: package: testEqualContents {
assertion = "ghc is version ${version}";
expected = writeText "expected" ("The Glorious Glasgow Haskell Compilation System, version " + version + "\n");
actual = runCommand "actual" { nativeBuildInputs = [ package ]; } ''
ghc --version > $out
ghcCheck = { packageName, ghc, weeder, hls }: testEqualContents {
assertion = "versions for ${packageName}";
expected = writeText "expected" ''
The Glorious Glasgow Haskell Compilation System, version ${ghc}
weeder version ${weeder}
haskell-language-server version: ${hls}
'';
};

weederVersionCheck = version: package: testEqualContents {
assertion = "ghc is version ${version}";
expected = writeText "expected" ("weeder version " + version + "\n");
actual = runCommand "actual" { nativeBuildInputs = [ package ]; } ''
weeder --version | head -n1 > $out
'';
};

hlsVersionCheck = version: package: testEqualContents {
assertion = "haskell-language-server is version ${version}";
expected = writeText "expected" ("haskell-language-server version: " + version + "\n");
actual = runCommand "actual" { nativeBuildInputs = [ package ]; } ''
actual = runCommand "actual"
{
nativeBuildInputs = [
(lib.haskellBundle {
ghcVersion = packageName;
enableHLS = true;
})
];
} ''
touch $out
ghc --version >> $out
weeder --version | head -n1 >> $out
haskell-language-server-wrapper --version | head -n1 \
| sed -re 's#^(haskell-language-server version: [[:digit:]\.]+).*$#\1#' \
> $out
>> $out
'';
};

in
{
ghc-9-2-7 = ghcVersionCheck "9.2.7" packages.ghc-9-2-7;
ghc-9-2-8 = ghcVersionCheck "9.2.8" packages.ghc-9-2-8;
ghc-9-4-5 = ghcVersionCheck "9.4.5" packages.ghc-9-4-5;
ghc-9-4-6 = ghcVersionCheck "9.4.6" packages.ghc-9-4-6;
ghc-9-4-7 = ghcVersionCheck "9.4.7" packages.ghc-9-4-7;
ghc-9-4-8 = ghcVersionCheck "9.4.8" packages.ghc-9-4-8;
ghc-9-6-3 = ghcVersionCheck "9.6.3" packages.ghc-9-6-3;
ghc-9-6-4 = ghcVersionCheck "9.6.4" packages.ghc-9-6-4;
ghc-9-6-5 = ghcVersionCheck "9.6.5" packages.ghc-9-6-5;

weeder-for-ghc-9-2-7 = weederVersionCheck "2.4.1" packages.ghc-9-2-7;
weeder-for-ghc-9-2-8 = weederVersionCheck "2.4.1" packages.ghc-9-2-8;
weeder-for-ghc-9-4-5 = weederVersionCheck "2.7.0" packages.ghc-9-4-5;
weeder-for-ghc-9-4-6 = weederVersionCheck "2.7.0" packages.ghc-9-4-6;
weeder-for-ghc-9-4-7 = weederVersionCheck "2.7.0" packages.ghc-9-4-7;
weeder-for-ghc-9-4-8 = weederVersionCheck "2.7.0" packages.ghc-9-4-8;
weeder-for-ghc-9-6-3 = weederVersionCheck "2.7.0" packages.ghc-9-6-3;
weeder-for-ghc-9-6-4 = weederVersionCheck "2.8.0" packages.ghc-9-6-4;
weeder-for-ghc-9-6-5 = weederVersionCheck "2.8.0" packages.ghc-9-6-5;

hls-for-ghc-9-2-7 = hlsVersionCheck "1.10.0.0" (lib.haskellBundle { ghcVersion = "ghc-9-2-7"; enableHLS = true; });
hls-for-ghc-9-2-8 = hlsVersionCheck "2.4.0.0" (lib.haskellBundle { ghcVersion = "ghc-9-2-8"; enableHLS = true; });
hls-for-ghc-9-4-5 = hlsVersionCheck "2.4.0.0" (lib.haskellBundle { ghcVersion = "ghc-9-4-5"; enableHLS = true; });
hls-for-ghc-9-4-6 = hlsVersionCheck "2.4.0.0" (lib.haskellBundle { ghcVersion = "ghc-9-4-6"; enableHLS = true; });
hls-for-ghc-9-4-7 = hlsVersionCheck "2.4.0.0" (lib.haskellBundle { ghcVersion = "ghc-9-4-7"; enableHLS = true; });
hls-for-ghc-9-4-8 = hlsVersionCheck "2.4.0.0" (lib.haskellBundle { ghcVersion = "ghc-9-4-8"; enableHLS = true; });
hls-for-ghc-9-6-3 = hlsVersionCheck "2.4.0.0" (lib.haskellBundle { ghcVersion = "ghc-9-6-3"; enableHLS = true; });
hls-for-ghc-9-6-4 = hlsVersionCheck "2.7.0.0" (lib.haskellBundle { ghcVersion = "ghc-9-6-4"; enableHLS = true; });
hls-for-ghc-9-6-5 = hlsVersionCheck "2.7.0.0" (lib.haskellBundle { ghcVersion = "ghc-9-6-5"; enableHLS = true; });
ghc-9-2-7 = ghcCheck { packageName = "ghc-9-2-7"; ghc = "9.2.7"; weeder = "2.4.1"; hls = "1.10.0.0"; };
ghc-9-2-8 = ghcCheck { packageName = "ghc-9-2-8"; ghc = "9.2.8"; weeder = "2.4.1"; hls = "2.4.0.0"; };
ghc-9-4-5 = ghcCheck { packageName = "ghc-9-4-5"; ghc = "9.4.5"; weeder = "2.7.0"; hls = "2.4.0.0"; };
ghc-9-4-6 = ghcCheck { packageName = "ghc-9-4-6"; ghc = "9.4.6"; weeder = "2.7.0"; hls = "2.4.0.0"; };
ghc-9-4-7 = ghcCheck { packageName = "ghc-9-4-7"; ghc = "9.4.7"; weeder = "2.7.0"; hls = "2.4.0.0"; };
ghc-9-4-8 = ghcCheck { packageName = "ghc-9-4-8"; ghc = "9.4.8"; weeder = "2.7.0"; hls = "2.4.0.0"; };
ghc-9-6-3 = ghcCheck { packageName = "ghc-9-6-3"; ghc = "9.6.3"; weeder = "2.7.0"; hls = "2.4.0.0"; };
ghc-9-6-4 = ghcCheck { packageName = "ghc-9-6-4"; ghc = "9.6.4"; weeder = "2.8.0"; hls = "2.7.0.0"; };
ghc-9-6-5 = ghcCheck { packageName = "ghc-9-6-5"; ghc = "9.6.5"; weeder = "2.8.0"; hls = "2.7.0.0"; };
}
60 changes: 32 additions & 28 deletions main/nodejs/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,30 @@ let
inherit (nixpkgs.lib.attrsets) recursiveUpdate;
inherit (nixpkgs.testers) testEqualContents;

checkNodejsVersion = version: package: testEqualContents {
assertion = "nodejs is version ${version}";
expected = writeText "expected" ("v" + version + "\n");
actual = runCommand "actual" { nativeBuildInputs = [ package ]; } "node --version > $out";
nodeCheck = { packageName, node, yarn, pnpm }: testEqualContents {
assertion = "versions for ${packageName}";
expected = writeText "expected" ''
node v${node}
yarn ${yarn}
pnpm ${pnpm}
'';
actual = runCommand "actual"
{
nativeBuildInputs = [
packages.${packageName}
];
} ''
touch $out
echo -n "node " >> $out
node --version >> $out
echo -n "yarn " >> $out
yarn --version >> $out
echo -n "pnpm " >> $out
pnpm --version >> $out
'';
};

checkYarnVersion = version: package: testEqualContents {
Expand All @@ -20,32 +40,16 @@ let
checkPnpmVersion = version: package: testEqualContents {
assertion = "pnpm is version ${version}";
expected = writeText "expected" (version + "\n");
actual = runCommand "actual" { nativeBuildInputs = [ package ]; } "pnpm --version > $out";
actual = runCommand "actual" { nativeBuildInputs = [ package ]; } "";
};

in
{
nodejs-16-20-0-version = checkNodejsVersion "16.20.0" packages.nodejs-16-20-0;
nodejs-16-20-1-version = checkNodejsVersion "16.20.1" packages.nodejs-16-20-1;
nodejs-16-20-2-version = checkNodejsVersion "16.20.2" packages.nodejs-16-20-2;
nodejs-18-17-1-version = checkNodejsVersion "18.17.1" packages.nodejs-18-17-1;
nodejs-18-18-0-version = checkNodejsVersion "18.18.0" packages.nodejs-18-18-0;
nodejs-20-11-0-version = checkNodejsVersion "20.11.0" packages.nodejs-20-11-0;
nodejs-20-11-1-version = checkNodejsVersion "20.11.1" packages.nodejs-20-11-1;

nodejs-16-20-0-yarn-version = checkYarnVersion "1.22.19" packages.nodejs-16-20-0;
nodejs-16-20-1-yarn-version = checkYarnVersion "1.22.19" packages.nodejs-16-20-1;
nodejs-16-20-2-yarn-version = checkYarnVersion "1.22.19" packages.nodejs-16-20-2;
nodejs-18-17-1-yarn-version = checkYarnVersion "1.22.19" packages.nodejs-18-17-1;
nodejs-18-18-0-yarn-version = checkYarnVersion "1.22.19" packages.nodejs-18-18-0;
nodejs-20-11-0-yarn-version = checkYarnVersion "1.22.19" packages.nodejs-20-11-0;
nodejs-20-11-1-yarn-version = checkYarnVersion "1.22.19" packages.nodejs-20-11-1;

nodejs-16-20-0-pnpm-version = checkPnpmVersion "8.4.0" packages.nodejs-16-20-0;
nodejs-16-20-1-pnpm-version = checkPnpmVersion "8.5.1" packages.nodejs-16-20-1;
nodejs-16-20-2-pnpm-version = checkPnpmVersion "8.5.1" packages.nodejs-16-20-2;
nodejs-18-17-1-pnpm-version = checkPnpmVersion "8.6.12" packages.nodejs-18-17-1;
nodejs-18-18-0-pnpm-version = checkPnpmVersion "8.8.0" packages.nodejs-18-18-0;
nodejs-20-11-0-pnpm-version = checkPnpmVersion "8.14.0" packages.nodejs-20-11-0;
nodejs-20-11-1-pnpm-version = checkPnpmVersion "8.15.1" packages.nodejs-20-11-1;
nodejs-16-20-0 = nodeCheck { packageName = "nodejs-16-20-0"; node = "16.20.0"; yarn = "1.22.19"; pnpm = "8.4.0"; };
nodejs-16-20-1 = nodeCheck { packageName = "nodejs-16-20-1"; node = "16.20.1"; yarn = "1.22.19"; pnpm = "8.5.1"; };
nodejs-16-20-2 = nodeCheck { packageName = "nodejs-16-20-2"; node = "16.20.2"; yarn = "1.22.19"; pnpm = "8.5.1"; };
nodejs-18-17-1 = nodeCheck { packageName = "nodejs-18-17-1"; node = "18.17.1"; yarn = "1.22.19"; pnpm = "8.6.12"; };
nodejs-18-18-0 = nodeCheck { packageName = "nodejs-18-18-0"; node = "18.18.0"; yarn = "1.22.19"; pnpm = "8.8.0"; };
nodejs-20-11-0 = nodeCheck { packageName = "nodejs-20-11-0"; node = "20.11.0"; yarn = "1.22.19"; pnpm = "8.14.0"; };
nodejs-20-11-1 = nodeCheck { packageName = "nodejs-20-11-1"; node = "20.11.1"; yarn = "1.22.19"; pnpm = "8.15.1"; };
}

0 comments on commit 94f2808

Please sign in to comment.