ci/check: move matrix output

This commit is contained in:
Matt Sturgeon 2025-05-27 15:45:15 +01:00
parent f77ecb989a
commit 0f0dca464e
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 40 additions and 37 deletions

View file

@ -27,7 +27,7 @@ jobs:
id: set-matrix id: set-matrix
run: | run: |
set -Eeu set -Eeu
matrix=$(nix eval --json .#githubActions.matrix) matrix=$(nix eval --json .#githubActions.checksMatrix)
echo "matrix=$matrix" >> "$GITHUB_OUTPUT" echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
build: build:
@ -37,8 +37,7 @@ jobs:
- prepare - prepare
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
include: ${{ fromJSON(needs.prepare.outputs.matrix) }}
secrets: inherit secrets: inherit
with: with:
systemAsName: true systemAsName: true

View file

@ -14,7 +14,7 @@
}; };
# Output a build matrix for CI # Output a build matrix for CI
flake.githubActions.matrix = flake.githubActions =
let let
systemsByPrio = [ systemsByPrio = [
"x86_64-linux" "x86_64-linux"
@ -41,38 +41,42 @@
) (throw "No supported system found!") systemsByPrio; ) (throw "No supported system found!") systemsByPrio;
in in
toGithubBuild system; toGithubBuild system;
checks = lib.pipe self.checks [
(lib.mapAttrsRecursiveCond (x: !lib.isDerivation x) (
loc: _: {
_type = "check";
build = toGithubBuild (builtins.head loc);
name = lib.attrsets.showAttrPath (builtins.tail loc);
}
))
(lib.collect (lib.isType "check"))
(lib.groupBy' (builds: x: builds ++ [ x.build ]) [ ] (x: x.name))
(lib.mapAttrsToList (name: builds: { inherit name builds; }))
# Only build one one system for non-test attrs
# TODO: this is very heavy handed, maybe we want some exceptions?
(map (
matrix:
matrix
// lib.optionalAttrs (!lib.strings.hasPrefix "test-" matrix.name) {
builds = [
(getPrimaryBuild matrix.builds)
];
}
))
# Inject per-system attr
(map (
matrix:
matrix
// {
builds = map (build: build // { attr = "checks.${build.system}.${matrix.name}"; }) matrix.builds;
}
))
];
in in
lib.pipe self.checks [ {
(lib.mapAttrsRecursiveCond (x: !lib.isDerivation x) ( checksMatrix.include = checks;
loc: _: { };
_type = "check";
build = toGithubBuild (builtins.head loc);
name = lib.attrsets.showAttrPath (builtins.tail loc);
}
))
(lib.collect (lib.isType "check"))
(lib.groupBy' (builds: x: builds ++ [ x.build ]) [ ] (x: x.name))
(lib.mapAttrsToList (name: builds: { inherit name builds; }))
# Only build one one system for non-test attrs
# TODO: this is very heavy handed, maybe we want some exceptions?
(map (
matrix:
matrix
// lib.optionalAttrs (!lib.strings.hasPrefix "test-" matrix.name) {
builds = [
(getPrimaryBuild matrix.builds)
];
}
))
# Inject per-system attr
(map (
matrix:
matrix
// {
builds = map (build: build // { attr = "checks.${build.system}.${matrix.name}"; }) matrix.builds;
}
))
];
} }