From 7f4bfa88a6ff022219ea88e08e831892097efbd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Bary=C5=82a?= Date: Tue, 5 Mar 2024 13:12:27 +0100 Subject: [PATCH] semver_checks CI: fail when something in script fails --- .github/workflows/semver_checks.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/semver_checks.yml b/.github/workflows/semver_checks.yml index 4b14f40113..6b3b8c9d5e 100644 --- a/.github/workflows/semver_checks.yml +++ b/.github/workflows/semver_checks.yml @@ -63,11 +63,16 @@ jobs: - name: Verify the API compatibilty with PR base id: semver-pr-check run: | - set +e + set -e # So that failed commands exit the script + set -o pipefail # So that if a command in a pipe fails, the whole command fails + echo "output<> $GITHUB_OUTPUT + SEMVER_REV_OUTPUT=$(semver-rev rev="$PR_BASE" 2>&1) && true # "&& true" preserves exit code but cancels effects of set -e + exitcode=$? + # Weird sed strip ANSI colors from output - make semver-rev rev="$PR_BASE" |& tee /proc/self/fd/2 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" >> $GITHUB_OUTPUT - exitcode=${PIPESTATUS[0]} + # If any of the commands below fail, `set -e` and `set -o pipefail` should exit the script + echo "${SEMVER_REV_OUTPUT}" | tee /proc/self/fd/2 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" >> $GITHUB_OUTPUT echo "SEMVER_STDOUT_EOF" >> $GITHUB_OUTPUT echo "Semver checks exitcode: " $exitcode