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