fix: propagate docker exit code from bats pipeline with pipefail
CI / Load gitea-env.conf to pipeline env (push) Successful in 12s
ci-cucumber Cucumber tests
ci-bats Bats tests
ci-build Build complete
CI / Quality Gate (push) Successful in 1m52s
CI / Build & Push Artifact (push) Has been skipped

Pipeline 'tar | docker | tee' previously always returned tee's exit
code (0), masking test failures in the bats job. set -o pipefail
makes 0 capture the last failed command's exit code instead.
This commit is contained in:
moilanik
2026-06-14 08:17:50 +03:00
parent 37c0428fb5
commit ba94009822
+2 -1
View File
@@ -50,6 +50,7 @@ jobs:
shell: bash shell: bash
run: | run: |
set +e set +e
set -o pipefail
mkdir -p "reports/${GITHUB_SHA:0:8}/bats" mkdir -p "reports/${GITHUB_SHA:0:8}/bats"
tar cf - . | docker run --rm -i \ tar cf - . | docker run --rm -i \
--entrypoint bash ${{ inputs.bats-image }} \ --entrypoint bash ${{ inputs.bats-image }} \
@@ -60,7 +61,7 @@ jobs:
apk add -q lsof python3 jq curl ruby apk add -q lsof python3 jq curl ruby
bats tests/ bats tests/
' 2>&1 | tee "reports/${GITHUB_SHA:0:8}/bats/results.txt" ' 2>&1 | tee "reports/${GITHUB_SHA:0:8}/bats/results.txt"
BATS_EXIT=${PIPESTATUS[1]} BATS_EXIT=$?
bash .ci/.gitea/scripts/bats-report.sh "reports/${GITHUB_SHA:0:8}/bats" || true bash .ci/.gitea/scripts/bats-report.sh "reports/${GITHUB_SHA:0:8}/bats" || true
STATE="success" STATE="success"