Skip to content

Commit 3506a07

Browse files
author
Release Manager
committed
sagemathgh-35373: Fix workflow "Build documentation (PDF)" <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes sagemath#12345", use "Add a new method to multiply two integers" --> ### 📚 Description Follow-up on sagemath#35169. The container `sage-docker-fedora-31-maximal-with-targets` used for the PDF docbuild turned out to be not reliable. Here we replace it by `ubuntu-focal-standard-with-targets` and install texlive in it. We also copy over the incremental build from doc-build.yml and the method to get CI fixes from blocker tickets from sagemath#36338. This workflow is currently disabled in sagemath/sage. Example run: https://github.com/mkoeppe/sage/actions/runs/6318741659/job/17158468016 <!-- Describe your changes here in detail. --> <!-- 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. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [ ] The description explains in detail what this PR is about. - [x] 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: ... --> - Depends on sagemath#36338 - Depends on sagemath#36348 <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#35373 Reported by: Matthias Köppe Reviewer(s): Dima Pasechnik
2 parents c7b19b2 + 7565e0c commit 3506a07

File tree

3 files changed

+112
-14
lines changed

3 files changed

+112
-14
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ jobs:
4141
- name: Store CI fixes in upstream artifact
4242
run: |
4343
mkdir -p upstream
44-
git format-patch --stdout test_base > upstream/ci_fixes.patch
44+
if git format-patch --stdout test_base > ci_fixes.patch; then
45+
cp ci_fixes.patch upstream/
46+
fi
4547
- uses: actions/upload-artifact@v3
4648
with:
4749
path: upstream

.github/workflows/doc-build-pdf.yml

Lines changed: 106 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,136 @@ on:
55
push:
66
workflow_dispatch:
77
# Allow to run manually
8+
inputs:
9+
platform:
10+
description: 'Platform'
11+
required: true
12+
default: 'ubuntu-focal-standard'
13+
docker_tag:
14+
description: 'Docker tag'
15+
required: true
16+
default: 'dev'
817

918
concurrency:
1019
# Cancel previous runs of this workflow for the same branch
1120
group: ${{ github.workflow }}-${{ github.ref }}
1221
cancel-in-progress: true
1322

1423
jobs:
15-
build-docs:
24+
get_ci_fixes:
1625
runs-on: ubuntu-latest
17-
# Use "maximal" so that texlive is installed
18-
# Use "fedora-31" for build diversity
19-
container: ghcr.io/sagemath/sage/sage-docker-fedora-31-maximal-with-targets:dev
2026
steps:
2127
- name: Checkout
28+
id: checkout
2229
uses: actions/checkout@v4
23-
2430
- name: Merge CI fixes from sagemath/sage
2531
run: |
2632
.ci/merge-fixes.sh
2733
env:
2834
GH_TOKEN: ${{ github.token }}
35+
- name: Store CI fixes in upstream artifact
36+
run: |
37+
mkdir -p upstream
38+
if git format-patch --stdout test_base > ci_fixes.patch; then
39+
cp ci_fixes.patch upstream/
40+
fi
41+
- uses: actions/upload-artifact@v3
42+
with:
43+
path: upstream
44+
name: upstream
2945

30-
- name: Prepare
46+
build-docs-pdf:
47+
runs-on: ubuntu-latest
48+
container: ghcr.io/sagemath/sage/sage-${{ github.event.inputs.platform || 'ubuntu-focal-standard' }}-with-targets:${{ github.event.inputs.docker_tag || 'dev'}}
49+
needs: [get_ci_fixes]
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Update system packages
55+
run: |
56+
export PATH="build/bin:$PATH"
57+
eval $(sage-print-system-package-command auto update)
58+
eval $(sage-print-system-package-command auto --yes --no-install-recommends install zip)
59+
eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git texlive)
60+
61+
62+
- name: Add prebuilt tree as a worktree
63+
id: worktree
3164
run: |
32-
apt-get update && apt-get install -y zip
33-
# Reuse built SAGE_LOCAL contained in the Docker image
34-
./bootstrap
35-
./configure --enable-build-as-root --prefix=/sage/local --with-sage-venv --enable-download-from-upstream-url
65+
set -ex
66+
git config --global user.email "[email protected]"
67+
git config --global user.name "Build & Test workflow"
68+
git config --global --add safe.directory $(pwd)
69+
# If actions/checkout downloaded our source tree using the GitHub REST API
70+
# instead of with git (because do not have git installed in our image),
71+
# we first make the source tree a repo.
72+
if [ ! -d .git ]; then git init && git add -A && git commit --quiet -m "new"; fi
73+
# Tag this state of the source tree "new". This is what we want to build and test.
74+
git tag -f new
75+
# Our container image contains a source tree in /sage with a full build of Sage.
76+
# But /sage is not a git repository.
77+
# We make /sage a worktree whose index is at tag "new".
78+
# We then commit the current sources and set the tag "old". (This keeps all mtimes unchanged.)
79+
# Then we update worktree and index with "git reset --hard new".
80+
# (This keeps mtimes of unchanged files unchanged and mtimes of changed files newer than unchanged files.)
81+
# Finally we reset the index to "old". (This keeps all mtimes unchanged.)
82+
# The changed files now show up as uncommitted changes.
83+
# The final "git add -N" makes sure that files that were added in "new" do not show
84+
# as untracked files, which would be removed by "git clean -fx".
85+
git worktree add --detach worktree-image
86+
rm -rf /sage/.git && mv worktree-image/.git /sage/
87+
rm -rf worktree-image && ln -s /sage worktree-image
88+
if [ ! -f worktree-image/.gitignore ]; then cp .gitignore worktree-image/; fi
89+
(cd worktree-image && git add -A && git commit --quiet --allow-empty -m "old" -a && git tag -f old && git reset --hard new && git reset --quiet old && git add -N . && git status)
90+
# Keep track of changes to built HTML
91+
new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old")
92+
93+
- name: Download upstream artifact
94+
uses: actions/download-artifact@v3
95+
with:
96+
path: upstream
97+
name: upstream
98+
99+
- name: Apply CI fixes from sagemath/sage
100+
# After applying the fixes, make sure all changes are marked as uncommitted changes.
101+
run: |
102+
if [ -r upstream/ci_fixes.patch ]; then
103+
(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
104+
fi
105+
106+
- name: Incremental build
107+
id: incremental
108+
run: |
109+
# Now re-bootstrap and build. The build is incremental because we were careful with the timestamps.
110+
./bootstrap && make build
111+
working-directory: ./worktree-image
112+
env:
113+
MAKE: make -j2
114+
SAGE_NUM_THREADS: 2
115+
116+
- name: Build (fallback to non-incremental)
117+
id: build
118+
if: always() && steps.worktree.outcome == 'success' && steps.incremental.outcome != 'success'
119+
run: |
120+
set -ex
121+
make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage && ./config.status && make build
122+
working-directory: ./worktree-image
123+
env:
124+
MAKE: make -j2
125+
SAGE_NUM_THREADS: 2
36126

37-
- name: Build
127+
- name: Build docs (PDF)
128+
id: docbuild
129+
if: always() && (steps.incremental.outcome == 'success' || steps.build.outcome == 'success')
38130
run: make build V=0 && make doc-pdf
131+
working-directory: ./worktree-image
39132
env:
40133
MAKE: make -j2
41134
SAGE_NUM_THREADS: 2
42-
TEXMFHOME: /sage/texmf
43135

44136
- name: Copy docs
137+
if: always() && steps.docbuild.outcome == 'success'
45138
run: |
46139
# For some reason the deploy step below cannot find /sage/...
47140
# So copy everything from there to local folder
@@ -51,6 +144,7 @@ jobs:
51144
zip -r docs-pdf.zip docs
52145
53146
- name: Upload docs
147+
if: always() && steps.copy.outcome == 'success'
54148
uses: actions/upload-artifact@v3
55149
with:
56150
name: docs-pdf

.github/workflows/doc-build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ jobs:
3030
- name: Store CI fixes in upstream artifact
3131
run: |
3232
mkdir -p upstream
33-
git format-patch --stdout test_base > upstream/ci_fixes.patch
33+
if git format-patch --stdout test_base > ci_fixes.patch; then
34+
cp ci_fixes.patch upstream/
35+
fi
3436
- uses: actions/upload-artifact@v3
3537
with:
3638
path: upstream

0 commit comments

Comments
 (0)