Skip to content

Commit

Permalink
.github/workflows/build.yml: Merge doc-build.yml, doc-build-pdf.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Oct 11, 2023
1 parent 08d8cb9 commit 6d0005c
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 268 deletions.
185 changes: 185 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,188 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: ./worktree-image/coverage.xml

build-docs:
runs-on: ubuntu-latest
container: ghcr.io/sagemath/sage/sage-ubuntu-focal-standard-with-targets:dev
needs: [get_ci_fixes]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update system packages
run: |
apt-get update && apt-get install -y git zip
- name: Add prebuilt tree as a worktree
id: worktree
run: |
git config --global user.email "[email protected]"
git config --global user.name "Build & Test workflow"
git config --global --add safe.directory $(pwd)
.ci/retrofit-worktree.sh worktree-image /sage
# Keep track of changes to built HTML
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")
- name: Download upstream artifact
uses: actions/download-artifact@v3
with:
path: upstream
name: upstream

- name: Apply CI fixes from sagemath/sage
# After applying the fixes, make sure all changes are marked as uncommitted changes.
run: |
if [ -r upstream/ci_fixes.patch ]; then
(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
fi
- name: Incremental build
id: incremental
run: |
# Now re-bootstrap and build. The build is incremental because we were careful with the timestamps.
./bootstrap && make build
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
SAGE_NUM_THREADS: 2

- name: Build (fallback to non-incremental)
id: build
if: always() && steps.worktree.outcome == 'success' && steps.incremental.outcome != 'success'
run: |
set -ex
make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage && ./config.status && make build
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
SAGE_NUM_THREADS: 2

- name: Build docs
id: docbuild
if: always() && (steps.incremental.outcome == 'success' || steps.build.outcome == 'success')
# Always non-incremental because of the concern that
# incremental docbuild may introduce broken links (inter-file references) though build succeeds
run: |
set -ex
export SAGE_USE_CDNS=yes
mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc
make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage
mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git
./config.status && make doc-html
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
SAGE_NUM_THREADS: 2

- name: Copy docs
id: copy
if: always() && steps.docbuild.outcome == 'success'
run: |
set -ex
mkdir -p ./docs
# Create changelog
echo '## Preview of CHANGES.html'
(cd /sage/local/share/doc/sage/html/en && git diff --name-only) | tee ./docs/CHANGES.txt
(cd /sage/local/share/doc/sage/html/en && git diff; rm -rf .git) > ./docs/html.diff
echo '## Preview of html.diff'; head -n 400 ./docs/html.diff
(echo '<p><a href="html.diff">HTML diff</a>'; sed -E 's,(.*),<p><a href="\1">\1</a>,' ./docs/CHANGES.txt) > ./docs/CHANGES.html
# For some reason the deploy step below cannot find /sage/...
# So copy everything from there to local folder
# We also need to replace the symlinks because netlify is not following them
cp -r -L /sage/local/share/doc/sage/html/en/* ./docs
# Zip everything for increased performance
zip -r docs.zip docs
- name: Upload docs
if: always() && steps.copy.outcome == 'success'
uses: actions/upload-artifact@v3
with:
name: docs
path: docs.zip

build-docs-pdf:
runs-on: ubuntu-latest
container: ghcr.io/sagemath/sage/sage-${{ github.event.inputs.platform || 'ubuntu-focal-standard' }}-with-targets:${{ github.event.inputs.docker_tag || 'dev'}}
needs: [get_ci_fixes]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update system packages
run: |
export PATH="build/bin:$PATH"
eval $(sage-print-system-package-command auto update)
eval $(sage-print-system-package-command auto --yes --no-install-recommends install zip)
eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git texlive)
- name: Add prebuilt tree as a worktree
id: worktree
run: |
git config --global user.email "[email protected]"
git config --global user.name "Build & Test workflow"
git config --global --add safe.directory $(pwd)
.ci/retrofit-worktree.sh worktree-image /sage
# Keep track of changes to built HTML
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")
- name: Download upstream artifact
uses: actions/download-artifact@v3
with:
path: upstream
name: upstream

- name: Apply CI fixes from sagemath/sage
# After applying the fixes, make sure all changes are marked as uncommitted changes.
run: |
if [ -r upstream/ci_fixes.patch ]; then
(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
fi
- name: Incremental build
id: incremental
run: |
# Now re-bootstrap and build. The build is incremental because we were careful with the timestamps.
./bootstrap && make build
working-directory: ./worktree-image
env:
MAKE: make -j2
SAGE_NUM_THREADS: 2

- name: Build (fallback to non-incremental)
id: build
if: always() && steps.worktree.outcome == 'success' && steps.incremental.outcome != 'success'
run: |
set -ex
make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage && ./config.status && make build
working-directory: ./worktree-image
env:
MAKE: make -j2
SAGE_NUM_THREADS: 2

- name: Build docs (PDF)
id: docbuild
if: always() && (steps.incremental.outcome == 'success' || steps.build.outcome == 'success')
run: make build V=0 && make doc-pdf
working-directory: ./worktree-image
env:
MAKE: make -j2
SAGE_NUM_THREADS: 2

- name: Copy docs
if: always() && steps.docbuild.outcome == 'success'
run: |
# For some reason the deploy step below cannot find /sage/...
# So copy everything from there to local folder
mkdir -p ./docs
cp -r -L /sage/local/share/doc/sage/pdf/en/* ./docs
# Zip everything for increased performance
zip -r docs-pdf.zip docs
- name: Upload docs
if: always() && steps.copy.outcome == 'success'
uses: actions/upload-artifact@v3
with:
name: docs-pdf
path: docs-pdf.zip
130 changes: 0 additions & 130 deletions .github/workflows/doc-build-pdf.yml

This file was deleted.

Loading

0 comments on commit 6d0005c

Please sign in to comment.