Skip to content

Commit 3abc045

Browse files
author
Release Manager
committed
gh-36970: CI: Upload test stats as artifacts, improve output of "List Docker images" <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> - `tox -e docker-....` now copies logs and stats from the image to the tox environment directory - CI Linux and CI Linux Incremental (via docker.yml) prepare the logs artifact from there (they used to be in charge of copying the logs from the image) - We switch from the legacy Docker builder to the current one ("buildkit"), avoiding deprecation warnings (e.g. https://github.com/sag emath/sage/actions/runs/7342841283/job/19992633064?pr=36977#step:11:29) - We also improve the output of the step "List Docker images": - It no longer advertises Docker images if they could not be pushed to the registry - see https://github.com/sagemath/sage/actions/runs/7335 489109/job/19973517180?pr=36970#step:15:60 - When it is able to push, it now shows instructions for developers what to do with them - see https://github.com/mkoeppe/sage/actions/runs /7345058426/job/19997709977#step:15:61 - and also creates an Annotation - see https://github.com/mkoeppe/sage/actions/runs/7345058426 - Just to trigger the CI Linux Incremental workflow here on the PR, we include the upgrade of the `info` package. In a follow-up: - We could store the stats in a persistent database <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36970 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee, Matthias Köppe
2 parents 93066db + 78f9f2e commit 3abc045

File tree

5 files changed

+97
-27
lines changed

5 files changed

+97
-27
lines changed

.github/workflows/docker.yml

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,8 @@ 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"
252+
rm -rf "artifacts/$LOGS_ARTIFACT_NAME"/{bin,lib,pyvenv.cfg}
254253
if: always()
255254
- uses: actions/upload-artifact@v3
256255
with:
@@ -262,9 +261,46 @@ jobs:
262261
run: |
263262
.github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
264263
if: always()
265-
- name: List docker images
264+
- name: List Docker images
266265
run: |
267-
if [ -f .tox/$TOX_ENV/Dockertags ]; then
268-
cat .tox/$TOX_ENV/Dockertags
266+
if [ -n "$DOCKER_PUSH_REPOSITORY" -a -f .tox/$TOX_ENV/Dockertags.pushed ]; then
267+
set -- $(cat .tox/$TOX_ENV/Dockertags.pushed)
268+
case $# in
269+
1) images="image"; one_image="the image";;
270+
*) images="images"; one_image="one of the images";;
271+
esac
272+
echo "::notice title=Docker $images pushed::Pushed $images $*)"
273+
echo
274+
echo "To pull $one_image and enter the container, type:"
275+
echo
276+
for TAG in $*; do
277+
echo " \$ docker run -it $TAG bash"
278+
done
279+
echo
280+
echo "To use $one_image as the base for an incremental build, type:"
281+
echo
282+
TOX_ENV_SANS_INCREMENTAL=${TOX_ENV/-incremental/}
283+
DOCKER_IMAGE=${TOX_ENV_SANS_INCREMENTAL#docker-}
284+
for TAG in $*; do
285+
echo -n " \$"
286+
if [ "$DOCKER_PUSH_REPOSITORY" != "ghcr.io/sagemath/sage/" ]; then
287+
echo -n " FROM_DOCKER_REPOSITORY=$DOCKER_PUSH_REPOSITORY"
288+
fi
289+
eval DOCKER_TARGET=\${TAG#*$DOCKER_IMAGE-}
290+
DOCKER_TARGET=${DOCKER_TARGET%:*}
291+
if [ "$DOCKER_TARGET" != "with-targets" ]; then
292+
echo -n " FROM_DOCKER_TARGET=$DOCKER_TARGET"
293+
fi
294+
echo " FROM_DOCKER_TAG=${TAG#*:} tox -e $TOX_ENV_SANS_INCREMENTAL-incremental"
295+
done
296+
elif [ -n "$DOCKER_PUSH_REPOSITORY" -a -f .tox/$TOX_ENV/Dockertags ]; then
297+
echo "Unable to push Docker images to $DOCKER_PUSH_REPOSITORY."
298+
echo "This is normal in a pull request to sagemath/sage or to another user's repository."
299+
echo
300+
echo "If you need Docker images, "
301+
echo " - either run this GitHub Actions workflow in your repository fork"
302+
echo " - or use the method described in https://doc.sagemath.org/html/en/developer/portability_testing.html#automatic-docker-based-build-testing-using-tox"
303+
else
304+
echo "No Docker images created."
269305
fi
270-
if: always()
306+
if: always() && ${{ inputs.docker_push_repository }}

build/bin/write-dockerfile.sh

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,18 @@ EOF
214214
;;
215215
esac
216216
esac
217+
218+
case ${DOCKER_BUILDKIT-0} in
219+
1)
220+
# With buildkit we cannot retrieve failed builds.
221+
# So we do not allow the main step of a build stage to fail.
222+
# Instead we record the exit code in the file STATUS.
223+
THEN_SAVE_STATUS='; echo $? > STATUS'
224+
# ... and at the beginning of the next build stage,
225+
# we check the status and exit with an error status.
226+
CHECK_STATUS_THEN='STATUS=$(cat STATUS 2>/dev/null); case "$STATUS" in ""|0) ;; *) exit $STATUS;; esac; '
227+
esac
228+
217229
cat <<EOF
218230
219231
FROM with-system-packages as bootstrapped
@@ -230,20 +242,20 @@ $ADD pkgs pkgs
230242
$ADD build ./build
231243
$ADD .upstream.d ./.upstream.d
232244
ARG BOOTSTRAP=./bootstrap
233-
$RUN sh -x -c "\${BOOTSTRAP}" $ENDRUN
245+
$RUN sh -x -c "\${BOOTSTRAP}" $ENDRUN $THEN_SAVE_STATUS
234246
235247
FROM bootstrapped as configured
236248
#:configuring:
237-
RUN mkdir -p logs/pkgs; rm -f config.log; ln -s logs/pkgs/config.log config.log
249+
RUN $CHECK_STATUS_THEN mkdir -p logs/pkgs; rm -f config.log; ln -s logs/pkgs/config.log config.log
238250
ARG EXTRA_CONFIGURE_ARGS=""
239251
EOF
240252
if [ ${WITH_SYSTEM_SPKG} = "force" ]; then
241253
cat <<EOF
242-
$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
254+
$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
243255
EOF
244256
else
245257
cat <<EOF
246-
$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
258+
$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
247259
EOF
248260
fi
249261
cat <<EOF
@@ -256,7 +268,7 @@ ARG USE_MAKEFLAGS="-k V=0"
256268
ENV SAGE_CHECK=warn
257269
ENV SAGE_CHECK_PACKAGES="!cython,!r,!python3,!gap,!cysignals,!linbox,!git,!ppl,!cmake,!rpy2,!sage_sws2rst"
258270
#:toolchain:
259-
$RUN make \${USE_MAKEFLAGS} base-toolchain $ENDRUN
271+
$RUN $CHECK_STATUS_THEN make \${USE_MAKEFLAGS} base-toolchain $ENDRUN $THEN_SAVE_STATUS
260272
261273
FROM with-base-toolchain as with-targets-pre
262274
ARG NUMPROC=8
@@ -266,7 +278,7 @@ ENV SAGE_CHECK=warn
266278
ENV SAGE_CHECK_PACKAGES="!cython,!r,!python3,!gap,!cysignals,!linbox,!git,!ppl,!cmake,!rpy2,!sage_sws2rst"
267279
#:make:
268280
ARG TARGETS_PRE="all-sage-local"
269-
$RUN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS_PRE} $ENDRUN
281+
$RUN $CHECK_STATUS_THEN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS_PRE} $ENDRUN $THEN_SAVE_STATUS
270282
271283
FROM with-targets-pre as with-targets
272284
ARG NUMPROC=8
@@ -276,7 +288,7 @@ ENV SAGE_CHECK=warn
276288
ENV SAGE_CHECK_PACKAGES="!cython,!r,!python3,!gap,!cysignals,!linbox,!git,!ppl,!cmake,!rpy2,!sage_sws2rst"
277289
$ADD src src
278290
ARG TARGETS="build"
279-
$RUN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS} $ENDRUN
291+
$RUN $CHECK_STATUS_THEN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS} $ENDRUN $THEN_SAVE_STATUS
280292
281293
FROM with-targets as with-targets-optional
282294
ARG NUMPROC=8
@@ -285,7 +297,7 @@ ARG USE_MAKEFLAGS="-k V=0"
285297
ENV SAGE_CHECK=warn
286298
ENV SAGE_CHECK_PACKAGES="!cython,!r,!python3,!gap,!cysignals,!linbox,!git,!ppl,!cmake,!rpy2,!sage_sws2rst"
287299
ARG TARGETS_OPTIONAL="ptest"
288-
$RUN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS_OPTIONAL} || echo "(error ignored)" $ENDRUN
300+
$RUN $CHECK_STATUS_THEN make SAGE_SPKG="sage-spkg -y -o" \${USE_MAKEFLAGS} \${TARGETS_OPTIONAL} || echo "(error ignored)" $ENDRUN $THEN_SAVE_STATUS
289301
290302
#:end:
291303
EOF

build/pkgs/info/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tarball=texinfo-VERSION.tar.xz
2-
sha1=ce3776715e655400485381b8ae94e34c5632e729
3-
md5=a91b404e30561a5df803e6eb3a53be71
4-
cksum=3632265516
2+
sha1=356a623b88401d7c993408f33450c8104aad9df8
3+
md5=37bf94fd255729a14d4ea3dda119f81a
4+
cksum=1448415744
55
upstream_url=https://ftp.gnu.org/gnu/texinfo/texinfo-VERSION.tar.xz

build/pkgs/info/package-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.8
1+
7.0.3

tox.ini

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ passenv =
143143
docker: EXTRA_DOCKER_BUILD_ARGS
144144
docker: EXTRA_DOCKER_TAGS
145145
docker: DOCKER_TAG
146-
# Use DOCKER_BUILDKIT=1 for new version - for which unfortunately we cannot save failed builds as an image
146+
# Use DOCKER_BUILDKIT=0 for legacy builder
147147
docker: DOCKER_BUILDKIT
148148
docker: BUILDKIT_INLINE_CACHE
149149
# Set for example to "with-system-packages configured with-targets-pre with-targets"
@@ -760,7 +760,7 @@ commands =
760760
docker: BUILD_IMAGE=$DOCKER_PUSH_REPOSITORY$BUILD_IMAGE_STEM-$docker_target; \
761761
docker: BUILD_TAG={env:DOCKER_TAG:$(git describe --dirty --always)}; \
762762
docker: TAG_ARGS=$(for tag in $BUILD_TAG {env:EXTRA_DOCKER_TAGS:}; do echo --tag $BUILD_IMAGE:$tag; done); \
763-
docker: DOCKER_BUILDKIT={env:DOCKER_BUILDKIT:0} \
763+
docker: DOCKER_BUILDKIT={env:DOCKER_BUILDKIT:1}; \
764764
docker: docker build . -f {envdir}/Dockerfile \
765765
docker: --target $docker_target \
766766
docker: $TAG_ARGS \
@@ -772,16 +772,38 @@ commands =
772772
docker: --build-arg TARGETS="{posargs:build}" \
773773
docker: --build-arg TARGETS_OPTIONAL="{env:TARGETS_OPTIONAL:ptest}" \
774774
docker: {env:EXTRA_DOCKER_BUILD_ARGS:}; status=$?; \
775+
docker: unset CONTAINER; \
775776
docker: if [ $status != 0 ]; then \
776-
docker: BUILD_TAG="$BUILD_TAG-failed"; docker commit $(docker ps -l -q) $BUILD_IMAGE:$BUILD_TAG; PUSH_TAGS=$BUILD_IMAGE:$BUILD_TAG; \
777-
docker: else \
778-
docker: PUSH_TAGS=$(echo $BUILD_IMAGE:$BUILD_TAG; for tag in {env:EXTRA_DOCKER_TAGS:}; do echo "$BUILD_IMAGE:$tag"; done); \
777+
docker: if [ $DOCKER_BUILDKIT = 0 ]; then \
778+
docker: BUILD_TAG="$BUILD_TAG-failed"; CONTAINER=$(docker ps -l -q); docker commit $CONTAINER $BUILD_IMAGE:$BUILD_TAG; \
779+
docker: else \
780+
docker: unset BUILD_TAG; echo "DOCKER_BUILDKIT=1, so we cannot commit and tag the failed image"; \
781+
docker: fi; \
779782
docker: fi; \
780-
docker: echo $BUILD_IMAGE:$BUILD_TAG >> {envdir}/Dockertags; \
781-
docker: if [ x"{env:DOCKER_PUSH_REPOSITORY:}" != x ]; then \
783+
docker: if [ -n "$BUILD_TAG" ]; then \
784+
docker: echo "Copying logs from the container to {envdir}/sage/"; \
785+
docker: rm -f {envdir}/sage/STATUS; \
786+
docker: docker run $BUILD_IMAGE:$BUILD_TAG bash -c " \
787+
docker: tar -c --ignore-failed-read -f - \
788+
docker: /sage/STATUS /sage/logs /sage/{prefix,venv}/var/lib/sage/installed \
789+
docker: ~/.sage/timings2.json /sage/pkgs/*/.tox/*/.sage/timings2.json \
790+
docker: /sage/pkgs/*/.tox/*/logs 2> /dev/null" \
791+
docker: | (cd {envdir} && tar xf -); \
792+
docker: if [ -f {envdir}/sage/STATUS ]; then status=$(cat {envdir}/sage/STATUS); fi; \
793+
docker: fi; \
794+
docker: unset PUSH_TAGS; \
795+
docker: if [ -n "$BUILD_TAG" ]; then \
796+
docker: if [ $status != 0 ]; then \
797+
docker: BUILD_TAG="${BUILD_TAG%-failed}-failed"; PUSH_TAGS=$BUILD_IMAGE:$BUILD_TAG; \
798+
docker: else \
799+
docker: PUSH_TAGS=$(echo $BUILD_IMAGE:$BUILD_TAG; for tag in {env:EXTRA_DOCKER_TAGS:}; do echo "$BUILD_IMAGE:$tag"; done); \
800+
docker: fi; \
801+
docker: echo $BUILD_IMAGE:$BUILD_TAG >> {envdir}/Dockertags; \
802+
docker: fi; \
803+
docker: if [ x"{env:DOCKER_PUSH_REPOSITORY:}" != x -a x"$PUSH_TAGS" != x ]; then \
782804
docker: echo Pushing $PUSH_TAGS; \
783805
docker: for tag in $PUSH_TAGS; do \
784-
docker: docker push $tag || echo "(ignoring errors)"; \
806+
docker: if docker push $tag; then echo $tag >> {envdir}/Dockertags.pushed; else echo "(ignoring errors)"; fi; \
785807
docker: done; \
786808
docker: fi; \
787809
docker: if [ $status != 0 ]; then exit $status; fi; \

0 commit comments

Comments
 (0)