Skip to content

Commit 8cd1147

Browse files
author
Matthias Koeppe
committed
tox.ini (docker): Move copying of logs from container here from .github/workflows/docker.yml
1 parent 10df873 commit 8cd1147

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ jobs:
248248
- name: Copy logs from the Docker image or build container
249249
run: |
250250
mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"
251-
cp -r .tox/$TOX_ENV/Dockerfile .tox/$TOX_ENV/log "artifacts/$LOGS_ARTIFACT_NAME"
252-
if [ -f .tox/$TOX_ENV/Dockertags ]; then CONTAINERS=$(docker create $(tail -1 .tox/$TOX_ENV/Dockertags) /bin/bash || true); fi
253-
if [ -n "$CONTAINERS" ]; then for CONTAINER in $CONTAINERS; do for ARTIFACT in /sage/logs; do docker cp $CONTAINER:$ARTIFACT artifacts/$LOGS_ARTIFACT_NAME && HAVE_LOG=1; done; if [ -n "$HAVE_LOG" ]; then break; fi; done; fi
251+
cp -r .tox/$TOX_ENV/* "artifacts/$LOGS_ARTIFACT_NAME"
254252
if: always()
255253
- uses: actions/upload-artifact@v3
256254
with:

tox.ini

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,10 @@ commands =
768768
docker: --build-arg TARGETS="{posargs:build}" \
769769
docker: --build-arg TARGETS_OPTIONAL="{env:TARGETS_OPTIONAL:ptest}" \
770770
docker: {env:EXTRA_DOCKER_BUILD_ARGS:}; status=$?; \
771+
docker: unset CONTAINER; \
771772
docker: if [ $status != 0 ]; then \
772773
docker: if [ $DOCKER_BUILDKIT = 0 ]; then \
773-
docker: BUILD_TAG="$BUILD_TAG-failed"; docker commit $(docker ps -l -q) $BUILD_IMAGE:$BUILD_TAG; PUSH_TAGS=$BUILD_IMAGE:$BUILD_TAG; \
774+
docker: BUILD_TAG="$BUILD_TAG-failed"; CONTAINER=$(docker ps -l -q); docker commit $CONTAINER $BUILD_IMAGE:$BUILD_TAG; PUSH_TAGS=$BUILD_IMAGE:$BUILD_TAG; \
774775
docker: else \
775776
docker: unset BUILD_TAG; unset PUSH_TAGS; echo "DOCKER_BUILDKIT=1, so we cannot commit and tag the failed image"; \
776777
docker: fi; \
@@ -784,6 +785,15 @@ commands =
784785
docker: docker push $tag || echo "(ignoring errors)"; \
785786
docker: done; \
786787
docker: fi; \
788+
docker: if [ x"$BUILD_TAG" != x ]; then \
789+
docker: echo "Copying logs from the container to {envdir}/sage/"; \
790+
docker: docker run $BUILD_IMAGE:$BUILD_TAG bash -c " \
791+
docker: tar -c --ignore-failed-read -f - \
792+
docker: /sage/logs /sage/{prefix,venv}/var/lib/sage/installed \
793+
docker: ~/.sage/timings2.json /sage/pkgs/*/.tox/*/.sage/timings2.json \
794+
docker: /sage/pkgs/*/.tox/*/logs 2> /dev/null" \
795+
docker: | (cd {envdir} && tar xf -); \
796+
docker: fi; \
787797
docker: if [ $status != 0 ]; then exit $status; fi; \
788798
docker: done'
789799
# #28728: gap fails its test suite.

0 commit comments

Comments
 (0)