fix: propagate docker exit code using volume-based approach
CI / Load gitea-env.conf to pipeline env (push) Successful in 11s
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

Replace tar|docker|tee pipeline with docker volume + redirect pattern
from master. 'docker run > file 2>&1' eliminates the pipe, so 0
directly captures the container exit code. Separate commit status
step with if: always() ensures status is reported regardless of
test outcome.
This commit is contained in:
moilanik
2026-06-14 08:27:32 +03:00
parent ba94009822
commit 9f79e3733e
+20 -16
View File
@@ -49,31 +49,35 @@ jobs:
id: bats-tests
shell: bash
run: |
set +e
set -o pipefail
docker volume create bats-workspace
tar c . | docker run --rm -i -v bats-workspace:/data alpine tar x -C /data
mkdir -p "reports/${GITHUB_SHA:0:8}/bats"
tar cf - . | docker run --rm -i \
set +e
docker run --rm \
-v bats-workspace:/data \
--entrypoint bash ${{ inputs.bats-image }} \
-c '
mkdir -p /repo
tar xf - -C /repo
cd /repo
apk add -q lsof python3 jq curl ruby
bats tests/
' 2>&1 | tee "reports/${GITHUB_SHA:0:8}/bats/results.txt"
-c 'apk add -q lsof python3 jq curl ruby && cd /data && bats tests/' \
> "reports/${GITHUB_SHA:0:8}/bats/results.txt" 2>&1
BATS_EXIT=$?
bash .ci/.gitea/scripts/bats-report.sh "reports/${GITHUB_SHA:0:8}/bats" || true
STATE="success"
[ "${BATS_EXIT}" != "0" ] && STATE="failure"
bash .ci/scripts/report-status.sh "${STATE}" "Bats tests" ci-bats
bash .ci/.gitea/scripts/bats-coverage.sh bats-workspace "reports/${GITHUB_SHA:0:8}/bats"
docker volume rm bats-workspace > /dev/null 2>&1
bash .ci/.gitea/scripts/bats-report.sh "reports/${GITHUB_SHA:0:8}/bats"
echo "BATS_EXIT=${BATS_EXIT}" >> "${GITHUB_ENV}"
exit ${BATS_EXIT}
- name: Publish bats reports
if: always()
run: bash .ci/scripts/publish-git-pages.sh bats
- name: Set bats commit status
if: always()
run: |
if [ "${BATS_EXIT}" = "0" ]; then
bash .ci/scripts/report-status.sh success "Bats tests" ci-bats bats
else
bash .ci/scripts/report-status.sh failure "Bats tests FAILED" ci-bats bats
fi
cucumber:
runs-on: ubuntu-latest
container: