Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 8236960

Browse files
committed
[DEVOPS-1100] Catch errors in check-hydra.sh and exit appropriately
1 parent fcc489c commit 8236960

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

scripts/ci/check-hydra.sh

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1-
#!/bin/sh
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -p jq -i bash
23

34
nix-build https://github.com/nixos/nixpkgs/archive/4fb198892d298452023ab176e7067da58d30772e.tar.gz -A hydra
45
echo '~~~ Evaluating release.nix'
5-
./result/bin/hydra-eval-jobs -I . release.nix
6+
env time --format '%e' -o eval-time.txt ./result/bin/hydra-eval-jobs -I . release.nix > eval.json
7+
EVAL_EXIT_CODE="$?"
8+
if [ "$EVAL_EXIT_CODE" != 0 ]
9+
then
10+
rm eval.json
11+
echo -e "\e[31;1mERROR: Failed to evaluate release.nix\e[0m"
12+
exit 1
13+
fi
14+
EVAL_TIME=$(cat eval-time.txt)
15+
jq . < eval.json
16+
ERRORS=$(jq -r 'map_values(.error)|to_entries[]|select(.value)|@text "\(.key): \(.value)"' < eval.json)
17+
NUM_ERRORS=$(jq -r '[ map_values(.error)|to_entries[]|select(.value) ] |length' < eval.json)
18+
rm eval.json eval-time.txt
19+
20+
if [ "$NUM_ERRORS" != 0 ]
21+
then
22+
echo -e "\e[31;1mERROR: evaluation completed in $EVAL_TIME seconds with $NUM_ERRORS errors\e[0m"
23+
echo $ERRORS
24+
exit 1
25+
else
26+
echo -e "\e[32;1mOK: evaluation completed in $EVAL_TIME seconds with no errors\e[0m"
27+
exit 0
28+
fi

0 commit comments

Comments
 (0)