Skip to content

Commit c44072f

Browse files
treewide: introduce hydra jobs (#1059)
2 parents e484357 + d84e2b2 commit c44072f

File tree

24 files changed

+440
-151
lines changed

24 files changed

+440
-151
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ jobs:
1313
- uses: actions/checkout@v3
1414
- uses: DeterminateSystems/nix-installer-action@main
1515
- uses: DeterminateSystems/magic-nix-cache-action@main
16-
- run: nix build -L .#checks.x86_64-linux.pytest-facts
17-
- run: nix build -L .#checks.x86_64-linux.perl-switches
18-
- run: nix build -L .#checks.x86_64-linux.openwrt-golden
19-
- run: nix build -L .#checks.x86_64-linux.formatting
20-
nix_builds:
16+
- run: nix flake check -L --allow-import-from-derivation
17+
# monitor and bind-master uses IFD
18+
nix_verify_scale_network:
2119
name: nix builds
2220
runs-on: ubuntu-latest
2321
steps:
2422
- uses: actions/checkout@v3
2523
- uses: DeterminateSystems/nix-installer-action@main
2624
- uses: DeterminateSystems/magic-nix-cache-action@main
27-
- run: nix build -L .#massflash
28-
- run: nix build -L .#scale-inventory
29-
- run: nix build -L .#serverspec
25+
- run: nix run .#verify-scale-network

.gitlab-ci.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,34 @@ stages:
66
- test
77
- build
88
- integ
9-
# Nix build all the things
109
nix-checks:
1110
tags:
1211
- nix
1312
stage: test
14-
# Takes more than 1 hr to build on gitlab shared runners
13+
timeout: 10 minutes
14+
script:
15+
- nix flake check -L --allow-import-from-derivation
16+
verify-scale-network:
17+
tags:
18+
- nix
19+
stage: test
20+
timeout: 20 minutes
21+
script:
22+
- nix run .#verify-scale-network
23+
verify-scale-tests:
24+
tags:
25+
- nix
26+
stage: test
27+
timeout: 20 minutes
28+
script:
29+
- nix run .#verify-scale-tests
30+
verify-scale-nixos-tests:
31+
tags:
32+
- nix
33+
stage: test
1534
timeout: 1 hour
1635
script:
17-
- nix flake check
36+
- nix run .#verify-scale-nixos-tests
1837
# This build takes a long time and should be done
1938
# outside of initial PR CI testing
2039
openwrt-ar71xx-build:

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
devShells = import ./nix/dev-shells inputs;
2323
formatter = import ./nix/formatter inputs;
2424
formatterModule = import ./nix/formatterModule inputs;
25+
hydraJobs = import ./nix/hydra-jobs inputs;
2526
legacyPackages = import ./nix/legacy-packages inputs;
27+
legacyPackagesTests = import ./nix/legacy-packages/tests.nix inputs;
2628
library = import ./nix/library inputs;
2729
mixosConfigurations = import ./nix/mixos-configurations inputs;
2830
nixosConfigurations = import ./nix/nixos-configurations inputs;

nix/checks/default.nix

Lines changed: 1 addition & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
inputs:
22
let
3-
# inherits
3+
44
inherit (inputs.nixpkgs-lib)
55
lib
66
;
@@ -9,117 +9,8 @@ let
99
mapAttrs
1010
;
1111

12-
inherit (lib.fileset)
13-
toSource
14-
unions
15-
;
16-
17-
# sources
18-
19-
# Used for derivations where facts is the primary directory.
20-
factsSrc = toSource {
21-
root = ../..;
22-
fileset = unions [
23-
../../facts
24-
../../switch-configuration
25-
];
26-
};
27-
28-
# Used for derivations where switch-configuration is the primary directory.
29-
switchConfigurationSrc = toSource {
30-
root = ../..;
31-
fileset = unions [
32-
../../facts
33-
../../switch-configuration
34-
];
35-
};
36-
37-
# Used for derivations where openwrt is the primary directory.
38-
openwrtSrc = toSource {
39-
root = ../..;
40-
fileset = unions [
41-
../../facts
42-
../../openwrt
43-
../../tests
44-
];
45-
};
4612
in
4713
mapAttrs (system: pkgs: {
48-
core = pkgs.testers.runNixOSTest (import ./core.nix { inherit inputs lib; });
49-
routers = pkgs.testers.runNixOSTest (import ./routers.nix { inherit inputs; });
50-
router-border = pkgs.testers.runNixOSTest (import ./router-border.nix { inherit inputs lib; });
51-
loghost = pkgs.testers.runNixOSTest (import ./loghost.nix { inherit inputs; });
52-
monitor = pkgs.testers.runNixOSTest (import ./monitor.nix { inherit inputs; });
53-
wasgeht = pkgs.testers.runNixOSTest (import ./wasgeht.nix { inherit inputs; });
54-
55-
pytest-facts =
56-
let
57-
testPython = (
58-
pkgs.python3.withPackages (
59-
pythonPackages: with pythonPackages; [
60-
pylint
61-
pytest
62-
jinja2
63-
pandas
64-
]
65-
)
66-
);
67-
in
68-
(pkgs.runCommand "pytest-facts"
69-
{
70-
src = factsSrc;
71-
buildInputs = [ testPython ];
72-
}
73-
''
74-
cd $src/facts
75-
pylint --persistent n *.py
76-
pytest -vv -p no:cacheprovider
77-
touch $out
78-
''
79-
);
80-
81-
perl-switches = pkgs.stdenv.mkDerivation (finalAttrs: {
82-
pname = "perl-switches";
83-
version = "0.1.0";
84-
85-
src = switchConfigurationSrc;
86-
87-
nativeBuildInputs = with pkgs; [
88-
gnumake
89-
perl
90-
];
91-
92-
buildPhase = ''
93-
cd switch-configuration
94-
make .lint
95-
make .build-switch-configs
96-
'';
97-
98-
installPhase = ''
99-
touch $out
100-
'';
101-
});
102-
103-
openwrt-golden = pkgs.stdenv.mkDerivation (finalAttrs: {
104-
pname = "openwrt-golden";
105-
version = "0.1.0";
106-
107-
src = openwrtSrc;
108-
109-
buildInputs = [
110-
pkgs.diffutils
111-
pkgs.gomplate
112-
];
113-
114-
buildPhase = ''
115-
cd tests/unit/openwrt
116-
mkdir -p $out/tmp/ath79
117-
'';
118-
119-
installPhase = ''
120-
./test.sh -t ath79 -o $out
121-
'';
122-
});
12314

12415
formatting = inputs.self.formatterModule.${system}.config.build.check inputs.self;
12516

nix/hydra-jobs/default.nix

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
inputs:
2+
3+
let
4+
5+
inherit (inputs.nixpkgs-lib)
6+
lib
7+
;
8+
9+
inherit (lib.attrsets)
10+
filterAttrs
11+
updateManyAttrsByPath
12+
;
13+
14+
inherit (lib.lists)
15+
init
16+
last
17+
map
18+
;
19+
20+
inherit (lib.trivial)
21+
pipe
22+
;
23+
24+
inherit (inputs.self)
25+
legacyPackages
26+
legacyPackagesTests
27+
library
28+
;
29+
30+
inherit (library.systems)
31+
defaultSystems
32+
;
33+
34+
inherit (library.attrsets)
35+
removeDirectoriesRecursiveAttrs
36+
;
37+
38+
removeByPath =
39+
pathList: set:
40+
updateManyAttrsByPath [
41+
{
42+
path = init pathList;
43+
update = old: filterAttrs (n: v: n != (last pathList)) old;
44+
}
45+
] set;
46+
47+
in
48+
49+
{
50+
51+
scale-network =
52+
pipe
53+
(defaultSystems (system: removeDirectoriesRecursiveAttrs legacyPackages.${system}.scale-network))
54+
(
55+
map removeByPath [
56+
[
57+
"aarch64-darwin"
58+
"dhcptest"
59+
]
60+
[
61+
"aarch64-darwin"
62+
"isc-dhcp"
63+
]
64+
[
65+
"aarch64-linux"
66+
"dhcptest"
67+
]
68+
[
69+
"x86_64-darwin"
70+
"dhcptest"
71+
]
72+
[
73+
"x86_64-darwin"
74+
"isc-dhcp"
75+
]
76+
]
77+
);
78+
79+
scale-tests = defaultSystems (
80+
system: removeDirectoriesRecursiveAttrs legacyPackagesTests.${system}.scale-tests
81+
);
82+
83+
scale-nixos-tests =
84+
pipe
85+
(defaultSystems (
86+
system: removeDirectoriesRecursiveAttrs legacyPackagesTests.${system}.scale-nixos-tests
87+
))
88+
(
89+
map removeByPath [
90+
[
91+
"aarch64-darwin"
92+
"core"
93+
]
94+
[
95+
"aarch64-linux"
96+
"core"
97+
]
98+
[
99+
"x86_64-darwin"
100+
"core"
101+
]
102+
]
103+
);
104+
105+
}

nix/legacy-packages/default.nix

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
inputs:
2-
inputs.nixpkgs-lib.lib.genAttrs
3-
[
4-
"aarch64-darwin"
5-
"aarch64-linux"
6-
"x86_64-darwin"
7-
"x86_64-linux"
8-
]
9-
(
10-
system:
11-
import inputs.nixpkgs {
12-
inherit system;
13-
overlays = [ inputs.self.overlays.default ];
14-
}
15-
)
2+
inputs.self.library.systems.defaultSystems (
3+
system:
4+
import inputs.nixpkgs {
5+
inherit system;
6+
overlays = [ inputs.self.overlays.default ];
7+
}
8+
)

nix/legacy-packages/tests.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
inputs:
2+
inputs.self.library.systems.defaultSystems (
3+
system:
4+
import inputs.nixpkgs {
5+
inherit system;
6+
overlays = [
7+
inputs.self.overlays.default
8+
inputs.self.overlays.scale-tests
9+
];
10+
}
11+
)

nix/library/default.nix

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ let
1010
inherit (lib.attrsets)
1111
attrNames
1212
filterAttrs
13+
genAttrs
1314
mapAttrs'
1415
nameValuePair
1516
;
@@ -40,6 +41,29 @@ let
4041
in
4142
fix (finalLibrary: {
4243

44+
systems = {
45+
46+
defaultSystems = genAttrs [
47+
"x86_64-linux"
48+
"aarch64-linux"
49+
"x86_64-darwin"
50+
"aarch64-darwin"
51+
];
52+
53+
};
54+
55+
attrsets = {
56+
57+
removeDirectoriesRecursiveAttrs = flip removeAttrs [
58+
"callPackage"
59+
"newScope"
60+
"overrideScope"
61+
"packages"
62+
"recurseForDerivations"
63+
];
64+
65+
};
66+
4367
path = fix (finalPath: {
4468

4569
/**

0 commit comments

Comments
 (0)