Skip to content

Commit

Permalink
Better status handling
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Apr 24, 2024
1 parent 3882e22 commit 5778de1
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions .github/workflows/release-upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ name: Release Upload
# so no release will get created. This is useful for debugging or
# trying to build a release before tagging it.
#
# So far this pipeline only supports releasing Linux binaries. However everything is ready to support
# other platforms. Please see the "TODO generalize" comments in this file to support new platforms.
# So far this pipeline supports releasing Linux and Darwin binaries.
# Please see the "TODO generalize" comments in this file to support new platforms.

on:
workflow_dispatch:
Expand Down Expand Up @@ -96,18 +96,35 @@ jobs:
timeout-minutes: 120
run: |
while true; do
conclusion=$(gh api "repos/$GITHUB_REPOSITORY/commits/${{ env.TARGET_TAG }}/check-runs" --jq '.check_runs[] | select(.name | test("ci/hydra-build:.*\\.required")) | .conclusion' | more | uniq)
case "$conclusion" in
success)
echo "ci/hydra-build:required succeeded"
exit 0;;
failure)
conclusion=$(gh api "repos/$GITHUB_REPOSITORY/commits/${{ env.TARGET_TAG }}/check-runs" --jq '.check_runs[] | select(.name | test("ci/hydra-build:.*\\.required")) | .conclusion')
# Here we are being careful, because we query the status of multiple jobs (once per line)
# But the only thing we are sure is that "success" means a green job. There
# could be unknown statuses, which is why we may retry when unsure (see 'sleep') below.
echo "ci/hydra-build:.*\\.required returned status: $conclusion"
# conclusion is of the form (note the newlines, which matter because we use 'grep -c' below)
# success
# failure
# success
# shellcheck disable=SC2126
nb_failure=$(echo "$conclusion" | grep "^failure" | wc -l)
if [[ "$nb_failure" != "0" ]]
then
# Some failure
echo "ci/hydra-build:required failed"
exit 1;;
*)
echo "ci/hydra-build:required pending with $conclusion. Waiting 30s..."
sleep 30;;
esac
exit 1
fi
nb_statuses=$(echo "$conclusion" | wc -l)
# shellcheck disable=SC2126
nb_success=$(echo "$conclusion" | grep "^success" | wc -l)
if [[ "$nb_statuses" == "$nb_success" ]]
then
# Only successes
echo "ci/hydra-build:required succeeded"
exit 0
fi
# Unclear (some non-failure, non-success)
echo "ci/hydra-build:required pending with $conclusion. Waiting 30s..."
sleep 30
done
pull:
Expand Down Expand Up @@ -136,13 +153,10 @@ jobs:
run: |
case ${{ matrix.arch }} in
linux)
derivation="cardano-cli:exe:cardano-cli"
;;
x86_64-darwin)
derivation="hydraJobs.x86_64-darwin.packages.cardano-cli:exe:cardano-cli"
derivation="hydraJobs.x86_64-linux.packages.cardano-cli:exe:cardano-cli"
;;
aarch64-darwin)
derivation="hydraJobs.aarch64-darwin.packages.cardano-cli:exe:cardano-cli"
x86_64-darwin|aarch64-darwin)
derivation="hydraJobs.${{ matrix.arch }}.packages.cardano-cli:exe:cardano-cli"
;;
# TODO generalize
# ;;
Expand Down Expand Up @@ -173,18 +187,6 @@ jobs:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
# with:
# name: cardano-cli-linux # Should match (2)
# - uses: actions/download-artifact@v4
# with:
# name: cardano-cli-x86_64-darwin # Should match (2)
# - uses: actions/download-artifact@v4
# with:
# name: cardano-cli-aarch64-darwin # Should match (2)
# TODO generalize
# - uses: actions/download-artifact@v4
# with:
# name: cardano-cli-win64 # Should match (2)
- name: Compress
run: |
# (3)
Expand Down

0 comments on commit 5778de1

Please sign in to comment.