mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-24 15:01:56 +03:00
db35339b1e
So far, /examples was the only place with packages that are built in the CI pipeline. This change allows us to add package build tests to individual modules at the location where the module is defined. This has several benefits: - We are not forced to add unnecessary examples in order to maintain test coverage - When modules get removed, their tests will be removed alongside - It allows us to keep old modules around and assure they keep working without having to keep outdated examples in /examples
45 lines
1.1 KiB
Nix
45 lines
1.1 KiB
Nix
{
|
|
self,
|
|
lib,
|
|
...
|
|
}: {
|
|
perSystem = {
|
|
self',
|
|
pkgs,
|
|
...
|
|
}: let
|
|
modules = self.modules.dream2nix;
|
|
modulesWithTests =
|
|
lib.filterAttrs
|
|
(_: module: lib.pathExists (module + /tests/packages))
|
|
modules;
|
|
getPackagePaths = moduleName: modulePath:
|
|
lib.concatMapAttrs
|
|
(packageDir: _: {
|
|
"module-${moduleName}-${packageDir}" = "${modulePath}/tests/packages/${packageDir}";
|
|
})
|
|
(builtins.readDir (modulePath + /tests/packages));
|
|
makePackage = testModulePath: let
|
|
evaled = lib.evalModules {
|
|
specialArgs = {
|
|
dream2nix.modules = self.modules;
|
|
packageSets.nixpkgs = pkgs;
|
|
};
|
|
modules = [
|
|
testModulePath
|
|
{
|
|
paths.projectRoot = testModulePath;
|
|
paths.package = testModulePath;
|
|
}
|
|
];
|
|
};
|
|
in
|
|
evaled.config.public;
|
|
packagesToBuild =
|
|
lib.concatMapAttrs getPackagePaths modulesWithTests;
|
|
packagesBuilt = lib.mapAttrs (_: makePackage) packagesToBuild;
|
|
in {
|
|
checks = self'.packages // packagesBuilt;
|
|
};
|
|
}
|