fix: propagate docker exit code using volume-based approach
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:
@@ -49,31 +49,35 @@ jobs:
|
|||||||
id: bats-tests
|
id: bats-tests
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set +e
|
docker volume create bats-workspace
|
||||||
set -o pipefail
|
tar c . | docker run --rm -i -v bats-workspace:/data alpine tar x -C /data
|
||||||
mkdir -p "reports/${GITHUB_SHA:0:8}/bats"
|
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 }} \
|
--entrypoint bash ${{ inputs.bats-image }} \
|
||||||
-c '
|
-c 'apk add -q lsof python3 jq curl ruby && cd /data && bats tests/' \
|
||||||
mkdir -p /repo
|
> "reports/${GITHUB_SHA:0:8}/bats/results.txt" 2>&1
|
||||||
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"
|
|
||||||
BATS_EXIT=$?
|
BATS_EXIT=$?
|
||||||
bash .ci/.gitea/scripts/bats-report.sh "reports/${GITHUB_SHA:0:8}/bats" || true
|
bash .ci/.gitea/scripts/bats-coverage.sh bats-workspace "reports/${GITHUB_SHA:0:8}/bats"
|
||||||
|
docker volume rm bats-workspace > /dev/null 2>&1
|
||||||
STATE="success"
|
bash .ci/.gitea/scripts/bats-report.sh "reports/${GITHUB_SHA:0:8}/bats"
|
||||||
[ "${BATS_EXIT}" != "0" ] && STATE="failure"
|
echo "BATS_EXIT=${BATS_EXIT}" >> "${GITHUB_ENV}"
|
||||||
bash .ci/scripts/report-status.sh "${STATE}" "Bats tests" ci-bats
|
|
||||||
|
|
||||||
exit ${BATS_EXIT}
|
exit ${BATS_EXIT}
|
||||||
|
|
||||||
- name: Publish bats reports
|
- name: Publish bats reports
|
||||||
if: always()
|
if: always()
|
||||||
run: bash .ci/scripts/publish-git-pages.sh bats
|
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:
|
cucumber:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
|
|||||||
Reference in New Issue
Block a user