Skip to content

Commit

Permalink
Migrate integration tests to flake-parts
Browse files Browse the repository at this point in the history
Well, actually also to fix them.
  • Loading branch information
zhaofengli committed Aug 26, 2024
1 parent 44b01e6 commit cf6f76d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 35 deletions.
35 changes: 0 additions & 35 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

inherit (inputs.nixpkgs) lib;

makeCranePkgs = pkgs: let
craneLib = inputs.crane.mkLib pkgs;
in pkgs.callPackage ./crane.nix { inherit craneLib; };

modules = builtins.foldl' (acc: f: f acc) ./flake [
builtins.readDir
(lib.filterAttrs (name: type:
Expand All @@ -46,36 +42,5 @@
systems = supportedSystems;

debug = true;

# old flake
flake = inputs.flake-utils.lib.eachSystem supportedSystems (system: let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [];
};
cranePkgs = makeCranePkgs pkgs;


pkgsStable = import inputs.nixpkgs-stable {
inherit system;
overlays = [];
};
cranePkgsStable = makeCranePkgs pkgsStable;

inherit (pkgs) lib;
in rec {
checks = let
makeIntegrationTests = pkgs: import ./integration-tests {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
flake = self;
};
unstableTests = makeIntegrationTests pkgs;
stableTests = lib.mapAttrs' (name: lib.nameValuePair "stable-${name}") (makeIntegrationTests pkgsStable);
in lib.optionalAttrs pkgs.stdenv.isLinux (unstableTests // stableTests);
}) // {
};
};
}
47 changes: 47 additions & 0 deletions flake/integration-tests.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ lib, flake-parts-lib, inputs, self, ... }:
let
inherit (lib)
mkOption
types
;
inherit (flake-parts-lib)
mkPerSystemOption
;
in
{
options = {
perSystem = mkPerSystemOption {
options.attic.integration-tests = {
nixpkgsArgs = mkOption {
type = types.attrsOf types.anything;
default = {};
};
};
};
};

config = {
perSystem = { self', pkgs, config, system, ... }: let
cfg = config.attic.integration-tests;
in {
checks = let
vmPkgs = import inputs.nixpkgs ({
inherit system;
overlays = [ self.overlays.default ];
} // cfg.nixpkgsArgs);
vmPkgsStable = import inputs.nixpkgs-stable ({
inherit system;
overlays = [ self.overlays.default ];
} // cfg.nixpkgsArgs);

makeIntegrationTests = pkgs: import ../integration-tests {
inherit pkgs;
flake = self;
};

unstableTests = makeIntegrationTests vmPkgs;
stableTests = lib.mapAttrs' (name: lib.nameValuePair "stable-${name}") (makeIntegrationTests vmPkgsStable);
in lib.optionalAttrs pkgs.stdenv.isLinux (unstableTests // stableTests);
};
};
}

0 comments on commit cf6f76d

Please sign in to comment.