Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Move code for tagging/pushing docker images into tox.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Aug 12, 2020
1 parent 415221a commit cf25b83
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ jobs:
run: |
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install python-tox
- name: Try to login to docker.pkg.github.com
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: |
TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
if [ -z "$TOKEN" ]; then
TOKEN="${{ secrets.GITHUB_TOKEN }}"
fi
if echo "$TOKEN" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin; then
echo "::set-env name=DOCKER_PUSH_REPOSITORY::docker.pkg.github.com/${{ github.repository }}/"
fi
- run: |
set -o pipefail; EXTRA_DOCKER_BUILD_ARGS="--build-arg USE_MAKEFLAGS=\"-k V=0 SAGE_NUM_THREADS=3\"" tox -e $TOX_ENV -- $TARGETS 2>&1 | sed "/^configure: notice:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|;/^configure: warning:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|;/^configure: error:/s|^|::error file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|;"
- name: Copy logs from the docker image or build container
Expand All @@ -78,20 +88,10 @@ jobs:
run: |
.github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
if: always()
- name: Push docker images
- name: List docker images
run: |
if [ -f .tox/$TOX_ENV/Dockertags ]; then
TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
if [ -z "$TOKEN" ]; then
TOKEN="${{ secrets.GITHUB_TOKEN }}"
fi
echo "$TOKEN" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
for a in $(cat .tox/$TOX_ENV/Dockertags); do
FULL_TAG=docker.pkg.github.com/${{ github.repository }}/$a
docker tag $a $FULL_TAG
echo Pushing $FULL_TAG
docker push $FULL_TAG
done || echo "(Ignoring errors)"
cat .tox/$TOX_ENV/Dockertags
fi
if: always()

Expand Down
14 changes: 9 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ passenv =
# Set for example to "with-system-packages configured with-targets-pre with-targets"
# to tag intermediate images.
docker: DOCKER_TARGETS
# If set, we use this prefix and push to it
docker: DOCKER_PUSH_REPOSITORY
local: MAKE
local-direct: *

Expand Down Expand Up @@ -409,8 +411,8 @@ commands =
# configure binfmt-support on the Docker host (works locally or remotely, i.e: using boot2docker)
docker-{arm64,armhf}: docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker: bash -c 'for docker_target in {env:DOCKER_TARGETS:with-targets}; do \
docker: BUILD_TAG=sage-{envname}-$docker_target:$(git describe --dirty --always); \
docker: if docker build . -f {envdir}/Dockerfile \
docker: BUILD_TAG={env:DOCKER_PUSH_REPOSITORY:}sage-{envname}-$docker_target:$(git describe --dirty --always); \
docker: docker build . -f {envdir}/Dockerfile \
docker: --target $docker_target \
docker: --tag $BUILD_TAG \
docker: --build-arg EXTRA_CONFIGURE_ARGS="{env:CONFIGURE_ARGS}" \
Expand All @@ -420,9 +422,11 @@ commands =
docker: --build-arg TARGETS_PRE="$(if test -n "$TARGETS_PRE"; then echo $TARGETS_PRE; else echo {posargs:sagelib-build-deps}; fi)" \
docker: --build-arg TARGETS="{posargs:build}" \
docker: --build-arg TARGETS_OPTIONAL="{env:TARGETS_OPTIONAL:ptest}" \
docker: {env:EXTRA_DOCKER_BUILD_ARGS:}; \
docker: then echo $BUILD_TAG >> {envdir}/Dockertags; \
docker: else docker commit $(docker ps -l -q) $BUILD_TAG-failed && echo $BUILD_TAG-failed >> {envdir}/Dockertags; exit 1; fi; \
docker: {env:EXTRA_DOCKER_BUILD_ARGS:}; status=$?; \
docker: if [ $status != 0 ]; then BUILD_TAG="$BUILD_TAG-failed"; docker commit $(docker ps -l -q) $BUILD_TAG; fi; \
docker: echo $BUILD_TAG >> {envdir}/Dockertags; \
docker: if [ x"{env:DOCKER_PUSH_REPOSITORY:}" != x ]; then echo Pushing $BUILD_TAG; docker push $BUILD_TAG || echo (ignoring errors); fi; \
docker: if [ $status != 0 ]; then exit $status; fi; \
docker: done'
# pathpy checksuite needs tox. #28728: gap fails its test suite.
# linbox/cysignals testsuites fail. ppl takes very long.
Expand Down

0 comments on commit cf25b83

Please sign in to comment.