|
5 | 5 | push: |
6 | 6 | workflow_dispatch: |
7 | 7 | # 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' |
8 | 17 |
|
9 | 18 | concurrency: |
10 | 19 | # Cancel previous runs of this workflow for the same branch |
11 | 20 | group: ${{ github.workflow }}-${{ github.ref }} |
12 | 21 | cancel-in-progress: true |
13 | 22 |
|
14 | 23 | jobs: |
15 | | - build-docs: |
| 24 | + get_ci_fixes: |
16 | 25 | 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 |
20 | 26 | steps: |
21 | 27 | - name: Checkout |
| 28 | + id: checkout |
22 | 29 | uses: actions/checkout@v4 |
23 | | - |
24 | 30 | - name: Merge CI fixes from sagemath/sage |
25 | 31 | run: | |
26 | 32 | .ci/merge-fixes.sh |
27 | 33 | env: |
28 | 34 | 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 |
29 | 45 |
|
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 |
31 | 64 | 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 |
36 | 126 |
|
37 | | - - name: Build |
| 127 | + - name: Build docs (PDF) |
| 128 | + id: docbuild |
| 129 | + if: always() && (steps.incremental.outcome == 'success' || steps.build.outcome == 'success') |
38 | 130 | run: make build V=0 && make doc-pdf |
| 131 | + working-directory: ./worktree-image |
39 | 132 | env: |
40 | 133 | MAKE: make -j2 |
41 | 134 | SAGE_NUM_THREADS: 2 |
42 | | - TEXMFHOME: /sage/texmf |
43 | 135 |
|
44 | 136 | - name: Copy docs |
| 137 | + if: always() && steps.docbuild.outcome == 'success' |
45 | 138 | run: | |
46 | 139 | # For some reason the deploy step below cannot find /sage/... |
47 | 140 | # So copy everything from there to local folder |
|
51 | 144 | zip -r docs-pdf.zip docs |
52 | 145 |
|
53 | 146 | - name: Upload docs |
| 147 | + if: always() && steps.copy.outcome == 'success' |
54 | 148 | uses: actions/upload-artifact@v3 |
55 | 149 | with: |
56 | 150 | name: docs-pdf |
|
0 commit comments