Skip to content

Commit 7da5efe

Browse files
committed
Add comments
1 parent 39ebbe4 commit 7da5efe

File tree

2 files changed

+120
-71
lines changed

2 files changed

+120
-71
lines changed

.github/workflows/docker.yml

Lines changed: 88 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -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,67 @@ 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 'grep -l "[m][a][k][e]" {} | cut -d/ -f3 | xargs --no-run-if-empty kill' \;
272+
done
273+
) &
274+
# Set pipeline to fail if any command fails
275+
set -o pipefail
276+
#
277+
EXTRA_DOCKER_BUILD_ARGS="--build-arg NUMPROC=9 --build-arg USE_MAKEFLAGS=\"-k V=0 SAGE_NUM_THREADS=5\""
278+
#
279+
# The tox command starts to build and test Sage within a Docker container.
280+
#
281+
# Adter the build, the sed command strips away timestamps from
282+
# "docker build" (buildkit) such as "#25 1211.0" at the beginning of
283+
# each line. The timestamps are redundant because GH Actions provides
284+
# timestamps for each line already. Stripping the timestamps from
285+
# the beginnings of lines also allows GitHub Actions to recognize
286+
# workflow commands such as ::error etc. The other sed commands
287+
# annotate configuration notices/warnings/errors as GitHub
288+
# ::warning/::warning/::error respectively.
289+
#
290+
tox -e $TOX_ENV -- $TARGETS 2>&1 | sed -E --unbuffered "
291+
s/^#[0-9]+ [0-9]+[.][0-9]+ //
292+
/^configure: notice:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|
293+
/^configure: warning:/s|^|::warning file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|
294+
/^configure: error:/s|^|::error file=artifacts/$LOGS_ARTIFACT_NAME/config.log::|
295+
"
257296
- name: Copy logs from the Docker image or build container
258297
run: |
259298
mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"
260299
cp -r .tox/$TOX_ENV/* "artifacts/$LOGS_ARTIFACT_NAME"
261300
rm -rf "artifacts/$LOGS_ARTIFACT_NAME"/{bin,lib,pyvenv.cfg}
262301
if: always()
302+
263303
- uses: actions/upload-artifact@v4
264304
with:
265305
path: artifacts
266306
name: ${{ env.LOGS_ARTIFACT_NAME }}
267307
if: always()
308+
268309
- name: Print out logs for immediate inspection
269310
# and markup the output with GitHub Actions logging commands
270311
run: |
271312
.github/workflows/scan-logs.sh "artifacts/$LOGS_ARTIFACT_NAME"
272313
if: always()
314+
273315
- name: List Docker images
274316
run: |
275317
if [ -n "$DOCKER_PUSH_REPOSITORY" -a -f .tox/$TOX_ENV/Dockertags.pushed ]; then

build/make/Makefile.in

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,29 @@ $(foreach pkgname,$(PIP_PACKAGES),\
187187
$(SAGE_LOCAL)/$(SPKG_INST_RELDIR)/.dummy:
188188
touch $@
189189

190-
191-
# Filtered by installation tree
190+
# Define variables
191+
#
192+
# SAGE_LOCAL_INSTALLED_PACKAGE_INSTS
193+
# SAGE_VENV_INSTALLED_PACKAGE_INSTS
194+
# SAGE_DOCS_INSTALLED_PACKAGE_INSTS
195+
#
196+
# SAGE_LOCAL_UNINSTALLED_PACKAGE_UNINSTALLS
197+
# SAGE_VENV_UNINSTALLED_PACKAGE_UNINSTALLS
198+
# SAGE_DOCS_UNINSTALLED_PACKAGE_UNINSTALLS
199+
#
200+
# that list targets for packages to be installed/uninstalled into installation
201+
# tree SAGE_LOCAL/SAGE_VENV/SAGE_DOCS
192202
$(foreach tree,SAGE_LOCAL SAGE_VENV SAGE_DOCS, \
193203
$(eval $(tree)_INSTALLED_PACKAGE_INSTS = \
194204
$(foreach pkgname,$(INSTALLED_PACKAGES), \
195205
$(if $(findstring $(tree),$(trees_$(pkgname))), \
196206
$(inst_$(pkgname))))) \
197207
$(eval $(tree)_UNINSTALLED_PACKAGE_UNINSTALLS = \
198-
$(foreach pkgname,$(INSTALLED_PACKAGES), \
208+
$(foreach pkgname,$(UNINSTALLED_PACKAGES), \
199209
$(if $(findstring $(tree),$(trees_$(pkgname))), \
200-
$(inst_$(pkgname))))))
201-
210+
$($(pkgname)-uninstall)))))
202211

203-
###############################################################################
212+
# ==============================================================================
204213

205214
# Silent rules
206215
# https://www.gnu.org/software/automake/manual/html_node/Automake-Silent-Rules.html
@@ -277,8 +286,8 @@ base-toolchain: _clean-broken-gcc base
277286

278287
# All targets except for the base packages and except the documentation
279288
all-sage: \
280-
$(SAGE_LOCAL_INSTALLED_PACKAGE_INSTS) $(SAGE_LOCAL_UNINSTALLED_PACKAGES_UNINSTALLS) \
281-
$(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_UNINSTALLED_PACKAGES_UNINSTALLS)
289+
$(SAGE_LOCAL_INSTALLED_PACKAGE_INSTS) $(SAGE_LOCAL_UNINSTALLED_PACKAGES_UNINSTALLS) \
290+
$(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_UNINSTALLED_PACKAGES_UNINSTALLS)
282291

283292
# Same but filtered by installation trees:
284293
all-build-local: toolchain-deps
@@ -289,12 +298,12 @@ all-sage-local: $(SAGE_LOCAL_INSTALLED_PACKAGE_INSTS) $(SAGE_LOCAL_UNINSTALLED_P
289298
all-build-venv: toolchain-deps
290299
+$(MAKE_REC) all-sage-venv
291300

292-
all-sage-venv: $(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_UNINSTALLED_PACKAGES_UNINSTALLS)
301+
all-sage-venv: $(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_UNINSTALLED_PACKAGES_UNINSTALLS)
293302

294303
all-build-docs: toolchain-deps
295304
+$(MAKE_REC) all-sage-docs
296305

297-
all-sage-docs: $(SAGE_DOCS_INSTALLED_PACKAGE_INSTS) $(SAGE_DOCS_UNINSTALLED_PACKAGES_UNINSTALLS)
306+
all-sage-docs: $(SAGE_DOCS_INSTALLED_PACKAGE_INSTS) $(SAGE_DOCS_UNINSTALLED_PACKAGES_UNINSTALLS)
298307

299308
# Download all packages which should be inside an sdist tarball (the -B
300309
# option to make forces all targets to be built unconditionally)
@@ -343,17 +352,15 @@ SAGERUNTIME = sagelib $(inst_ipython) $(inst_pexpect)
343352
all-sageruntime: toolchain-deps
344353
+$(MAKE_REC) $(SAGERUNTIME)
345354

346-
347-
###############################################################################
355+
# ==============================================================================
348356
# Building the base system
349357
#
350358
# This consists of packages which are required for the Sage build system.
351-
###############################################################################
359+
# ==============================================================================
352360
base: $(inst_patch) $(inst_pkgconf)
353361

354-
###############################################################################
362+
# ==============================================================================
355363
# Building the documentation
356-
###############################################################################
357364

358365
# You can choose to have the built HTML version of the documentation link to
359366
# the PDF version. To do so, you need to build both the HTML and PDF versions.
@@ -365,7 +372,7 @@ base: $(inst_patch) $(inst_pkgconf)
365372
# For more information on the docbuild utility, do
366373
#
367374
# $ ./sage --docbuild -H
368-
375+
# ==============================================================================
369376
doc: doc-html
370377

371378
# All doc-building is delegated to the script packages
@@ -481,9 +488,9 @@ wheels:
481488

482489
pypi-wheels-check: $(PYPI_WHEEL_PACKAGES:%=%-check)
483490

484-
#==============================================================================
491+
# ==============================================================================
485492
# Setting SAGE_CHECK... variables
486-
#==============================================================================
493+
# ==============================================================================
487494
ifeq "$(origin SAGE_CHECK)" "undefined"
488495
SAGE_CHECK := no
489496
endif
@@ -525,10 +532,9 @@ $(foreach clause, $(SAGE_CHECK_PACKAGES_sep), \
525532
debug-check:
526533
@echo $(foreach pkgname, $(NORMAL_PACKAGES) $(SCRIPT_PACKAGES), SAGE_CHECK_$(pkgname) = $(SAGE_CHECK_$(pkgname)))
527534

528-
529-
#==============================================================================
535+
# ==============================================================================
530536
# Rules generated from pkgs/<package>/dependencies files
531-
#==============================================================================
537+
# ==============================================================================
532538

533539
# Define a function for generating the list of a package's dependencies
534540
# as $(inst_<pkgname>) variables. For example, takes:
@@ -595,7 +601,7 @@ pkg_deps = \
595601
# sage-spkg, and --keep-files to sage-spkg-uninstall since those packages can
596602
# have a recursive self-dependency, and should not be deleted while upgrading.
597603
# See Issue #25857
598-
604+
#
599605
# Positional arguments:
600606
# $(1): package name
601607
# $(2): package version
@@ -657,7 +663,7 @@ $(foreach pkgname, $(NORMAL_PACKAGES),\
657663
$(call pkg_deps,$(pkgname)),$(tree)))))
658664
endif
659665

660-
# ================================ pip packages ===============================
666+
# ================================ pip packages ====================================
661667
# Generate build rules for 'pip' packages; this template is used to generate
662668
# two rules in the form:
663669
#
@@ -666,10 +672,11 @@ endif
666672
#
667673
# <pkgname>-uninstall:
668674
# -sage --pip uninstall -y ...
669-
675+
#
670676
# Positional arguments:
671677
# $(1): package name
672678
# $(2): package dependencies
679+
673680
define PIP_PACKAGE_templ
674681
$(1)-build-deps: $(2)
675682

@@ -719,7 +726,7 @@ endif
719726
# . '$SAGE_ROOT/build/bin/sage-build-env-config' && \\
720727
# . '$SAGE_ROOT/build/bin/sage-build-env' && \\
721728
# '$SAGE_ROOT/build/pkgs/$PKG_NAME/spkg-uninstall'
722-
729+
#
723730
# Positional arguments:
724731
# $(1): package name
725732
# $(2): package version

0 commit comments

Comments
 (0)