Skip to content

Commit 259dd10

Browse files
committed
feat: add section for unsupported packages to report
1 parent 511c89f commit 259dd10

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

.github/workflows/review.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ jobs:
134134
with:
135135
sparse-checkout: |
136136
.github/actions
137+
drv-build-support.nix
137138
flake.lock
138139
flake.nix
139140
generate_markdown_report.py
@@ -181,6 +182,27 @@ jobs:
181182
182183
report_json=~/.cache/nixpkgs-review/pr-${PR_NUMBER}/report.json
183184
report_md=~/.cache/nixpkgs-review/pr-${PR_NUMBER}/report.md
185+
186+
if failed=$(jq -er '.result[].failed[]' "$report_json"); then
187+
git fetch origin "$MERGE" && git switch -d "$MERGE"
188+
tmp=$(mktemp -d)
189+
nix config show --json > "$tmp/nix-config.json"
190+
nix derivation show --recursive -f. $failed > "$tmp/drv-graph.json"
191+
nix-instantiate --eval --strict --json ../drv-build-support.nix \
192+
--argstr configPath "$tmp/nix-config.json" \
193+
--argstr drvGraphPath "$tmp/drv-graph.json" \
194+
> "$tmp/drv-build-support.json"
195+
196+
for pkg in $failed; do
197+
drvPath=$(nix eval -f. "${pkg}.drvPath" --raw)
198+
drv=$(basename "$drvPath")
199+
supported=$(jq '.[$drv].supported' "$tmp/drv-build-support.json" --arg drv "$drv")
200+
if [[ "$supported" = "false" ]]; then
201+
jq '.result[].failed -= [$pkg] | .result[].unsupported += [$pkg]' --arg pkg "$pkg" "$report_json" | sponge "$report_json"
202+
fi
203+
done
204+
fi
205+
184206
if failed=$(jq -er '.result[].failed[]' "$report_json"); then
185207
git fetch origin "$BASE" && git switch -d "$BASE"
186208
build=()
@@ -210,6 +232,7 @@ jobs:
210232
PR_JSON: ${{ needs.prepare.outputs.pr }}
211233
BASE: ${{ needs.prepare.outputs.base }}
212234
BASE_REF: ${{ needs.prepare.outputs.base_ref }}
235+
MERGE: ${{ needs.prepare.outputs.merge }}
213236

214237
- name: push results to cache
215238
if: ${{ inputs.push-to-cache && ((vars.ATTIC_SERVER != '' && vars.ATTIC_CACHE != '') || vars.CACHIX_CACHE != '') }}

drv-build-support.nix

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{ configPath, drvGraphPath }:
2+
3+
let
4+
importJSON = path: builtins.fromJSON (builtins.readFile path);
5+
pipe = builtins.foldl' (acc: f: f acc);
6+
flip =
7+
f: x: y:
8+
f y x;
9+
unique = flip pipe [
10+
(map (x: {
11+
name = x;
12+
value = null;
13+
}))
14+
builtins.listToAttrs
15+
builtins.attrNames
16+
];
17+
18+
config = builtins.mapAttrs (_: { value, ... }: value) (importJSON configPath);
19+
graph = importJSON drvGraphPath;
20+
21+
systems = [ config.system ] ++ config.extra-platforms;
22+
features = config.system-features;
23+
24+
toList =
25+
x:
26+
if builtins.isList x then
27+
x
28+
else if builtins.isString x then
29+
pipe x [
30+
(builtins.split "([^[:space:]]+)")
31+
(builtins.filter builtins.isList)
32+
(map builtins.head)
33+
]
34+
else
35+
[ ];
36+
37+
requiredFeatures =
38+
drv:
39+
pipe
40+
[
41+
drv.env or { }
42+
drv.structuredAttrs or { }
43+
]
44+
[
45+
(builtins.concatMap (x: toList x.requiredSystemFeatures or [ ]))
46+
unique
47+
];
48+
49+
result = builtins.mapAttrs (_: drv: rec {
50+
inherit (drv) system;
51+
requiredSystemFeatures = requiredFeatures drv;
52+
systemSupported = system == "builtin" || builtins.elem system systems;
53+
featuresSupported = builtins.all (flip builtins.elem features) requiredSystemFeatures;
54+
dependenciesSupported = builtins.all (drvPath: result.${drvPath}.supported) (
55+
builtins.attrNames drv.inputDrvs
56+
);
57+
supported = systemSupported && featuresSupported && dependenciesSupported;
58+
}) graph;
59+
in
60+
61+
result

generate_markdown_report.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ def html_pkgs_section(emoji: str, packages: list[str], msg: str, what: str = "pa
3838
msg += html_pkgs_section(":x:", report.get("still_failing", []), f"still failing to build (also failed on {base})")
3939
msg += html_pkgs_section(":white_check_mark:", report["tests"], "built", what="test")
4040
msg += html_pkgs_section(":white_check_mark:", report["built"], "built")
41+
msg += html_pkgs_section(":grey_question:", report.get("unsupported", []), "not supported by the current system")
4142

4243
print(msg, end="")

0 commit comments

Comments
 (0)