Skip to content

Commit

Permalink
tox.ini (docker): Move copying of logs from container here from .gith…
Browse files Browse the repository at this point in the history
…ub/workflows/docker.yml
  • Loading branch information
Matthias Koeppe committed Dec 26, 2023
1 parent 307c502 commit 6e7bcc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ jobs:
- name: Copy logs from the Docker image or build container
run: |
mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"
cp -r .tox/$TOX_ENV/Dockerfile .tox/$TOX_ENV/log "artifacts/$LOGS_ARTIFACT_NAME"
if [ -f .tox/$TOX_ENV/Dockertags ]; then CONTAINERS=$(docker create $(tail -1 .tox/$TOX_ENV/Dockertags) /bin/bash || true); fi
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
cp -r .tox/$TOX_ENV/* "artifacts/$LOGS_ARTIFACT_NAME"
if: always()
- uses: actions/upload-artifact@v3
with:
Expand Down
12 changes: 11 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,10 @@ commands =
docker: --build-arg TARGETS="{posargs:build}" \
docker: --build-arg TARGETS_OPTIONAL="{env:TARGETS_OPTIONAL:ptest}" \
docker: {env:EXTRA_DOCKER_BUILD_ARGS:}; status=$?; \
docker: unset CONTAINER; \
docker: if [ $status != 0 ]; then \
docker: if [ $DOCKER_BUILDKIT = 0 ]; then \
docker: BUILD_TAG="$BUILD_TAG-failed"; docker commit $(docker ps -l -q) $BUILD_IMAGE:$BUILD_TAG; PUSH_TAGS=$BUILD_IMAGE:$BUILD_TAG; \
docker: BUILD_TAG="$BUILD_TAG-failed"; CONTAINER=$(docker ps -l -q); docker commit $CONTAINER $BUILD_IMAGE:$BUILD_TAG; PUSH_TAGS=$BUILD_IMAGE:$BUILD_TAG; \
docker: else \
docker: unset BUILD_TAG; unset PUSH_TAGS; echo "DOCKER_BUILDKIT=1, so we cannot commit and tag the failed image"; \
docker: fi; \
Expand All @@ -779,6 +780,15 @@ commands =
docker: docker push $tag || echo "(ignoring errors)"; \
docker: done; \
docker: fi; \
docker: if [ x"$BUILD_TAG" != x ]; then \
docker: echo "Copying logs from the container to {envdir}/sage/"; \
docker: docker run $BUILD_IMAGE:$BUILD_TAG bash -c " \
docker: tar -c --ignore-failed-read -f - \
docker: /sage/logs /sage/{prefix,venv}/var/lib/sage/installed \
docker: ~/.sage/timings2.json /sage/pkgs/*/.tox/*/.sage/timings2.json \
docker: /sage/pkgs/*/.tox/*/logs 2> /dev/null" \
docker: | (cd {envdir} && tar xf -); \
docker: fi; \
docker: if [ $status != 0 ]; then exit $status; fi; \
docker: done'
# #28728: gap fails its test suite.
Expand Down

0 comments on commit 6e7bcc4

Please sign in to comment.