From 5f64b69d23bfee70d222671a7d10f2efe22b99c6 Mon Sep 17 00:00:00 2001 From: regnat Date: Tue, 30 Nov 2021 17:32:40 +0100 Subject: Add a github cron to check the hydra status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a regular github action that will check the status of the latest hydra evaluation. Things aren’t ideal right now because this job will only notify “the user who last modified the cron syntax in the workflow file” (so myself atm). But at least that’ll give a notification for failing hydra jobs --- scripts/check-hydra-status.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/check-hydra-status.sh (limited to 'scripts/check-hydra-status.sh') diff --git a/scripts/check-hydra-status.sh b/scripts/check-hydra-status.sh new file mode 100644 index 000000000..c1d2d7c40 --- /dev/null +++ b/scripts/check-hydra-status.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -euo pipefail +# set -x + + +# mapfile BUILDS_FOR_LATEST_EVAL < <( +# curl -H 'Accept: application/json' https://hydra.nixos.org/jobset/nix/master/evals | \ +# jq -r '.evals[0].builds[] | @sh') +BUILDS_FOR_LATEST_EVAL=$( +curl -sS -H 'Accept: application/json' https://hydra.nixos.org/jobset/nix/master/evals | \ + jq -r '.evals[0].builds[]') + +someBuildFailed=0 + +for buildId in $BUILDS_FOR_LATEST_EVAL; do + buildInfo=$(curl -sS -H 'Accept: application/json' "https://hydra.nixos.org/build/$buildId") + + buildStatus=$(echo "$buildInfo" | \ + jq -r '.buildstatus') + + if [[ "$buildStatus" -ne 0 ]]; then + someBuildFailed=1 + echo "Job “$(echo "$buildInfo" | jq -r '.job')” failed on hydra" + fi +done + +exit "$someBuildFailed" -- cgit v1.2.3 From b8d57e28839587832109f6607eb28819559fc30c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 10 Feb 2022 11:10:29 +0100 Subject: check-hydra-status.sh: Improve error behaviour --- scripts/check-hydra-status.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/check-hydra-status.sh') diff --git a/scripts/check-hydra-status.sh b/scripts/check-hydra-status.sh index c1d2d7c40..7efe9cf97 100644 --- a/scripts/check-hydra-status.sh +++ b/scripts/check-hydra-status.sh @@ -19,9 +19,9 @@ for buildId in $BUILDS_FOR_LATEST_EVAL; do buildStatus=$(echo "$buildInfo" | \ jq -r '.buildstatus') - if [[ "$buildStatus" -ne 0 ]]; then + if [[ $buildStatus != 0 ]]; then someBuildFailed=1 - echo "Job “$(echo "$buildInfo" | jq -r '.job')” failed on hydra" + echo "Job “$(echo "$buildInfo" | jq -r '.job')” failed on hydra: $buildInfo" fi done -- cgit v1.2.3 From 5b809f9e0e0fe84304c2ae0f5f7b2d4db02565ad Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 10 Feb 2022 21:15:07 +0100 Subject: check-hydra-status.sh: Ignore unfinished builds --- scripts/check-hydra-status.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts/check-hydra-status.sh') diff --git a/scripts/check-hydra-status.sh b/scripts/check-hydra-status.sh index 7efe9cf97..5e2f03429 100644 --- a/scripts/check-hydra-status.sh +++ b/scripts/check-hydra-status.sh @@ -16,8 +16,13 @@ someBuildFailed=0 for buildId in $BUILDS_FOR_LATEST_EVAL; do buildInfo=$(curl -sS -H 'Accept: application/json' "https://hydra.nixos.org/build/$buildId") - buildStatus=$(echo "$buildInfo" | \ - jq -r '.buildstatus') + finished=$(echo "$buildInfo" | jq -r '.finished') + + if [[ $finished = 0 ]]; then + continue + fi + + buildStatus=$(echo "$buildInfo" | jq -r '.buildstatus') if [[ $buildStatus != 0 ]]; then someBuildFailed=1 -- cgit v1.2.3