-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathci-pr.nix
85 lines (74 loc) · 2.56 KB
/
ci-pr.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{ src ? { rev = null; }, labels ? {}, ... }:
let
nixpkgs = import ./nix { };
subpath = p: import ./nix/gitSource.nix p;
# Wrap in a derivation to fix path to perl in shebang
diff-stats = nixpkgs.stdenvNoCC.mkDerivation {
name = "diff-stats";
src = ./test/diff-stats.pl;
phases = [ "installPhase fixupPhase" ];
buildInputs = [ nixpkgs.perl ];
installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/diff-stats
'';
};
test-data = subpath ./test;
wasm-hash-for = moc:
nixpkgs.stdenvNoCC.mkDerivation {
name = "wasm-hash";
src = test-data;
buildInputs = [ moc ];
buildPhase = ''
for file in */*.mo
do
# ignore all errors
echo -n $file
if moc $file -no-check-ir -ref-system-api -o $file.wasm 2>/dev/null
then echo " failed (ignored)"
else echo " ok"
fi
done
'';
installPhase = ''
sha256sum **/*.wasm > $out
'';
};
baseJobs = import (src.mergeBase + "/default.nix") { system = "x86_64-linux"; };
prJobs = import ./default.nix { system = "x86_64-linux"; };
# NB: We run both compilers on the new PR’s set of tests
wasm-hash-base = wasm-hash-for baseJobs.moc;
wasm-hash-pr = wasm-hash-for prJobs.moc;
# This job compares the performance numbers of the current revision
# with the mergeBase revision
#
# to test locally, use something like
# nix-build -A perf-delta ci-pr.nix --arg src '{ mergeBase = builtins.fetchGit { url = ./.; rev = "2a6221425d2c482208f9f3e2e2fc00d4847212e5"; }; }'
perf-delta =
nixpkgs.runCommandNoCC "perf-delta" {
nativeBuildInputs = [ nixpkgs.coreutils diff-stats ];
} ''
mkdir -p $out
mkdir -p $out/nix-support
if cmp -s ${wasm-hash-base} ${wasm-hash-pr}
then
echo "This PR does not affect the produced WebAssembly code." >> $out/report
else
diff-stats ${baseJobs.tests.perf}/stats.csv ${prJobs.tests.perf}/stats.csv > $out/report;
fi
echo "report perf-delta $out report" >> $out/nix-support/hydra-build-products
echo '{{{! comment:edit-one }}}' >> $out/comment
cat $out/report >> $out/comment
echo "comment manifest $out/comment" >> $out/nix-support/hydra-build-products
'';
jobs = import ./ci.nix { inherit src; inherit labels; } //
nixpkgs.lib.optionalAttrs (src ? mergeBase) {
inherit perf-delta;
};
in
jobs // {
all-jobs = nixpkgs.releaseTools.aggregate {
name = "all-jobs";
constituents = nixpkgs.lib.collect (drv: nixpkgs.lib.isDerivation drv) jobs;
};
}