@@ -166,63 +166,80 @@ jobs:
166166 remove-docker-images : true
167167 continue-on-error : true
168168 if : inputs.free_disk_space
169+
169170 - name : Check out SageMath
170171 uses : actions/checkout@v4
171172 with :
172173 repository : ${{ inputs.sage_repo }}
173174 ref : ${{ inputs.sage_ref }}
174175 fetch-depth : 10000
176+
175177 - name : Download upstream artifact
176178 uses : actions/download-artifact@v4
177179 with :
178180 path : upstream
179181 name : ${{ inputs.upstream_artifact }}
180182 if : inputs.upstream_artifact
183+
181184 - name : Install test prerequisites
182185 run : |
183186 sudo DEBIAN_FRONTEND=noninteractive apt-get update
184187 sudo DEBIAN_FRONTEND=noninteractive apt-get install tox
185188 sudo apt-get clean
186189 df -h
190+
187191 - name : Update Sage packages from upstream artifact
188- # Handle both the old and new location of write-dockerfile.sh,
189- # because docker.yml is a reusable workflow.
190192 run : |
191- (export PATH=$(pwd)/build/bin:$PATH; (cd upstream && bash -x update-pkgs.sh) && sed -i.bak '/upstream/d' .dockerignore; for a in build/bin/write-dockerfile.sh .ci/write-dockerfile.sh; do if [ -r $a ]; then echo "/:toolchain:/i ADD upstream upstream" | sed -i.bak -f - $a; fi; done; git diff)
193+ export PATH=$(pwd)/build/bin:$PATH
194+ cd upstream && bash -x update-pkgs.sh
195+ # Remove any lines containing 'upstream' from .dockerignore
196+ sed -i.bak '/upstream/d' .dockerignore
197+ # Handle both the old and new location of write-dockerfile.sh, because docker.yml is a reusable workflow
198+ for script_path in build/bin/write-dockerfile.sh .ci/write-dockerfile.sh; do
199+ if [ -r "$script_path" ]; then
200+ # Add 'ADD upstream upstream' before the line containing ':toolchain:' in the script
201+ echo "/:toolchain:/i ADD upstream upstream" | sed -i.bak -f - "$script_path"
202+ fi
203+ done
204+ # Show the changes made to the repository for review
205+ git diff
192206 if : inputs.upstream_artifact
193207
194208 - name : Try to login to ghcr.io
195209 if : inputs.docker_push_repository != ''
196210 # https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
197211 run : |
198- TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
199- if [ -z "$TOKEN" ]; then
200- TOKEN="${{ secrets.GITHUB_TOKEN }}"
201- fi
202- if echo "$TOKEN" | docker login ghcr.io -u ${{ github.actor }} --password-stdin; then
203- echo "DOCKER_PUSH_REPOSITORY=$(echo ${{ inputs.docker_push_repository }} | tr "[:upper:]" "[:lower:]")" >> $GITHUB_ENV
204- echo "DOCKER_CONFIG_FILE=$HOME/.docker/config.json" >> $GITHUB_ENV
205- fi
212+ TOKEN="${{ secrets.DOCKER_PKG_GITHUB_TOKEN }}"
213+ if [ -z "$TOKEN" ]; then
214+ TOKEN="${{ secrets.GITHUB_TOKEN }}"
215+ fi
216+ if echo "$TOKEN" | docker login ghcr.io -u ${{ github.actor }} --password-stdin; then
217+ echo "DOCKER_PUSH_REPOSITORY=$(echo ${{ inputs.docker_push_repository }} | tr "[:upper:]" "[:lower:]")" >> $GITHUB_ENV
218+ echo "DOCKER_CONFIG_FILE=$HOME/.docker/config.json" >> $GITHUB_ENV
219+ fi
206220
207221 - name : Determine Docker tags to use
208222 run : |
209- # This line needs to be run before the step "Merge CI fixes from sagemath/sage".
210- DOCKER_TAG="$(git describe --dirty --always)"
211- echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
212- # From the docker documentation via .ci/update-env.sh:
213- # "A tag name must be valid ASCII and may
214- # contain lowercase and uppercase letters, digits, underscores, periods and
215- # dashes. A tag name may not start with a period or a dash and may contain a
216- # maximum of 128 characters."
217- EXTRA_DOCKER_TAGS=`echo $GITHUB_REF_NAME | tr -d '[:space:]' | tr -c '[:alnum:]_.-' '-' | sed 's/^[-.]*//' | cut -c1-128`
218- shopt -s extglob
219- case "$GITHUB_REF_NAME" in
220- +([0-9]).+([0-9])?(.+([0-9])) )
221- EXTRA_DOCKER_TAGS="latest dev $EXTRA_DOCKER_TAGS";;
222- +([0-9]).+([0-9])?(.+([0-9]))?(.)@(a|alpha|b|beta|rc)+([0-9]) )
223- EXTRA_DOCKER_TAGS="dev $EXTRA_DOCKER_TAGS";;
224- esac
225- echo "EXTRA_DOCKER_TAGS=$EXTRA_DOCKER_TAGS" >> $GITHUB_ENV
223+ # This line needs to be run before the step "Merge CI fixes from sagemath/sage".
224+ #
225+ DOCKER_TAG="$(git describe --dirty --always)"
226+ echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
227+ #
228+ # From the docker documentation via .ci/update-env.sh:
229+ # "A tag name must be valid ASCII and may
230+ # contain lowercase and uppercase letters, digits, underscores, periods and
231+ # dashes. A tag name may not start with a period or a dash and may contain a
232+ # maximum of 128 characters."
233+ #
234+ EXTRA_DOCKER_TAGS=`echo $GITHUB_REF_NAME | tr -d '[:space:]' | tr -c '[:alnum:]_.-' '-' | sed 's/^[-.]*//' | cut -c1-128`
235+ shopt -s extglob
236+ case "$GITHUB_REF_NAME" in
237+ +([0-9]).+([0-9])?(.+([0-9])) )
238+ EXTRA_DOCKER_TAGS="latest dev $EXTRA_DOCKER_TAGS";;
239+ +([0-9]).+([0-9])?(.+([0-9]))?(.)@(a|alpha|b|beta|rc)+([0-9]) )
240+ EXTRA_DOCKER_TAGS="dev $EXTRA_DOCKER_TAGS";;
241+ esac
242+ echo "EXTRA_DOCKER_TAGS=$EXTRA_DOCKER_TAGS" >> $GITHUB_ENV
226243
227244 - name : Merge CI fixes from sagemath/sage
228245 # This step needs to happen after the commit sha is put in DOCKER_TAG
@@ -237,43 +254,69 @@ jobs:
237254 run : |
238255 df -h
239256 if : inputs.free_disk_space
257+
240258 - name : Configure and build Sage distribution within a Docker container
241- # The first command below is a self-destruct sequence,
242- # which preempts the GitHub Actions 6-hour job cancellation.
243- #
244- # Using "docker exec", we enter the temporary containers used by
245- # "docker build" and kill the "make" processes of the Sage distribution.
246- #
247- # The arcane "find" command is a replacement for "pkill make",
248- # which we use because pkill is not installed in the "minimal" package
249- # configuration on many platforms.
250- #
251- # The "sed" command strips away timestamps from "docker build" (buildkit)
252- # such as "#25 1211.0" at the beginning of each line. The timestamps are
253- # redundant because GH Actions provides timestamps for each line already.
254- # Stripping the timestamps from the beginnings of lines also allows
255- # GitHub Actions to recognize workflow commands such as ::error etc.
256- #
257259 run : |
258- (sleep ${{ inputs.timeout }}; for id in $(docker ps -q); do docker exec $id find /proc -maxdepth 2 -name cmdline -exec bash -c "grep -l [m][a][k][e] {} | cut -d/ -f3 | xargs --no-run-if-empty kill" \;; done) &
259- set -o pipefail; EXTRA_DOCKER_BUILD_ARGS="--build-arg NUMPROC=9 --build-arg USE_MAKEFLAGS=\"-k V=0 SAGE_NUM_THREADS=5\"" tox -e $TOX_ENV -- $TARGETS 2>&1 | sed -E --unbuffered "s/^#[0-9]+ [0-9]+[.][0-9]+ //;/^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::|;"
260+ # The first command below is a self-destruct sequence,
261+ # which preempts the GitHub Actions 6-hour job cancellation.
262+ #
263+ # Using "docker exec", we enter the temporary containers used by
264+ # "docker build" and kill the "make" processes of the Sage distribution.
265+ (
266+ sleep ${{ inputs.timeout }}
267+ for container_id in $(docker ps -q); do
268+ #
269+ # The arcane "find" command is a replacement for "pkill make",
270+ # which we use because pkill is not installed in the "minimal" package
271+ # configuration on many platforms.
272+ #
273+ docker exec "$container_id" find /proc -maxdepth 2 -name cmdline \
274+ -exec bash -c 'grep -l "[m][a][k][e]" {} | cut -d/ -f3 | xargs --no-run-if-empty kill' \;
275+ done
276+ ) &
277+ # Set pipeline to fail if any command fails
278+ set -o pipefail
279+ #
280+ EXTRA_DOCKER_BUILD_ARGS="--build-arg NUMPROC=9 --build-arg USE_MAKEFLAGS=\"-k V=0 SAGE_NUM_THREADS=5\""
281+ #
282+ # The tox command starts to build and test Sage within a Docker container.
283+ #
284+ # Adter the build, the sed command strips away timestamps from
285+ # "docker build" (buildkit) such as "#25 1211.0" at the beginning of
286+ # each line. The timestamps are redundant because GH Actions provides
287+ # timestamps for each line already. Stripping the timestamps from
288+ # the beginnings of lines also allows GitHub Actions to recognize
289+ # workflow commands such as ::error etc. The other sed commands
290+ # annotate configuration notices/warnings/errors as GitHub
291+ # ::warning/::warning/::error respectively.
292+ #
293+ tox -e $TOX_ENV -- $TARGETS 2>&1 | sed -E --unbuffered "
294+ s/^#[0-9]+ [0-9]+[.][0-9]+ //
295+ /^configure: notice:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|
296+ /^configure: warning:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|
297+ /^configure: error:/s|^|::error file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|
298+ "
299+
260300 - name : Copy logs from the Docker image or build container
261301 run : |
262302 mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"
263303 cp -r .tox/$TOX_ENV/* "artifacts/$LOGS_ARTIFACT_NAME"
264304 rm -rf "artifacts/$LOGS_ARTIFACT_NAME"/{bin,lib,pyvenv.cfg}
265305 if : always()
306+
266307 - name : Upload logs artifact
267308 uses : actions/upload-artifact@v4
268309 with :
269310 path : artifacts
270311 name : ${{ env.LOGS_ARTIFACT_NAME }}
271312 if : always() && inputs.logs_artifact
313+
272314 - name : Print out logs for immediate inspection
273315 # and markup the output with GitHub Actions logging commands
274316 run : |
275317 .github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
276318 if : always()
319+
277320 - name : List Docker images
278321 run : |
279322 if [ -n "$DOCKER_PUSH_REPOSITORY" -a -f .tox/$TOX_ENV/Dockertags.pushed ]; then
0 commit comments