on iko/ghcjs-patch-master help sign in
Use release-lib.nix for Hydra (#161)

* Use release-lib.nix for Hydra jobset * Buildkite: Add a script to check Hydra evaluation

commitcaf1f61267f3a409a3200130f394b75ceb7fb9b8 authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateMon 3 Jun 2019, 13:26 (7 years ago) parent3605e0a
9 files changed+118−23
.buildkite/pipeline.yml+8−1 .buildkite/updates.yml+3−3 build.nix+30 default.nix−8 docs/maintainer-scripts.md+2−2 nix-tools/default.nix+1−1 release.nix+33−5 scripts/check-hydra.nix+39 test/default.nix+2−3
.buildkite/pipeline.yml+8−1
@@ -4,9 +4,16 @@ steps:
44 agents:
55 system: x86_64-linux
66
7+ - label: 'Check that jobset will evaluate in Hydra'
8+ command:
9+ - nix-build build.nix -A maintainer-scripts.check-hydra -o check-hydra.sh
10+ - ./check-hydra.sh
11+ agents:
12+ system: x86_64-linux
13+
714 - label: 'Update docs'
815 command:
9− - nix-build -A maintainer-scripts.update-docs -o update-docs.sh
16+ - nix-build build.nix -A maintainer-scripts.update-docs -o update-docs.sh
1017 - ./update-docs.sh
1118 branches: master
1219 agents:
.buildkite/updates.yml+3−3
@@ -1,7 +1,7 @@
11steps:
22 - label: 'Update hackage.nix'
33 command:
4− - nix-build -A maintainer-scripts.update-hackage -o update-hackage.sh
4+ - nix-build build.nix -A maintainer-scripts.update-hackage -o update-hackage.sh
55 - echo "+++ Updating hackage.nix"
66 - ./update-hackage.sh
77 artifact_paths:
@@ -11,7 +11,7 @@ steps:
1111
1212 - label: 'Update stackage.nix'
1313 command:
14− - nix-build -A maintainer-scripts.update-stackage -o update-stackage.sh
14+ - nix-build build.nix -A maintainer-scripts.update-stackage -o update-stackage.sh
1515 - echo "+++ Updating stackage.nix"
1616 - ./update-stackage.sh
1717 artifact_paths:
@@ -25,7 +25,7 @@ steps:
2525 - label: 'Update pins'
2626 command:
2727 - 'buildkite-agent artifact download "*.json" .'
28− - nix-build -A maintainer-scripts.update-pins -o update-pins.sh
28+ - nix-build build.nix -A maintainer-scripts.update-pins -o update-pins.sh
2929 - ./update-pins.sh
3030 agents:
3131 system: x86_64-linux
build.nixnew file+30
@@ -0,0 +1,30 @@
1+# This file contains the package set used by the release.nix jobset.
2+#
3+# It is separate from default.nix because that file is the public API
4+# of Haskell.nix, which shouldn't have tests, etc.
5+
6+{ pkgs ? import nixpkgs nixpkgsArgs
7+, nixpkgs ? ./nixpkgs
8+# Provide args to the nixpkgs instantiation.
9+, system ? builtins.currentSystem
10+, crossSystem ? null
11+, config ? {}
12+, nixpkgsArgs ? { inherit system crossSystem config; }
13+}:
14+
15+let
16+ haskell = import ./default.nix { inherit pkgs; };
17+
18+in {
19+ inherit (haskell) nix-tools source-pins;
20+ tests = import ./test/default.nix { inherit haskell; };
21+
22+ # Scripts for keeping Hackage and Stackage up to date, and CI tasks.
23+ maintainer-scripts = pkgs.dontRecurseIntoAttrs {
24+ update-hackage = haskell.callPackage ./scripts/update-hackage.nix {};
25+ update-stackage = haskell.callPackage ./scripts/update-stackage.nix {};
26+ update-pins = haskell.callPackage ./scripts/update-pins.nix {};
27+ update-docs = haskell.callPackage ./scripts/update-docs.nix {};
28+ check-hydra = haskell.callPackage ./scripts/check-hydra.nix {};
29+ };
30+}
default.nix−8
@@ -132,14 +132,6 @@ let
132132 # regularly updated.
133133 inherit hackage stackage;
134134
135− # Scripts for keeping Hackage and Stackage up to date.
136− maintainer-scripts = {
137− update-hackage = self.callPackage ./scripts/update-hackage.nix {};
138− update-stackage = self.callPackage ./scripts/update-stackage.nix {};
139− update-pins = self.callPackage ./scripts/update-pins.nix {};
140− update-docs = self.callPackage ./scripts/update-docs.nix {};
141− };
142−
143135 # Make this handy overridable fetch function available.
144136 inherit fetchExternal;
145137
docs/maintainer-scripts.md+2−2
@@ -8,10 +8,10 @@ scripts in this repo.
88
99To run the updater scripts manually, use:
1010
11− nix-build -A maintainer-scripts.update-hackage -o update-hackage.sh
11+ nix-build build.nix -A maintainer-scripts.update-hackage -o update-hackage.sh
1212 ./update-hackage.sh
1313
14− nix-build -A maintainer-scripts.update-stackage -o update-stackage.sh
14+ nix-build build.nix -A maintainer-scripts.update-stackage -o update-stackage.sh
1515 ./update-stackage.sh
1616
1717The scripts will clone the repo, generate the latest data, then
nix-tools/default.nix+1−1
@@ -6,7 +6,7 @@ let
66 src = cleanSourceHaskell (fetchExternal {
77 name = "nix-tools-src";
88 specJSON = ./nix-tools-src.json;
9− override = "nix-tools";
9+ override = "nix-tools-src";
1010 });
1111
1212 pkgSet = mkCabalProjectPkgSet {
release.nix+33−5
@@ -1,7 +1,35 @@
1+{ supportedSystems ? [ "x86_64-linux" ] # spare our "x86_64-darwin" builders for now
2+, scrubJobs ? true
3+, haskell-nix ? { outPath = ./.; rev = "abcdef"; }
4+, nixpkgsArgs ? {}
5+}:
6+
7+let fixedNixpkgs = import ./nixpkgs {}; in
8+with fixedNixpkgs.lib;
9+with (import (fixedNixpkgs.path + "/pkgs/top-level/release-lib.nix") {
10+ inherit supportedSystems scrubJobs nixpkgsArgs;
11+ packageSet = import (haskell-nix + /build.nix);
12+});
13+
114let
2− haskell = import ./default.nix {};
3−in {
4− inherit (haskell) nix-tools source-pins;
15+ # Remove tests which have meta.disabled = true
16+ filterTests = let
17+ nonEmpty = attrs: length (attrValues attrs) != 0;
18+ removeDisabled = filterAttrs (system: test: !(test.meta.disabled or false));
19+ in jobs: jobs // {
20+ tests = filterAttrs (_: nonEmpty) (mapAttrs (name: removeDisabled) jobs.tests);
21+ };
22+
23+ jobs = {
24+ native = filterTests (mapTestOn (packagePlatforms pkgs));
25+ } // {
26+ # On IOHK Hydra, "required" is a special job that updates the
27+ # GitHub CI status.
28+ required = fixedNixpkgs.releaseTools.aggregate {
29+ name = "haskell.nix-required";
30+ meta.description = "All jobs required to pass CI";
31+ constituents = collect isDerivation jobs.native;
32+ };
33+ };
534
6− tests = import ./test { inherit haskell; };
7−}
35+in jobs
scripts/check-hydra.nixnew file+39
@@ -0,0 +1,39 @@
1+{ stdenv, writeScript, coreutils, time, hydra, jq }:
2+
3+with stdenv.lib;
4+
5+writeScript "check-hydra.sh" ''
6+ #!${stdenv.shell}
7+
8+ set -euo pipefail
9+
10+ export PATH="${makeBinPath [ coreutils time hydra jq ]}"
11+
12+ echo '~~~ Evaluating release.nix'
13+ command time --format '%e' -o eval-time.txt \
14+ hydra-eval-jobs \
15+ --option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \
16+ -I . release.nix > eval.json
17+ EVAL_EXIT_CODE="$?"
18+ if [ "$EVAL_EXIT_CODE" != 0 ]
19+ then
20+ rm eval.json eval-time.txt
21+ echo -e "\\e[31;1mERROR: Failed to evaluate release.nix\\e[0m"
22+ exit 1
23+ fi
24+ EVAL_TIME=$(cat eval-time.txt)
25+ jq . < eval.json
26+ ERRORS=$(jq -r 'map_values(.error)|to_entries[]|select(.value)|@text "\(.key): \(.value)"' < eval.json)
27+ NUM_ERRORS=$(jq -r '[ map_values(.error)|to_entries[]|select(.value) ] |length' < eval.json)
28+ rm eval.json eval-time.txt
29+
30+ if [ "$NUM_ERRORS" != 0 ]
31+ then
32+ echo -e "\\e[31;1mERROR: evaluation completed in $EVAL_TIME seconds with $NUM_ERRORS errors\\e[0m"
33+ echo "$ERRORS"
34+ exit 1
35+ else
36+ echo -e "\\e[32;1mOK: evaluation completed in $EVAL_TIME seconds with no errors\\e[0m"
37+ exit 0
38+ fi
39+''
test/default.nix+2−3
@@ -1,5 +1,4 @@
1−{ system ? builtins.currentSystem
2−, pkgs ? import nixpkgs { inherit system; }
1+{ pkgs ? import nixpkgs { }
32, nixpkgs ? ../nixpkgs
43, haskell ? pkgs.callPackage ../. { }
54}:
@@ -9,7 +8,7 @@ with pkgs;
98let
109 util = callPackage ./util.nix {};
1110
12−in {
11+in pkgs.recurseIntoAttrs {
1312 cabal-simple = haskell.callPackage ./cabal-simple { inherit util; };
1413 cabal-sublib = haskell.callPackage ./cabal-sublib { inherit util; };
1514 cabal-22 = haskell.callPackage ./cabal-22 {};