Skip to content

Commit 8f57246

Browse files
committed
Copy of pr sagemath#35652
1 parent 3202f65 commit 8f57246

File tree

2 files changed

+47
-19
lines changed

2 files changed

+47
-19
lines changed

.github/workflows/build.yml

+46-18
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,52 @@ jobs:
3232
id: checkout
3333
uses: actions/checkout@v3
3434

35-
- name: Prepare
35+
- name: Update system packages
3636
id: prepare
3737
run: |
38-
# Install test tools.
39-
if apt-get update && apt-get install -y git python3-venv; then
40-
# Debian-specific temporary code:
41-
# Installation of python3-venv can be removed as soon as a
42-
# base image with a release including #33822 is available
43-
:
44-
else
45-
export PATH="build/bin:$PATH"
46-
eval $(sage-print-system-package-command auto update)
47-
eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git)
48-
fi
49-
# Reuse built SAGE_LOCAL contained in the Docker image
38+
export PATH="build/bin:$PATH"
39+
eval $(sage-print-system-package-command auto update)
40+
eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git)
41+
42+
- name: Incremental build and test
43+
if: always() && steps.prepare.outcome == 'success'
44+
id: incremental
45+
run: |
46+
set -ex
47+
git config --global user.email "[email protected]"
48+
git config --global user.name "Build & Test workflow"
49+
# If actions/checkout downloaded our source tree using the GitHub REST API
50+
# instead of with git (because do not have git installed in our image),
51+
# we first make the source tree a repo.
52+
if [ ! -d .git ]; then git config --global --add safe.directory $(pwd) && git init && git add -A && git commit --quiet -m "new"; fi
53+
# Tag this state of the source tree "new". This is what we want to build and test.
54+
git tag -f new
55+
# Our container image contains a source tree in /sage with a full build of Sage.
56+
# But /sage is not a git repository.
57+
# We make /sage a worktree whose index is at tag "new".
58+
# We then commit the current sources and set the tag "old". (This keeps all mtimes unchanged.)
59+
# Then we update worktree and index with "git reset --hard".
60+
# (This keeps mtimes of unchanged files unchanged and mtimes of changed files newer than unchanged files.)
61+
# Finally we reset the index to "old". (This keeps all mtimes unchanged.)
62+
# The changed files now show up as uncommitted changes.
63+
git worktree add --detach worktree-image
64+
rm -rf /sage/.git && mv worktree-image/.git /sage/
65+
rm -rf worktree-image && ln -s /sage worktree-image
66+
(cd worktree-image && git commit --allow-empty -m "old" -a && git tag -f old && git reset --hard new && git reset old)
67+
# Now re-bootstrap and build. The build is incremental because we were careful with the timestamps.
68+
# We run tests with "sage -t --new"; this only tests the uncommitted changes.
69+
(cd worktree-image && ./bootstrap && make build && ./sage -t --new -p2)
70+
env:
71+
MAKE: make -j2
72+
SAGE_NUM_THREADS: 2
73+
74+
- name: Configure new tree
75+
if: always() && steps.prepare.outcome == 'success'
76+
run: |
77+
# Reuse built SAGE_LOCAL contained in the Docker image
5078
./bootstrap
5179
./configure --enable-build-as-root --prefix=/sage/local --with-sage-venv --enable-editable --enable-download-from-upstream-url
52-
80+
5381
- name: Build and test modularized distributions
5482
if: always() && steps.prepare.outcome == 'success'
5583
run: make V=0 tox && make pypi-wheels
@@ -70,8 +98,8 @@ jobs:
7098

7199
- name: Static code check with pyright
72100
if: always() && steps.prepare.outcome == 'success'
73-
run: pyright
74-
101+
run: pyright
102+
75103
- name: Build
76104
id: build
77105
if: always() && steps.prepare.outcome == 'success'
@@ -94,7 +122,7 @@ jobs:
94122
if: always() && steps.build.outcome == 'success'
95123
run: |
96124
../sage -python -m pip install coverage
97-
../sage -python -m coverage run ./bin/sage-runtests --all -p2 --random-seed=286735480429121101562228604801325644303
125+
../sage -python -m coverage run ./bin/sage-runtests --all --long -p2
98126
working-directory: ./src
99127

100128
- name: Prepare coverage results
@@ -103,7 +131,7 @@ jobs:
103131
./venv/bin/python3 -m coverage combine src/.coverage/
104132
./venv/bin/python3 -m coverage xml
105133
find . -name *coverage*
106-
134+
107135
- name: Upload coverage to codecov
108136
if: always() && steps.build.outcome == 'success'
109137
uses: codecov/codecov-action@v3

src/sage/doctest/control.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def add_files(self):
791791
# SAGE_ROOT_GIT can be None on distributions which typically
792792
# only have the SAGE_LOCAL install tree but not SAGE_ROOT
793793
if SAGE_ROOT_GIT is not None:
794-
have_git = os.path.isdir(SAGE_ROOT_GIT)
794+
have_git = os.path.exists(SAGE_ROOT_GIT)
795795
else:
796796
have_git = False
797797

0 commit comments

Comments
 (0)