Skip to content

Commit 4faf2ae

Browse files
author
Release Manager
committed
sagemathgh-36452: `make sagemath_categories-check`, `make pypi-wheels-check` <!-- ^^^^^ 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 sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> We add `make` targets for testing wheel-building script packages that have already been installed. For example: ``` $ make SAGE_WHEELS=yes sagemath_categories # builds and stores (but does not install) a wheel $ make sagemath_categories-check # tests the wheel using tox ``` The target `make pypi-wheels-check` calls all of them. We restructure the Build & Test CI so that all tests are run after build has been completed. Later, as a follow up of this and sagemath#36446, we can store the result of Build as a container image and then parallelize the various tests on top of it. This is implemented on top of an improvement of how we record information on our wheels. ``` $ cat venv/var/lib/sage/scripts/sagemath_categories/spkg- requirements.txt sagemath_categories @ file:///Users/mkoeppe/s/sage/sage- rebasing/worktree-algebraic-2018-spring/local/var/lib/sage/venv-python3. 11/var/lib/sage/wheels/sagemath_categories-10.2b6-cp311-cp311- macosx_13_0_x86_64.whl ``` Previously, this information was only known during the execution of the `spkg-install` script. In a follow-up, we can address sagemath#30956 by delaying the wheel installation to spkg-postinst. <!-- 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 sagemath#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 - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36452 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee, Matthias Köppe
2 parents 9088b6c + 8224cb0 commit 4faf2ae

File tree

11 files changed

+104
-68
lines changed

11 files changed

+104
-68
lines changed

.github/workflows/build.yml

+24-5
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,19 @@ jobs:
8585
(cd worktree-image && git commit -q -m "current changes" --allow-empty -a && git am; git reset --quiet old; git add -N .) < upstream/ci_fixes.patch
8686
fi
8787
88-
- name: Incremental build, test changed files (sage -t --new)
88+
- name: Incremental build
8989
id: incremental
9090
run: |
9191
# Now re-bootstrap and build. The build is incremental because we were careful with the timestamps.
92-
# We run tests with "sage -t --new"; this only tests the uncommitted changes.
93-
./bootstrap && make build && ./sage -t --new -p2
92+
./bootstrap && make build
9493
working-directory: ./worktree-image
9594
env:
9695
MAKE: make -j2 --output-sync=recurse
9796
SAGE_NUM_THREADS: 2
9897

99-
- name: Build and test modularized distributions
98+
- name: Build modularized distributions
10099
if: always() && steps.worktree.outcome == 'success'
101-
run: make V=0 tox && make pypi-wheels
100+
run: make V=0 tox && make SAGE_CHECK=no pypi-wheels
102101
working-directory: ./worktree-image
103102
env:
104103
MAKE: make -j2 --output-sync=recurse
@@ -143,6 +142,26 @@ jobs:
143142
MAKE: make -j2 --output-sync=recurse
144143
SAGE_NUM_THREADS: 2
145144

145+
# Testing
146+
147+
- name: Test changed files (sage -t --new)
148+
if: always() && steps.build.outcome == 'success'
149+
run: |
150+
# We run tests with "sage -t --new"; this only tests the uncommitted changes.
151+
./sage -t --new -p2
152+
working-directory: ./worktree-image
153+
env:
154+
MAKE: make -j2 --output-sync=recurse
155+
SAGE_NUM_THREADS: 2
156+
157+
- name: Test modularized distributions
158+
if: always() && steps.build.outcome == 'success'
159+
run: make V=0 tox && make pypi-wheels-check
160+
working-directory: ./worktree-image
161+
env:
162+
MAKE: make -j2 --output-sync=recurse
163+
SAGE_NUM_THREADS: 2
164+
146165
- name: Pytest
147166
if: contains(github.ref, 'pytest')
148167
run: |

build/bin/sage-dist-helpers

+9-6
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,15 @@ sdh_store_wheel() {
327327
mkdir -p "${SAGE_DESTDIR}${SAGE_SPKG_WHEELS}" && \
328328
$sudo mv "$wheel" "${SAGE_DESTDIR}${SAGE_SPKG_WHEELS}/" || \
329329
sdh_die "Error storing $wheel"
330-
wheel="${SAGE_DESTDIR}${SAGE_SPKG_WHEELS}/${wheel##*/}"
330+
wheel="${SAGE_SPKG_WHEELS}/${wheel##*/}"
331+
if [ -n "${SAGE_SPKG_SCRIPTS}" -a -n "${PKG_BASE}" ]; then
332+
wheel_basename="${wheel##*/}"
333+
distname="${wheel_basename%%-*}"
334+
# Record name and wheel file location
335+
mkdir -p ${SAGE_DESTDIR}${SAGE_SPKG_SCRIPTS}/${PKG_BASE}
336+
echo "${distname} @ file://${wheel}" >> ${SAGE_DESTDIR}${SAGE_SPKG_SCRIPTS}/${PKG_BASE}/spkg-requirements.txt
337+
fi
338+
wheel="${SAGE_DESTDIR}${wheel}"
331339
}
332340

333341
sdh_store_and_pip_install_wheel() {
@@ -379,11 +387,6 @@ sdh_store_and_pip_install_wheel() {
379387
fi
380388
$sudo sage-pip-install $root $pip_options "$wheel" || \
381389
sdh_die "Error installing ${wheel##*/}"
382-
if [ -n "${SAGE_PKG_DIR}" ]; then
383-
# Record name of installed distribution name for uninstallation.
384-
wheel=${wheel##*/}
385-
echo "${wheel%%-*}" >> ${SAGE_PKG_DIR}/spkg-piprm-requirements.txt
386-
fi
387390
}
388391

389392
sdh_pip_uninstall() {

build/bin/sage-spkg

+2-22
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ WRAPPED_SCRIPTS="build install check preinst postinst $INSTALLED_SCRIPTS"
548548

549549
# Prepare script for uninstallation of packages that use sdh_pip_install
550550
# or sdh_store_and_pip_install_wheel.
551-
echo 'sdh_pip_uninstall -r $SAGE_SPKG_SCRIPTS/$PKG_BASE/spkg-piprm-requirements.txt' > spkg-piprm.in
551+
echo 'sdh_pip_uninstall -r $SAGE_SPKG_SCRIPTS/$PKG_BASE/spkg-requirements.txt' > spkg-piprm.in
552552

553553
for script in $WRAPPED_SCRIPTS; do
554554
# 'Installed' scripts are not run immediately out of the package build
@@ -567,24 +567,6 @@ for script in $WRAPPED_SCRIPTS; do
567567
fi
568568
done
569569

570-
571-
# When there is no spkg-install, assume the "spkg" is a tarball not
572-
# specifically made for Sage. Since we want it to be as easy as
573-
# possible to install such a package, we "guess" spkg-install.
574-
if [ ! -f spkg-install ]; then
575-
echo '#!/usr/bin/env bash' > spkg-install
576-
if [ -x configure ]; then
577-
echo './configure --prefix="$SAGE_INST_LOCAL" && make && $SAGE_SUDO make install' >> spkg-install
578-
elif [ -f setup.py ]; then
579-
echo 'python setup.py install' >> spkg-install
580-
else
581-
echo >&2 "Error: There is no spkg-install script, no setup.py, and no configure"
582-
echo >&2 "script, so I do not know how to install $PKG_SRC."
583-
exit 1
584-
fi
585-
chmod +x spkg-install
586-
fi
587-
588570
echo "****************************************************"
589571
echo "Host system:"
590572
uname -a
@@ -722,9 +704,7 @@ unset SAGE_DESTDIR_LOCAL
722704
# removed by sage-spkg-uninstall
723705
INSTALLED_SCRIPTS_DEST="$SAGE_SPKG_SCRIPTS/$PKG_BASE"
724706

725-
if [ -f spkg-piprm-requirements.txt ]; then
726-
INSTALLED_SCRIPTS="$INSTALLED_SCRIPTS piprm-requirements.txt"
727-
else
707+
if [ ! -f $INSTALLED_SCRIPTS_DEST/spkg-requirements.txt ]; then
728708
# No packages to uninstall with pip, so remove the prepared uninstall script
729709
rm -f spkg-piprm spkg-piprm.in
730710
fi

build/make/Makefile.in

+29-1
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ wheels:
468468
$(MAKE_REC) SAGE_EDITABLE=no SAGE_WHEELS=yes $(WHEEL_PACKAGES)
469469
@echo "Built wheels are in venv/var/lib/sage/wheels/"
470470

471+
pypi-wheels-check: $(PYPI_WHEEL_PACKAGES:%=%-check)
472+
471473
#==============================================================================
472474
# Setting SAGE_CHECK... variables
473475
#==============================================================================
@@ -724,15 +726,21 @@ $(1)-$(4)-no-deps:
724726
echo "$$($(4)_DISABLED_MESSAGE)" 2>&1; \
725727
exit 1; \
726728
elif [ -x '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' ]; then \
729+
rm -rf '$$($(4))/var/lib/sage/scripts/$(1)'; \
727730
cd '$$(SAGE_ROOT)/build/pkgs/$(1)' && \
728731
. '$$(SAGE_ROOT)/src/bin/sage-src-env-config' && \
729732
. '$$(SAGE_ROOT)/src/bin/sage-env-config' && \
730733
. '$$(SAGE_ROOT)/src/bin/sage-env' && \
731734
. '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \
732735
. '$$(SAGE_ROOT)/build/bin/sage-build-env' && \
736+
PKG_BASE="$(1)" \
737+
PKG_VER="$(2)" \
738+
PKG_NAME="$(1)-$(2)" \
733739
SAGE_SPKG_WHEELS=$$($(4))/var/lib/sage/wheels \
740+
SAGE_SPKG_SCRIPTS=$$($(4))/var/lib/sage/scripts \
734741
SAGE_INST_LOCAL=$$($(4)) \
735-
sage-logger -p 'SAGE_CHECK=$$(SAGE_CHECK_$(1)) $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' '$$(SAGE_LOGS)/$(1)-$(2).log' && \
742+
SAGE_CHECK=$$(SAGE_CHECK_$(1)) \
743+
sage-logger -p '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install && if [ $$$$SAGE_CHECK != no -a -x $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-check ]; then $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-check; fi' '$$(SAGE_LOGS)/$(1)-$(2).log' && \
736744
rm -f "$$($(4))/$(SPKG_INST_RELDIR)/$(1)"-* && \
737745
touch "$$($(4))/$(SPKG_INST_RELDIR)/$(1)-$(2)"; \
738746
else ( \
@@ -752,6 +760,26 @@ $(1)-$(4)-no-deps:
752760

753761
$(1)-no-deps: $(1)-$(4)-no-deps
754762

763+
$(1)-$(4)-check:
764+
$(PLUS)@if [ -x $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-check ]; then \
765+
cd '$$(SAGE_ROOT)/build/pkgs/$(1)' && \
766+
. '$$(SAGE_ROOT)/src/bin/sage-src-env-config' && \
767+
. '$$(SAGE_ROOT)/src/bin/sage-env-config' && \
768+
. '$$(SAGE_ROOT)/src/bin/sage-env' && \
769+
. '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \
770+
. '$$(SAGE_ROOT)/build/bin/sage-build-env' && \
771+
PKG_BASE="$(1)" \
772+
PKG_VER="$(2)" \
773+
PKG_NAME="$(1)-$(2)" \
774+
SAGE_SPKG_WHEELS=$$($(4))/var/lib/sage/wheels \
775+
SAGE_SPKG_SCRIPTS=$$($(4))/var/lib/sage/scripts \
776+
SAGE_INST_LOCAL=$$($(4)) \
777+
SAGE_CHECK=$$(SAGE_CHECK_$(1)) \
778+
sage-logger -p '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-check' '$$(SAGE_LOGS)/$(1)-$(2).log'; \
779+
fi
780+
781+
$(1)-check: $(1)-$(4)-check
782+
755783
$(1)-$(4)-uninstall:
756784
-$(AM_V_at)cd '$$(SAGE_ROOT)/build/pkgs/$(1)' && \
757785
. '$$(SAGE_ROOT)/src/bin/sage-src-env-config' && \

build/pkgs/sage_sws2rst/spkg-check

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
#! /bin/sh
2-
cd src && ./check.sh
2+
cd src
3+
./check.sh
4+
if [ $? -ne 0 ]; then
5+
if [ "$SAGE_CHECK" = "warn" ]; then
6+
echo >&2 "Warning: Failures testing package $PKG_NAME (ignored)"
7+
else
8+
echo >&2 "Error testing package $PKG_NAME"
9+
exit 1
10+
fi
11+
fi

build/pkgs/sage_sws2rst/spkg-install

-10
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,3 @@ if [ "$SAGE_EDITABLE" = yes ]; then
1818
else
1919
sdh_pip_install .
2020
fi
21-
cd ..
22-
# For type=script packages, spkg-check is not run
23-
case "$SAGE_CHECK" in
24-
yes)
25-
./spkg-check
26-
;;
27-
warn)
28-
./spkg-check || echo >&2 "Warning: Failures testing package sage_sws2rst (ignored)"
29-
;;
30-
esac
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../sagemath_objects/spkg-check
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../sagemath_objects/spkg-check
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
cd src
3+
4+
export PIP_NO_INDEX=true
5+
export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS"
6+
7+
export TOX_PARALLEL_NO_SPINNER=1
8+
wheel="$(sed -n '1s,.*@ file://,,p' $SAGE_SPKG_SCRIPTS/$PKG_BASE/spkg-requirements.txt)"
9+
echo Running "tox -r -p auto -v --installpkg $wheel"
10+
tox -r -p auto -v --installpkg "$wheel"
11+
status=$?
12+
case $status:$SAGE_CHECK:$([ -r known-test-failures.json ]; echo $?) in
13+
0:*:0) echo "Passed the test suite (modulo baseline known-test-failures*.json)";;
14+
0:*:*) echo "Passed the test suite";;
15+
*:warn:0) echo "Warning: New failures (not in baseline known-test-failures*.json (ignored)"; status=0;;
16+
*:warn:*) echo "Warning: Failures testing the package (ignored)"; status=0;;
17+
*:yes:0) echo "New failures, not in baseline known-test-failures*.json";;
18+
*:yes:*) echo "Failures testing the package";;
19+
esac
20+
# Show summaries of failures (suppress lines ending with '[failed in baseline]')
21+
for f in $(pwd)/.tox/sagepython-sagewheels-nopypi-norequirements*/log/*-command*.log; do
22+
if [ -r "$f" ]; then
23+
echo "$f"
24+
grep '^sage -t.*#[^]]*$' "$f"
25+
fi
26+
done
27+
exit $status

build/pkgs/sagemath_objects/spkg-install

-23
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,3 @@ python3 -m build --outdir "$DIST_DIR"/dist . || sdh_die "Failure building sdist
2323

2424
wheel=$(cd "$DIST_DIR" && sdh_store_wheel . >&2 && echo $wheel)
2525
ls -l "$wheel"
26-
27-
if [ "$SAGE_CHECK" != no ]; then
28-
export TOX_PARALLEL_NO_SPINNER=1
29-
echo Running "tox -r -p auto -v --installpkg $wheel"
30-
tox -r -p auto -v --installpkg $wheel
31-
status=$?
32-
case $status:$SAGE_CHECK:$([ -r known-test-failures.json ]; echo $?) in
33-
0:*:0) echo "Passed the test suite (modulo baseline known-test-failures*.json)";;
34-
0:*:*) echo "Passed the test suite";;
35-
*:warn:0) echo "Warning: New failures (not in baseline known-test-failures*.json (ignored)"; status=0;;
36-
*:warn:*) echo "Warning: Failures testing the package (ignored)"; status=0;;
37-
*:yes:0) echo "New failures, not in baseline known-test-failures*.json";;
38-
*:yes:*) echo "Failures testing the package";;
39-
esac
40-
# Show summaries of failures (suppress lines ending with '[failed in baseline]')
41-
for f in $(pwd)/.tox/sagepython-sagewheels-nopypi-norequirements*/log/*-command*.log; do
42-
if [ -r "$f" ]; then
43-
echo "$f"
44-
grep '^sage -t.*#[^]]*$' "$f"
45-
fi
46-
done
47-
exit $status
48-
fi

build/pkgs/sagemath_repl/spkg-check

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../sagemath_objects/spkg-check

0 commit comments

Comments
 (0)