mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-11 18:32:23 +08:00
ci/eval: add rebuildsByPlatform to the comparison result
This commit is contained in:
@@ -3,55 +3,101 @@ rec {
|
||||
# Borrowed from https://github.com/NixOS/nixpkgs/pull/355616
|
||||
uniqueStrings = list: builtins.attrNames (builtins.groupBy lib.id list);
|
||||
|
||||
_processSystemPath =
|
||||
packageSystemPath:
|
||||
/*
|
||||
Converts a `packagePlatformPath` into a `packagePlatformAttr`
|
||||
|
||||
Turns
|
||||
"hello.aarch64-linux"
|
||||
into
|
||||
{
|
||||
name = "hello";
|
||||
platform = "aarch64-linux";
|
||||
}
|
||||
*/
|
||||
convertToPackagePlatformAttr =
|
||||
packagePlatformPath:
|
||||
let
|
||||
# python312Packages.torch.aarch64-linux -> ["python312Packages" "torch" "aarch64-linux"]
|
||||
# splittedPath = lib.splitString "." attrName;
|
||||
splittedPath = lib.splitString "." packageSystemPath;
|
||||
# python312Packages.numpy.aarch64-linux -> ["python312Packages" "numpy" "aarch64-linux"]
|
||||
splittedPath = lib.splitString "." packagePlatformPath;
|
||||
|
||||
# ["python312Packages" "torch" "aarch64-linux"] -> ["python312Packages" "torch"]
|
||||
# ["python312Packages" "numpy" "aarch64-linux"] -> ["python312Packages" "numpy"]
|
||||
packagePath = lib.sublist 0 (lib.length splittedPath - 1) splittedPath;
|
||||
in
|
||||
{
|
||||
# "python312Packages.torch"
|
||||
|
||||
# "python312Packages.numpy"
|
||||
name = lib.concatStringsSep "." packagePath;
|
||||
in
|
||||
if name == "" then
|
||||
null
|
||||
else
|
||||
{
|
||||
# python312Packages.numpy
|
||||
inherit name;
|
||||
|
||||
# "aarch64-linux"
|
||||
system = lib.last splittedPath;
|
||||
};
|
||||
# "aarch64-linux"
|
||||
platform = lib.last splittedPath;
|
||||
};
|
||||
|
||||
# Turns
|
||||
# [
|
||||
# "hello.aarch64-linux"
|
||||
# "hello.x86_64-linux"
|
||||
# "hello.aarch64-darwin"
|
||||
# "hello.x86_64-darwin"
|
||||
# "bye.x86_64-darwin"
|
||||
# "bye.aarch64-darwin"
|
||||
# ]
|
||||
#
|
||||
# into
|
||||
#
|
||||
# [
|
||||
# "hello"
|
||||
# "bye"
|
||||
# ]
|
||||
/*
|
||||
Converts a list of `packagePlatformPath`s into a list of `packagePlatformAttr`s
|
||||
|
||||
Turns
|
||||
[
|
||||
"hello.aarch64-linux"
|
||||
"hello.x86_64-linux"
|
||||
"hello.aarch64-darwin"
|
||||
"hello.x86_64-darwin"
|
||||
"bye.x86_64-darwin"
|
||||
"bye.aarch64-darwin"
|
||||
"release-checks" <- Will be dropped
|
||||
]
|
||||
into
|
||||
[
|
||||
{ name = "hello"; platform = "aarch64-linux"; }
|
||||
{ name = "hello"; platform = "x86_64-linux"; }
|
||||
{ name = "hello"; platform = "aarch64-darwin"; }
|
||||
{ name = "hello"; platform = "x86_64-darwin"; }
|
||||
{ name = "bye"; platform = "aarch64-darwin"; }
|
||||
{ name = "bye"; platform = "x86_64-darwin"; }
|
||||
]
|
||||
*/
|
||||
convertToPackagePlatformAttrs =
|
||||
packagePlatformPaths:
|
||||
builtins.filter (x: x != null) (builtins.map convertToPackagePlatformAttr packagePlatformPaths);
|
||||
|
||||
/*
|
||||
Converts a list of `packagePlatformPath`s directly to a list of (unique) package names
|
||||
|
||||
Turns
|
||||
[
|
||||
"hello.aarch64-linux"
|
||||
"hello.x86_64-linux"
|
||||
"hello.aarch64-darwin"
|
||||
"hello.x86_64-darwin"
|
||||
"bye.x86_64-darwin"
|
||||
"bye.aarch64-darwin"
|
||||
]
|
||||
into
|
||||
[
|
||||
"hello"
|
||||
"bye"
|
||||
]
|
||||
*/
|
||||
extractPackageNames =
|
||||
packageSystemPaths:
|
||||
builtins.attrNames (
|
||||
builtins.removeAttrs (builtins.groupBy (
|
||||
packageSystemPath: (_processSystemPath packageSystemPath).name
|
||||
) packageSystemPaths) [ "" ]
|
||||
);
|
||||
packagePlatformPaths:
|
||||
let
|
||||
packagePlatformAttrs = convertToPackagePlatformAttrs (uniqueStrings packagePlatformPaths);
|
||||
in
|
||||
uniqueStrings (builtins.map (p: p.name) packagePlatformAttrs);
|
||||
|
||||
# Computes a diff between two attrs
|
||||
# {
|
||||
# added: [ <keys only in the second object> ],
|
||||
# removed: [ <keys only in the first object> ],
|
||||
# changed: [ <keys with different values between the two objects> ],
|
||||
# }
|
||||
#
|
||||
/*
|
||||
Computes the key difference between two attrs
|
||||
|
||||
{
|
||||
added: [ <keys only in the second object> ],
|
||||
removed: [ <keys only in the first object> ],
|
||||
changed: [ <keys with different values between the two objects> ],
|
||||
}
|
||||
*/
|
||||
diff =
|
||||
let
|
||||
filterKeys = cond: attrs: lib.attrNames (lib.filterAttrs cond attrs);
|
||||
@@ -69,43 +115,78 @@ rec {
|
||||
) old;
|
||||
};
|
||||
|
||||
/*
|
||||
Group a list of `packagePlatformAttr`s by platforms
|
||||
|
||||
Turns
|
||||
[
|
||||
{ name = "hello"; platform = "aarch64-linux"; }
|
||||
{ name = "hello"; platform = "x86_64-linux"; }
|
||||
{ name = "hello"; platform = "aarch64-darwin"; }
|
||||
{ name = "hello"; platform = "x86_64-darwin"; }
|
||||
{ name = "bye"; platform = "aarch64-darwin"; }
|
||||
{ name = "bye"; platform = "x86_64-darwin"; }
|
||||
]
|
||||
into
|
||||
{
|
||||
aarch64-linux = [ "hello" ];
|
||||
x86_64-linux = [ "hello" ];
|
||||
aarch64-darwin = [ "hello" "bye" ];
|
||||
x86_64-darwin = [ "hello" "bye" ];
|
||||
}
|
||||
*/
|
||||
groupByPlatform =
|
||||
packagePlatformAttrs:
|
||||
let
|
||||
packagePlatformAttrsByPlatform = builtins.groupBy (p: p.platform) packagePlatformAttrs;
|
||||
extractPackageNames = map (p: p.name);
|
||||
in
|
||||
lib.mapAttrs (_: extractPackageNames) packagePlatformAttrsByPlatform;
|
||||
|
||||
# Turns
|
||||
# [
|
||||
# "hello.aarch64-linux"
|
||||
# "hello.x86_64-linux"
|
||||
# "hello.aarch64-darwin"
|
||||
# "hello.x86_64-darwin"
|
||||
# "bye.x86_64-darwin"
|
||||
# "bye.aarch64-darwin"
|
||||
# { name = "hello"; platform = "aarch64-linux"; }
|
||||
# { name = "hello"; platform = "x86_64-linux"; }
|
||||
# { name = "hello"; platform = "aarch64-darwin"; }
|
||||
# { name = "hello"; platform = "x86_64-darwin"; }
|
||||
# { name = "bye"; platform = "aarch64-darwin"; }
|
||||
# { name = "bye"; platform = "x86_64-darwin"; }
|
||||
# ]
|
||||
#
|
||||
# into
|
||||
#
|
||||
# {
|
||||
# linux = [
|
||||
# "hello"
|
||||
# ];
|
||||
# darwin = [
|
||||
# "hello"
|
||||
# "bye"
|
||||
# ];
|
||||
# linux = [ "hello" ];
|
||||
# darwin = [ "hello" "bye" ];
|
||||
# }
|
||||
groupByKernel =
|
||||
systemPaths:
|
||||
packagePlatformAttrs:
|
||||
let
|
||||
systemPaths' = builtins.map _processSystemPath systemPaths;
|
||||
|
||||
filterKernel =
|
||||
kernel:
|
||||
builtins.attrNames (
|
||||
builtins.groupBy (systemPath: systemPath.name) (
|
||||
builtins.filter (systemPath: lib.hasSuffix kernel systemPath.system) systemPaths'
|
||||
builtins.groupBy (p: p.name) (
|
||||
builtins.filter (p: lib.hasSuffix kernel p.platform) packagePlatformAttrs
|
||||
)
|
||||
);
|
||||
in
|
||||
lib.genAttrs [ "linux" "darwin" ] filterKernel;
|
||||
|
||||
getLabels = lib.mapAttrs (
|
||||
/*
|
||||
Maps an attrs of `kernel - rebuild counts` mappings to a list of labels
|
||||
|
||||
Turns
|
||||
{
|
||||
linux = 56;
|
||||
darwin = 8;
|
||||
}
|
||||
into
|
||||
[
|
||||
"10.rebuild-darwin: 1-10"
|
||||
"10.rebuild-linux: 11-100"
|
||||
]
|
||||
*/
|
||||
getLabels = lib.mapAttrsToList (
|
||||
kernel: rebuildCount:
|
||||
let
|
||||
number =
|
||||
|
||||
Reference in New Issue
Block a user