Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,8 @@ 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"
rm -rf "artifacts/$LOGS_ARTIFACT_NAME"/{bin,lib,pyvenv.cfg}
if: always()
- uses: actions/upload-artifact@v3
with:
Expand All @@ -262,9 +261,46 @@ jobs:
run: |
.github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
if: always()
- name: List docker images
- name: List Docker images
run: |
if [ -f .tox/$TOX_ENV/Dockertags ]; then
cat .tox/$TOX_ENV/Dockertags
if [ -n "$DOCKER_PUSH_REPOSITORY" -a -f .tox/$TOX_ENV/Dockertags.pushed ]; then
set -- $(cat .tox/$TOX_ENV/Dockertags.pushed)
case $# in
1) images="image"; one_image="the image";;
*) images="images"; one_image="one of the images";;
esac
echo "::notice title=Docker $images pushed::Pushed $images $*)"
echo
echo "To pull $one_image and enter the container, type:"
echo
for TAG in $*; do
echo " \$ docker run -it $TAG bash"
done
echo
echo "To use $one_image as the base for an incremental build, type:"
echo
TOX_ENV_SANS_INCREMENTAL=${TOX_ENV/-incremental/}
DOCKER_IMAGE=${TOX_ENV_SANS_INCREMENTAL#docker-}
for TAG in $*; do
echo -n " \$"
if [ "$DOCKER_PUSH_REPOSITORY" != "ghcr.io/sagemath/sage/" ]; then
echo -n " FROM_DOCKER_REPOSITORY=$DOCKER_PUSH_REPOSITORY"
fi
eval DOCKER_TARGET=\${TAG#*$DOCKER_IMAGE-}
DOCKER_TARGET=${DOCKER_TARGET%:*}
if [ "$DOCKER_TARGET" != "with-targets" ]; then
echo -n " FROM_DOCKER_TARGET=$DOCKER_TARGET"
fi
echo " FROM_DOCKER_TAG=${TAG#*:} tox -e $TOX_ENV_SANS_INCREMENTAL-incremental"
done
elif [ -n "$DOCKER_PUSH_REPOSITORY" -a -f .tox/$TOX_ENV/Dockertags ]; then
echo "Unable to push Docker images to $DOCKER_PUSH_REPOSITORY."
echo "This is normal in a pull request to sagemath/sage or to another user's repository."
echo
echo "If you need Docker images, "
echo " - either run this GitHub Actions workflow in your repository fork"
echo " - or use the method described in https://doc.sagemath.org/html/en/developer/portability_testing.html#automatic-docker-based-build-testing-using-tox"
else
echo "No Docker images created."
fi
if: always()
if: always() && ${{ inputs.docker_push_repository }}
28 changes: 20 additions & 8 deletions build/bin/write-dockerfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,18 @@ EOF
;;
esac
esac

case ${DOCKER_BUILDKIT-0} in
1)
# With buildkit we cannot retrieve failed builds.
# So we do not allow the main step of a build stage to fail.
# Instead we record the exit code in the file STATUS.
THEN_SAVE_STATUS='; echo $? > STATUS'
# ... and at the beginning of the next build stage,
# we check the status and exit with an error status.
CHECK_STATUS_THEN='STATUS=$(cat STATUS 2>/dev/null); case "$STATUS" in ""|0) ;; *) exit $STATUS;; esac; '
esac
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, how does this trick avoid the problem of "With buildkit we cannot retrieve failed builds."?

How is "failed build" different from "exit" with nonzero status?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, how does this trick avoid the problem of "With buildkit we cannot retrieve failed builds."?

By having the next build stage fail at the beginning, instead of failing the current one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so that the previous stage remains in the container and the current one discarded...

OK.


cat <<EOF

FROM with-system-packages as bootstrapped
Expand All @@ -230,20 +242,20 @@ $ADD pkgs pkgs
$ADD build ./build
$ADD .upstream.d ./.upstream.d
ARG BOOTSTRAP=./bootstrap
$RUN sh -x -c "\${BOOTSTRAP}" $ENDRUN
$RUN sh -x -c "\${BOOTSTRAP}" $ENDRUN $THEN_SAVE_STATUS

FROM bootstrapped as configured
#:configuring:
RUN mkdir -p logs/pkgs; rm -f config.log; ln -s logs/pkgs/config.log config.log
RUN $CHECK_STATUS_THEN mkdir -p logs/pkgs; rm -f config.log; ln -s logs/pkgs/config.log config.log
ARG EXTRA_CONFIGURE_ARGS=""
EOF
if [ ${WITH_SYSTEM_SPKG} = "force" ]; then
cat <<EOF
$RUN echo "****** Configuring: ./configure --enable-build-as-root $CONFIGURE_ARGS \${EXTRA_CONFIGURE_ARGS} *******"; ./configure --enable-build-as-root $CONFIGURE_ARGS \${EXTRA_CONFIGURE_ARGS} || (echo "********** configuring without forcing ***********"; echo "::group::config.log"; cat config.log; echo "::endgroup::"; ./configure --enable-build-as-root; echo "::group::config.log"; cat config.log; echo "::endgroup::"; exit 1) $ENDRUN
$RUN echo "****** Configuring: ./configure --enable-build-as-root $CONFIGURE_ARGS \${EXTRA_CONFIGURE_ARGS} *******"; ./configure --enable-build-as-root $CONFIGURE_ARGS \${EXTRA_CONFIGURE_ARGS} || (echo "********** configuring without forcing ***********"; echo "::group::config.log"; cat config.log; echo "::endgroup::"; ./configure --enable-build-as-root; echo "::group::config.log"; cat config.log; echo "::endgroup::"; exit 1) $ENDRUN $THEN_SAVE_STATUS
EOF
else
cat <<EOF
$RUN echo "****** Configuring: ./configure --enable-build-as-root $CONFIGURE_ARGS \${EXTRA_CONFIGURE_ARGS} *******"; ./configure --enable-build-as-root $CONFIGURE_ARGS \${EXTRA_CONFIGURE_ARGS} || (echo "::group::config.log"; cat config.log; echo "::endgroup::"; exit 1) $ENDRUN
$RUN echo "****** Configuring: ./configure --enable-build-as-root $CONFIGURE_ARGS \${EXTRA_CONFIGURE_ARGS} *******"; ./configure --enable-build-as-root $CONFIGURE_ARGS \${EXTRA_CONFIGURE_ARGS} || (echo "::group::config.log"; cat config.log; echo "::endgroup::"; exit 1) $ENDRUN $THEN_SAVE_STATUS
EOF
fi
cat <<EOF
Expand All @@ -256,7 +268,7 @@ ARG USE_MAKEFLAGS="-k V=0"
ENV SAGE_CHECK=warn
ENV SAGE_CHECK_PACKAGES="!cython,!r,!python3,!gap,!cysignals,!linbox,!git,!ppl,!cmake,!rpy2,!sage_sws2rst"
#:toolchain:
$RUN make \${USE_MAKEFLAGS} base-toolchain $ENDRUN
$RUN $CHECK_STATUS_THEN make \${USE_MAKEFLAGS} base-toolchain $ENDRUN $THEN_SAVE_STATUS

FROM with-base-toolchain as with-targets-pre
ARG NUMPROC=8
Expand All @@ -266,7 +278,7 @@ ENV SAGE_CHECK=warn
ENV SAGE_CHECK_PACKAGES="!cython,!r,!python3,!gap,!cysignals,!linbox,!git,!ppl,!cmake,!rpy2,!sage_sws2rst"
#:make:
ARG TARGETS_PRE="all-sage-local"
$RUN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS_PRE} $ENDRUN
$RUN $CHECK_STATUS_THEN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS_PRE} $ENDRUN $THEN_SAVE_STATUS

FROM with-targets-pre as with-targets
ARG NUMPROC=8
Expand All @@ -276,7 +288,7 @@ ENV SAGE_CHECK=warn
ENV SAGE_CHECK_PACKAGES="!cython,!r,!python3,!gap,!cysignals,!linbox,!git,!ppl,!cmake,!rpy2,!sage_sws2rst"
$ADD src src
ARG TARGETS="build"
$RUN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS} $ENDRUN
$RUN $CHECK_STATUS_THEN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS} $ENDRUN $THEN_SAVE_STATUS

FROM with-targets as with-targets-optional
ARG NUMPROC=8
Expand All @@ -285,7 +297,7 @@ ARG USE_MAKEFLAGS="-k V=0"
ENV SAGE_CHECK=warn
ENV SAGE_CHECK_PACKAGES="!cython,!r,!python3,!gap,!cysignals,!linbox,!git,!ppl,!cmake,!rpy2,!sage_sws2rst"
ARG TARGETS_OPTIONAL="ptest"
$RUN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS_OPTIONAL} || echo "(error ignored)" $ENDRUN
$RUN $CHECK_STATUS_THEN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS_OPTIONAL} || echo "(error ignored)" $ENDRUN $THEN_SAVE_STATUS

#:end:
EOF
6 changes: 3 additions & 3 deletions build/pkgs/info/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=texinfo-VERSION.tar.xz
sha1=ce3776715e655400485381b8ae94e34c5632e729
md5=a91b404e30561a5df803e6eb3a53be71
cksum=3632265516
sha1=356a623b88401d7c993408f33450c8104aad9df8
md5=37bf94fd255729a14d4ea3dda119f81a
cksum=1448415744
upstream_url=https://ftp.gnu.org/gnu/texinfo/texinfo-VERSION.tar.xz
2 changes: 1 addition & 1 deletion build/pkgs/info/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.8
7.0.3
38 changes: 30 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ passenv =
docker: EXTRA_DOCKER_BUILD_ARGS
docker: EXTRA_DOCKER_TAGS
docker: DOCKER_TAG
# Use DOCKER_BUILDKIT=1 for new version - for which unfortunately we cannot save failed builds as an image
# Use DOCKER_BUILDKIT=0 for legacy builder
docker: DOCKER_BUILDKIT
docker: BUILDKIT_INLINE_CACHE
# Set for example to "with-system-packages configured with-targets-pre with-targets"
Expand Down Expand Up @@ -756,7 +756,7 @@ commands =
docker: BUILD_IMAGE=$DOCKER_PUSH_REPOSITORY$BUILD_IMAGE_STEM-$docker_target; \
docker: BUILD_TAG={env:DOCKER_TAG:$(git describe --dirty --always)}; \
docker: TAG_ARGS=$(for tag in $BUILD_TAG {env:EXTRA_DOCKER_TAGS:}; do echo --tag $BUILD_IMAGE:$tag; done); \
docker: DOCKER_BUILDKIT={env:DOCKER_BUILDKIT:0} \
docker: DOCKER_BUILDKIT={env:DOCKER_BUILDKIT:1}; \
docker: docker build . -f {envdir}/Dockerfile \
docker: --target $docker_target \
docker: $TAG_ARGS \
Expand All @@ -768,16 +768,38 @@ 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: BUILD_TAG="$BUILD_TAG-failed"; docker commit $(docker ps -l -q) $BUILD_IMAGE:$BUILD_TAG; PUSH_TAGS=$BUILD_IMAGE:$BUILD_TAG; \
docker: else \
docker: PUSH_TAGS=$(echo $BUILD_IMAGE:$BUILD_TAG; for tag in {env:EXTRA_DOCKER_TAGS:}; do echo "$BUILD_IMAGE:$tag"; done); \
docker: if [ $DOCKER_BUILDKIT = 0 ]; then \
docker: BUILD_TAG="$BUILD_TAG-failed"; CONTAINER=$(docker ps -l -q); docker commit $CONTAINER $BUILD_IMAGE:$BUILD_TAG; \
docker: else \
docker: unset BUILD_TAG; echo "DOCKER_BUILDKIT=1, so we cannot commit and tag the failed image"; \
docker: fi; \
docker: fi; \
docker: echo $BUILD_IMAGE:$BUILD_TAG >> {envdir}/Dockertags; \
docker: if [ x"{env:DOCKER_PUSH_REPOSITORY:}" != x ]; then \
docker: if [ -n "$BUILD_TAG" ]; then \
docker: echo "Copying logs from the container to {envdir}/sage/"; \
docker: rm -f {envdir}/sage/STATUS; \
docker: docker run $BUILD_IMAGE:$BUILD_TAG bash -c " \
docker: tar -c --ignore-failed-read -f - \
docker: /sage/STATUS /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: if [ -f {envdir}/sage/STATUS ]; then status=$(cat {envdir}/sage/STATUS); fi; \
docker: fi; \
docker: unset PUSH_TAGS; \
docker: if [ -n "$BUILD_TAG" ]; then \
docker: if [ $status != 0 ]; then \
docker: BUILD_TAG="${BUILD_TAG%-failed}-failed"; PUSH_TAGS=$BUILD_IMAGE:$BUILD_TAG; \
docker: else \
docker: PUSH_TAGS=$(echo $BUILD_IMAGE:$BUILD_TAG; for tag in {env:EXTRA_DOCKER_TAGS:}; do echo "$BUILD_IMAGE:$tag"; done); \
docker: fi; \
docker: echo $BUILD_IMAGE:$BUILD_TAG >> {envdir}/Dockertags; \
docker: fi; \
docker: if [ x"{env:DOCKER_PUSH_REPOSITORY:}" != x -a x"$PUSH_TAGS" != x ]; then \
docker: echo Pushing $PUSH_TAGS; \
docker: for tag in $PUSH_TAGS; do \
docker: docker push $tag || echo "(ignoring errors)"; \
docker: if docker push $tag; then echo $tag >> {envdir}/Dockertags.pushed; else echo "(ignoring errors)"; fi; \
docker: done; \
docker: fi; \
docker: if [ $status != 0 ]; then exit $status; fi; \
Expand Down