Skip to content

Commit

Permalink
ci: fixes multi-system testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
SEIAROTg committed Nov 28, 2024
1 parent 2c51d07 commit 3850687
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:

- run: >
nix flake check
--keep-going
--override-input quadlet-nix "path:$(pwd)"
--override-input nixpkgs 'github:NixOS/nixpkgs/${{ matrix.version.nixpkgs }}'
--override-input home-manager 'github:nix-community/home-manager/${{ matrix.version.home-manager }}'
--override-input test-config "path:$(pwd)/tests/${{ matrix.system }}"
./tests
2 changes: 2 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ nix flake check \
--override-input quadlet-nix "path:$(pwd)" \
--override-input nixpkgs 'github:NixOS/nixpkgs/nixos-unstable' \
--override-input home-manager 'github:nix-community/home-manager/master' \
--override-input test-config "path:$(pwd)/tests/x86_64-linux" \
./tests
```

Expand All @@ -17,5 +18,6 @@ nix run \
--override-input quadlet-nix "path:$(pwd)" \
--override-input nixpkgs 'github:NixOS/nixpkgs/nixos-unstable' \
--override-input home-manager 'github:nix-community/home-manager/master' \
--override-input test-config "path:$(pwd)/tests/x86_64-linux" \
'./tests#checks.x86_64-linux.basic-rootful.driver'
```
5 changes: 5 additions & 0 deletions tests/aarch64-linux/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
outputs = _: {
system = "aarch64-linux";
};
}
39 changes: 21 additions & 18 deletions tests/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@

home-manager.url = "path:/dev/null";
home-manager.inputs.nixpkgs.follows = "nixpkgs";

test-config.url = "path:/dev/null";
};

outputs =
{ nixpkgs, nixpkgs-2405, home-manager, quadlet-nix, ... }: let
{ test-config, nixpkgs, nixpkgs-2405, home-manager, quadlet-nix, ... }: let
system = test-config.system;
makeTestScript = { user, testScript }: { nodes, ... }: ''
import json
from typing import Any, Optional
Expand Down Expand Up @@ -115,22 +118,20 @@

in {
checks = let
systems = [ "x86_64-linux" "aarch64-linux" ];
genTests = system: let
pkgs = import nixpkgs { inherit system; };
genRootfulTest = genTest pkgs runRootfulTest;
sdSwitchBugAffected = let
version = pkgs.sd-switch.version;
in builtins.compareVersions version "0.5.0" >= 0;
sdSwitchBugOverlay = final: prev: {
sd-switch = (import nixpkgs-2405 { inherit system; }).sd-switch;
};
rootlessPkgs = if !sdSwitchBugAffected then pkgs else import nixpkgs {
inherit system;
overlays = [ sdSwitchBugOverlay ];
};
genRootlessTest = genTest rootlessPkgs runRootlessTest;
in builtins.listToAttrs [
pkgs = import nixpkgs { inherit system; };
genRootfulTest = genTest pkgs runRootfulTest;
sdSwitchBugAffected = let
version = pkgs.sd-switch.version;
in builtins.compareVersions version "0.5.0" >= 0;
sdSwitchBugOverlay = final: prev: {
sd-switch = (import nixpkgs-2405 { inherit system; }).sd-switch;
};
rootlessPkgs = if !sdSwitchBugAffected then pkgs else import nixpkgs {
inherit system;
overlays = [ sdSwitchBugOverlay ];
};
genRootlessTest = genTest rootlessPkgs runRootlessTest;
tests = builtins.listToAttrs [
(genRootfulTest ./basic.nix)
(genRootlessTest ./basic.nix)
(genRootfulTest ./container.nix)
Expand All @@ -142,6 +143,8 @@
(genRootfulTest ./switch.nix)
(genRootlessTest ./switch.nix)
];
in builtins.listToAttrs (map (system: { name = system; value = genTests system; }) systems);
in {
"${system}" = tests;
};
};
}
5 changes: 5 additions & 0 deletions tests/x86_64-linux/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
outputs = _: {
system = "x86_64-linux";
};
}

0 comments on commit 3850687

Please sign in to comment.