From 0f0dca464e1326d573439c9a00ff9e6842049df9 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Tue, 27 May 2025 15:45:15 +0100 Subject: [PATCH] ci/check: move matrix output --- .github/workflows/check.yml | 5 ++- flake/dev/tests.nix | 72 +++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index d0b5053e..8d51d912 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -27,7 +27,7 @@ jobs: id: set-matrix run: | set -Eeu - matrix=$(nix eval --json .#githubActions.matrix) + matrix=$(nix eval --json .#githubActions.checksMatrix) echo "matrix=$matrix" >> "$GITHUB_OUTPUT" build: @@ -37,8 +37,7 @@ jobs: - prepare strategy: fail-fast: false - matrix: - include: ${{ fromJSON(needs.prepare.outputs.matrix) }} + matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} secrets: inherit with: systemAsName: true diff --git a/flake/dev/tests.nix b/flake/dev/tests.nix index 19ea383f..a09d0090 100644 --- a/flake/dev/tests.nix +++ b/flake/dev/tests.nix @@ -14,7 +14,7 @@ }; # Output a build matrix for CI - flake.githubActions.matrix = + flake.githubActions = let systemsByPrio = [ "x86_64-linux" @@ -41,38 +41,42 @@ ) (throw "No supported system found!") systemsByPrio; in 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 - 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; - } - )) - ]; + { + checksMatrix.include = checks; + }; }