Skip to content

Commit 6df7a6a

Browse files
committed
Add comments
1 parent 766c7a0 commit 6df7a6a

File tree

2 files changed

+126
-73
lines changed

2 files changed

+126
-73
lines changed

.github/workflows/docker.yml

Lines changed: 89 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -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

build/make/Makefile.in

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,15 @@ GCC_DEP = @SAGE_GCC_DEP@
111111
OPTIONAL_INSTALLED_PACKAGES = @SAGE_OPTIONAL_INSTALLED_PACKAGES@
112112
INSTALLED_PACKAGES = $(OPTIONAL_INSTALLED_PACKAGES)
113113
INSTALLED_PACKAGE_INSTS = \
114-
$(foreach pkgname,$(INSTALLED_PACKAGES),$(inst_$(pkgname)))
114+
$(foreach pkgname,$(INSTALLED_PACKAGES),inst_$(pkgname))
115115

116116
# All previously installed standard/optional/experimental packages that are to be uninstalled
117117
OPTIONAL_UNINSTALLED_PACKAGES = @SAGE_OPTIONAL_UNINSTALLED_PACKAGES@
118118
UNINSTALLED_PACKAGES = $(OPTIONAL_UNINSTALLED_PACKAGES)
119-
UNINSTALLED_PACKAGES_UNINSTALLS = $(UNINSTALLED_PACKAGES:%=%-uninstall)
119+
UNINSTALLED_PACKAGE_UNINSTALLS = \
120+
$(foreach pkgname,$(UNINSTALLED_PACKAGES),$(pkgname)-uninstall)
121+
122+
.PHONY: $(INSTALLED_PACKAGE_INSTS) $(UNINSTALLED_PACKAGE_UNINSTALLS)
120123

121124
# All packages which should be downloaded
122125
SDIST_PACKAGES = @SAGE_SDIST_PACKAGES@
@@ -187,20 +190,29 @@ $(foreach pkgname,$(PIP_PACKAGES),\
187190
$(SAGE_LOCAL)/$(SPKG_INST_RELDIR)/.dummy:
188191
touch $@
189192

190-
191-
# Filtered by installation tree
193+
# Define variables
194+
#
195+
# SAGE_LOCAL_INSTALLED_PACKAGE_INSTS
196+
# SAGE_VENV_INSTALLED_PACKAGE_INSTS
197+
# SAGE_DOCS_INSTALLED_PACKAGE_INSTS
198+
#
199+
# SAGE_LOCAL_UNINSTALLED_PACKAGE_UNINSTALLS
200+
# SAGE_VENV_UNINSTALLED_PACKAGE_UNINSTALLS
201+
# SAGE_DOCS_UNINSTALLED_PACKAGE_UNINSTALLS
202+
#
203+
# that list targets for packages to be installed/uninstalled into installation
204+
# tree SAGE_LOCAL/SAGE_VENV/SAGE_DOCS
192205
$(foreach tree,SAGE_LOCAL SAGE_VENV SAGE_DOCS, \
193206
$(eval $(tree)_INSTALLED_PACKAGE_INSTS = \
194207
$(foreach pkgname,$(INSTALLED_PACKAGES), \
195208
$(if $(findstring $(tree),$(trees_$(pkgname))), \
196209
$(inst_$(pkgname))))) \
197210
$(eval $(tree)_UNINSTALLED_PACKAGE_UNINSTALLS = \
198-
$(foreach pkgname,$(INSTALLED_PACKAGES), \
211+
$(foreach pkgname,$(UNINSTALLED_PACKAGES), \
199212
$(if $(findstring $(tree),$(trees_$(pkgname))), \
200-
$(inst_$(pkgname))))))
201-
213+
$(pkgname)-uninstall))))
202214

203-
###############################################################################
215+
# ==============================================================================
204216

205217
# Silent rules
206218
# https://www.gnu.org/software/automake/manual/html_node/Automake-Silent-Rules.html
@@ -277,8 +289,8 @@ base-toolchain: _clean-broken-gcc base
277289

278290
# All targets except for the base packages and except the documentation
279291
all-sage: \
280-
$(SAGE_LOCAL_INSTALLED_PACKAGE_INSTS) $(SAGE_LOCAL_UNINSTALLED_PACKAGES_UNINSTALLS) \
281-
$(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_UNINSTALLED_PACKAGES_UNINSTALLS)
292+
$(SAGE_LOCAL_INSTALLED_PACKAGE_INSTS) $(SAGE_LOCAL_UNINSTALLED_PACKAGE_UNINSTALLS) \
293+
$(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_UNINSTALLED_PACKAGE_UNINSTALLS)
282294

283295
# Same but filtered by installation trees:
284296
all-build-local: toolchain-deps
@@ -289,12 +301,12 @@ all-sage-local: $(SAGE_LOCAL_INSTALLED_PACKAGE_INSTS) $(SAGE_LOCAL_UNINSTALLED_P
289301
all-build-venv: toolchain-deps
290302
+$(MAKE_REC) all-sage-venv
291303

292-
all-sage-venv: $(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_UNINSTALLED_PACKAGES_UNINSTALLS)
304+
all-sage-venv: $(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_UNINSTALLED_PACKAGES_UNINSTALLS)
293305

294306
all-build-docs: toolchain-deps
295307
+$(MAKE_REC) all-sage-docs
296308

297-
all-sage-docs: $(SAGE_DOCS_INSTALLED_PACKAGE_INSTS) $(SAGE_DOCS_UNINSTALLED_PACKAGES_UNINSTALLS)
309+
all-sage-docs: $(SAGE_DOCS_INSTALLED_PACKAGE_INSTS) $(SAGE_DOCS_UNINSTALLED_PACKAGES_UNINSTALLS)
298310

299311
# Download all packages which should be inside an sdist tarball (the -B
300312
# option to make forces all targets to be built unconditionally)
@@ -343,17 +355,15 @@ SAGERUNTIME = sagelib $(inst_ipython) $(inst_pexpect)
343355
all-sageruntime: toolchain-deps
344356
+$(MAKE_REC) $(SAGERUNTIME)
345357

346-
347-
###############################################################################
358+
# ==============================================================================
348359
# Building the base system
349360
#
350361
# This consists of packages which are required for the Sage build system.
351-
###############################################################################
362+
# ==============================================================================
352363
base: $(inst_patch) $(inst_pkgconf)
353364

354-
###############################################################################
365+
# ==============================================================================
355366
# Building the documentation
356-
###############################################################################
357367

358368
# You can choose to have the built HTML version of the documentation link to
359369
# the PDF version. To do so, you need to build both the HTML and PDF versions.
@@ -365,7 +375,7 @@ base: $(inst_patch) $(inst_pkgconf)
365375
# For more information on the docbuild utility, do
366376
#
367377
# $ ./sage --docbuild -H
368-
378+
# ==============================================================================
369379
doc: doc-html
370380

371381
# All doc-building is delegated to the script packages
@@ -481,9 +491,9 @@ wheels:
481491

482492
pypi-wheels-check: $(PYPI_WHEEL_PACKAGES:%=%-check)
483493

484-
#==============================================================================
494+
# ==============================================================================
485495
# Setting SAGE_CHECK... variables
486-
#==============================================================================
496+
# ==============================================================================
487497
ifeq "$(origin SAGE_CHECK)" "undefined"
488498
SAGE_CHECK := no
489499
endif
@@ -525,10 +535,9 @@ $(foreach clause, $(SAGE_CHECK_PACKAGES_sep), \
525535
debug-check:
526536
@echo $(foreach pkgname, $(NORMAL_PACKAGES) $(SCRIPT_PACKAGES), SAGE_CHECK_$(pkgname) = $(SAGE_CHECK_$(pkgname)))
527537

528-
529-
#==============================================================================
538+
# ==============================================================================
530539
# Rules generated from pkgs/<package>/dependencies files
531-
#==============================================================================
540+
# ==============================================================================
532541

533542
# Define a function for generating the list of a package's dependencies
534543
# as $(inst_<pkgname>) variables. For example, takes:
@@ -595,7 +604,7 @@ pkg_deps = \
595604
# sage-spkg, and --keep-files to sage-spkg-uninstall since those packages can
596605
# have a recursive self-dependency, and should not be deleted while upgrading.
597606
# See Issue #25857
598-
607+
#
599608
# Positional arguments:
600609
# $(1): package name
601610
# $(2): package version
@@ -657,7 +666,7 @@ $(foreach pkgname, $(NORMAL_PACKAGES),\
657666
$(call pkg_deps,$(pkgname)),$(tree)))))
658667
endif
659668

660-
# ================================ pip packages ===============================
669+
# ================================ pip packages ====================================
661670
# Generate build rules for 'pip' packages; this template is used to generate
662671
# two rules in the form:
663672
#
@@ -666,10 +675,11 @@ endif
666675
#
667676
# <pkgname>-uninstall:
668677
# -sage --pip uninstall -y ...
669-
678+
#
670679
# Positional arguments:
671680
# $(1): package name
672681
# $(2): package dependencies
682+
673683
define PIP_PACKAGE_templ
674684
$(1)-build-deps: $(2)
675685

@@ -719,7 +729,7 @@ endif
719729
# . '$SAGE_ROOT/build/bin/sage-build-env-config' && \\
720730
# . '$SAGE_ROOT/build/bin/sage-build-env' && \\
721731
# '$SAGE_ROOT/build/pkgs/$PKG_NAME/spkg-uninstall'
722-
732+
#
723733
# Positional arguments:
724734
# $(1): package name
725735
# $(2): package version

0 commit comments

Comments
 (0)