add test for aggregated fetching: github source

This commit is contained in:
DavHau 2021-11-17 17:40:09 +07:00
parent e99487cee9
commit 4cf80a1460
5 changed files with 111 additions and 37 deletions

View File

@ -61,6 +61,8 @@ rec {
listDirs = path: lib.attrNames (lib.filterAttrs (n: v: v == "directory") (builtins.readDir path));
toDrv = path: runCommand "some-drv" {} "cp -r ${path} $out";
# directory names of a given directory
dirNames = dir: lib.attrNames (lib.filterAttrs (name: type: type == "directory") (builtins.readDir dir));

View File

@ -5,45 +5,17 @@
}:
let
lib = pkgs.lib // builtins;
l = pkgs.lib // builtins;
makeTest =
{
name,
source,
cmds,
}:
let
outputs = dream2nix.riseAndShine {
inherit source;
};
commandsToRun = cmds outputs;
in
pkgs.runCommand "test-${name}" {}
(lib.concatStringsSep "\n" commandsToRun);
projects = {
prettier = {
source = lib.fetchTarball {
url = "https://github.com/prettier/prettier/tarball/2.4.1";
sha256 = "19b37qakhlsnr2n5bgv83aih5npgzbad1d2p2rs3zbq5syqbxdyi";
};
cmds = outputs:
let
prettier = outputs.defaultPackage.overrideAttrs (old: {
dontBuild = true;
});
in
[
"${prettier}/bin/prettier --version | grep -q 2.4.1 && mkdir $out"
];
};
buildProjectsTests = import ./projects.nix {
inherit lib pkgs dream2nix;
};
allTests =
lib.mapAttrs
(name: args: makeTest (args // { inherit name; }))
projects;
otherTests = import ./other {
inherit lib pkgs dream2nix;
};
in
allTests
buildProjectsTests
//
otherTests

View File

@ -0,0 +1,21 @@
{
lib ? pkgs.lib,
pkgs ? import <nixpkgs> {},
dream2nix ? import ./src { inherit pkgs; },
}:
let
l = pkgs.lib // builtins;
fetchAggrgatedGithub =
dream2nix.utils.toDrv
(dream2nix.fetchSources {
dreamLock = ./prettier.json;
}).fetchedSources.prettier."2.4.1";
in
{
inherit fetchAggrgatedGithub;
}

View File

@ -0,0 +1,30 @@
{
"_generic": {
"mainPackageName": "prettier",
"mainPackageVersion": "2.4.1",
"sourcesAggregatedHash": "sha256-AR5QtVJE15NCLJpjWdg6UxhIEwFGsCAne5TI3DcOMeI=",
"subsystem": "nodejs",
"translatedBy": "nodejs.pure.yarn-lock",
"translator": "yarn-lock",
"translatorParams": ""
},
"_subsystem": {
"nodejsVersion": "14"
},
"cyclicDependencies": {},
"dependencies": {
"prettier": {
"2.4.1": []
}
},
"sources": {
"prettier": {
"2.4.1": {
"owner": "prettier",
"repo": "prettier",
"rev": "2.4.1",
"type": "github"
}
}
}
}

49
tests/pure/projects.nix Normal file
View File

@ -0,0 +1,49 @@
{
lib ? pkgs.lib,
pkgs ? import <nixpkgs> {},
dream2nix ? import ./src { inherit pkgs; },
}:
let
lib = pkgs.lib // builtins;
makeTest =
{
name,
source,
cmds,
}:
let
outputs = dream2nix.riseAndShine {
inherit source;
};
commandsToRun = cmds outputs;
in
pkgs.runCommand "test-${name}" {}
(lib.concatStringsSep "\n" commandsToRun);
projects = {
prettier = {
source = lib.fetchTarball {
url = "https://github.com/prettier/prettier/tarball/2.4.1";
sha256 = "19b37qakhlsnr2n5bgv83aih5npgzbad1d2p2rs3zbq5syqbxdyi";
};
cmds = outputs:
let
prettier = outputs.defaultPackage.overrideAttrs (old: {
dontBuild = true;
});
in
[
"${prettier}/bin/prettier --version | grep -q 2.4.1 && mkdir $out"
];
};
};
allTests =
lib.mapAttrs
(name: args: makeTest (args // { inherit name; }))
projects;
in
allTests