Merge pull request #5 from adisbladis/meta-fields

Add full meta to output
This commit is contained in:
Jörg Thalheim 2021-08-24 06:01:58 +01:00 committed by GitHub
commit 273b761919
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 34 deletions

View file

@ -16,7 +16,9 @@
defaultPackage = self.packages.${system}.hydra-eval-jobs; defaultPackage = self.packages.${system}.hydra-eval-jobs;
devShell = defaultPackage.overrideAttrs (old: { devShell = defaultPackage.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ nativeBuildInputs = old.nativeBuildInputs ++ [
pkgs.python3.pkgs.pytest (pkgs.python3.withPackages(ps: [
ps.pytest
]))
]; ];
}); });
}); });

View file

@ -17,6 +17,8 @@
#include <nix/derivations.hh> #include <nix/derivations.hh>
#include <nix/local-fs-store.hh> #include <nix/local-fs-store.hh>
#include <nix/value-to-json.hh>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/resource.h> #include <sys/resource.h>
@ -98,31 +100,6 @@ struct MyArgs : MixEvalArgs, MixCommonArgs
static MyArgs myArgs; static MyArgs myArgs;
static std::string queryMetaStrings(EvalState & state, DrvInfo & drv, const string & name, const string & subAttribute)
{
Strings res;
std::function<void(Value & v)> rec;
rec = [&](Value & v) {
state.forceValue(v);
if (v.type() == nString)
res.push_back(v.string.s);
else if (v.isList())
for (unsigned int n = 0; n < v.listSize(); ++n)
rec(*v.listElems()[n]);
else if (v.type() == nAttrs) {
auto a = v.attrs->find(state.symbols.create(subAttribute));
if (a != v.attrs->end())
res.push_back(state.forceString(*a->value));
}
};
Value * v = drv.queryMeta(name);
if (v) rec(*v);
return concatStringsSep(", ", res);
}
static nlohmann::json serializeStorePathSet(StorePathSet &paths, LocalFSStore &store) { static nlohmann::json serializeStorePathSet(StorePathSet &paths, LocalFSStore &store) {
auto array = nlohmann::json::array(); auto array = nlohmann::json::array();
for (auto & p : paths) { for (auto & p : paths) {
@ -208,14 +185,16 @@ static void worker(
job["nixName"] = drv->queryName(); job["nixName"] = drv->queryName();
job["system"] =drv->querySystem(); job["system"] =drv->querySystem();
job["drvPath"] = drvPath; job["drvPath"] = drvPath;
job["description"] = drv->queryMetaString("description");
job["license"] = queryMetaStrings(state, *drv, "license", "shortName"); nlohmann::json meta;
job["homepage"] = drv->queryMetaString("homepage"); for (auto & name : drv->queryMetaNames()) {
job["maintainers"] = queryMetaStrings(state, *drv, "maintainers", "email"); PathSet context;
job["schedulingPriority"] = drv->queryMetaInt("schedulingPriority", 100); std::stringstream ss;
job["timeout"] = drv->queryMetaInt("timeout", 36000); printValueAsJSON(state, true, *drv->queryMeta(name), ss, context);
job["maxSilent"] = drv->queryMetaInt("maxSilent", 7200); nlohmann::json field = nlohmann::json::parse(ss.str());
job["isChannel"] = drv->queryMetaBool("isHydraChannel", false); meta[name] = field;
}
job["meta"] = meta;
/* If this is an aggregate, then get its constituents. */ /* If this is an aggregate, then get its constituents. */
auto a = v->attrs->get(state.symbols.create("_hydraAggregate")); auto a = v->attrs->get(state.symbols.create("_hydraAggregate"));