Build and deploy site #2471
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and deploy site | |
on: | |
repository_dispatch: | |
schedule: | |
- cron: '29 11 * * *' | |
pull_request: | |
push: | |
branches: [main] | |
jobs: | |
cancel-superseded: | |
name: Cancel superseded | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.7.0 | |
with: | |
access_token: ${{ github.token }} | |
build-core-site: | |
needs: cancel-superseded | |
name: Build core site | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.11.0 | |
with: | |
access_token: ${{ github.token }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Ruby 2.7 | |
uses: actions/setup-ruby@v1 | |
with: | |
ruby-version: 2.7 | |
- uses: actions/cache@v3 | |
with: | |
path: /opt/hostedtoolcache/Ruby/2.7.2/x64/lib/ruby/gems | |
key: ${{ runner.os }}-gems-v3-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems-v3 | |
- name: Install deps | |
run: | | |
gem update --system --no-document | |
gem install bundler jekyll | |
bundle install | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
cache: 'npm' | |
- name: Install deps | |
run: npm ci | |
- name: Build site | |
run: GITHUB_TOKEN=${{ github.token }} grunt build | |
- name: Debug | |
run: | | |
cat Gemfile.lock | |
bundle info jekyll | |
bundle info jekyll-theme-cayman | |
ls | |
cat dist/index.html | |
- name: Upload built site | |
uses: actions/upload-artifact@v2 | |
with: | |
name: core-site | |
path: dist/* | |
build-msprime-docs: | |
name: Build msprime docs | |
needs: cancel-superseded | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
name: Checkout msprime | |
with: | |
ref: main | |
repository: tskit-dev/msprime | |
submodules: true | |
fetch-depth: 0 # Needed for setuptools_scm to work correctly | |
- name: Get commit SHA1 for cache | |
run: git rev-parse HEAD > SHA1 | |
- uses: actions/cache@v2 | |
id: docs-cache | |
name: Docs cache | |
with: | |
path: dist | |
key: msprime-docs-v11-${{ hashFiles('SHA1') }} | |
- name: Install GSL | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: sudo apt-get install -y libgsl0-dev | |
- uses: actions/setup-python@v2 | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
name: Setup Python | |
with: | |
python-version: "3.10" | |
- name: Build virtualenv | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: python -m venv venv-latest | |
- name: Install deps | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
venv-latest/bin/activate && pip install -r requirements/CI-docs/requirements.txt | |
- name: Build C module | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: venv-latest/bin/activate && make | |
- name: Build Docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
venv-latest/bin/activate | |
cd docs | |
make dist | |
# make dist changes the _conf.yml file to write the version number, so drop the change | |
git checkout . | |
- name: Copy docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p dist | |
cp -r docs/_build/html dist/latest | |
- name: Checkout latest stable tag | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
git fetch --tags --recurse-submodules=no | |
git checkout `git tag --list --sort=creatordate | grep -vi "[baC]" | tail -n1` | |
git submodule update --init --recursive | |
git status | |
# - name: Build virtualenv | |
# if: steps.docs-cache.outputs.cache-hit != 'true' | |
# run: python -m venv venv-stable | |
# | |
# - name: Install deps | |
# if: steps.docs-cache.outputs.cache-hit != 'true' | |
# run: | | |
# venv-stable/bin/activate | |
# [ -f requirements/CI-docs/requirements.txt ] && pip install -r requirements/CI-docs/requirements.txt | |
# [ -f requirements/development.txt ] && pip install -r requirements/development.txt | |
- name: Build C module | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
# run: venv-stable/bin/activate && make | |
run: venv-latest/bin/activate && make | |
- name: Build Docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
rm -rf docs/_build | |
venv-latest/bin/activate | |
cd docs | |
make dist | |
# make dist changes the _conf.yml file to write the version number, so drop the change | |
git checkout . | |
# run: | | |
# rm -rf docs/_build | |
# venv-stable/bin/activate | |
# cd docs | |
# ### Temp fix for unpinned dependency change (#156) | |
# sed -i 's/sphinxarg.ext/sphinxarg.ext\n - IPython.sphinxext.ipython_console_highlighting/g' _config.yml | |
# # Install jsonschema for bugfix | |
# pip install jsonschema[format-nongpl]==4.17.3 | |
# ### Temp changes for theme | |
# pip install tskit-book-theme | |
# sed -i 's/ config:/ config:\n html_theme: tskit_book_theme\n pygments_style: monokai/g' _config.yml | |
# ### Temp changes for theme | |
# make dist | |
# # make dist changes the _conf.yml file to write the version number, so drop the change | |
# git checkout . | |
- name: Copy docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | |
cp -r docs/_build/html dist/stable | |
- name: Upload msprime docs | |
uses: actions/upload-artifact@v2 | |
with: | |
name: msprime-docs | |
path: dist/* | |
build-tsinfer-docs: | |
name: Build tsinfer docs | |
needs: cancel-superseded | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
name: Checkout tsinfer | |
with: | |
ref: main | |
repository: tskit-dev/tsinfer | |
submodules: true | |
fetch-depth: 0 # Needed for setuptools_scm to work correctly | |
- name: Get commit SHA1 for cache | |
run: git rev-parse HEAD > SHA1 | |
- uses: actions/cache@v2 | |
id: docs-cache | |
name: Docs cache | |
with: | |
path: dist | |
key: tsinfer-docs-v1-${{ hashFiles('SHA1') }} | |
- uses: actions/setup-python@v4 | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
name: Setup Python | |
with: | |
python-version: "3.10" | |
- name: Build virtualenv | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: python -m venv venv-latest | |
- name: Install deps | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
venv-latest/bin/activate && pip install -r requirements/CI-docs/requirements.txt | |
- name: Build C module | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: venv-latest/bin/activate && make | |
- name: Build Docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
venv-latest/bin/activate | |
cd docs | |
make dist | |
# make dist changes the _conf.yml file to write the version number, so drop the change | |
git checkout . | |
- name: Copy docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p dist | |
cp -r docs/_build/html dist/latest | |
- name: Checkout latest stable tag | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
git fetch --tags --recurse-submodules=no | |
git checkout `git tag --list --sort=creatordate | grep -vi "[baC]" | tail -n1` | |
git submodule update --init --recursive | |
git status | |
# - uses: actions/setup-python@v4 | |
# if: steps.docs-cache.outputs.cache-hit != 'true' | |
# name: Setup Python | |
# with: | |
# python-version: "3.8" | |
# | |
# - name: Build virtualenv | |
# if: steps.docs-cache.outputs.cache-hit != 'true' | |
# run: python -m venv venv-stable | |
# Changes have meant that the stable version docs won't build - so use the venv-latest instead for now. # | |
# - name: Install deps | |
# if: steps.docs-cache.outputs.cache-hit != 'true' | |
# run: | | |
# venv-stable/bin/activate | |
# [ -f requirements/CI-docs/requirements.txt ] && pip install -r requirements/CI-docs/requirements.txt | |
# # Remove this line after 0.4.0 | |
# pip install jsonschema[format-nongpl]==4.17.3 | |
- name: Build C module | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
# run: venv-stable/bin/activate && make | |
run: | | |
venv-latest/bin/activate | |
venv-latest/bin/activate && which python | |
venv-latest/bin/activate && python -c "import numpy;print(numpy.__file__)" | |
venv-latest/bin/activate && make | |
- name: Build Docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
rm -rf docs/_build | |
#venv-stable/bin/activate | |
venv-latest/bin/activate | |
cd docs | |
### Temp fix for unpinned dependency change (#156) | |
sed -i 's/sphinxarg.ext/sphinxarg.ext\n - IPython.sphinxext.ipython_console_highlighting/g' _config.yml | |
make dist | |
# make dist changes the _conf.yml file to write the version number, so drop the change | |
git checkout . | |
- name: Copy docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | |
cp -r docs/_build/html dist/stable | |
- name: Upload tsinfer docs | |
uses: actions/upload-artifact@v2 | |
with: | |
name: tsinfer-docs | |
path: dist/* | |
build-tskit-docs: | |
name: Build tskit docs | |
needs: cancel-superseded | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
name: Checkout tskit | |
with: | |
ref: main | |
repository: tskit-dev/tskit | |
submodules: true | |
fetch-depth: 0 # Needed for setuptools_scm to work correctly | |
- name: Get commit SHA1 for cache | |
run: git rev-parse HEAD > SHA1 | |
- uses: actions/cache@v2 | |
id: docs-cache | |
name: Docs cache | |
with: | |
path: dist | |
key: tskit-docs-v7-${{ hashFiles('SHA1') }} | |
- uses: actions/setup-python@v4 | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
name: Setup Python | |
with: | |
python-version: "3.10" | |
- name: Build virtualenv | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: python -m venv venv-latest | |
- name: Install deps | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
sudo apt-get install doxygen | |
venv-latest/bin/activate && pip install -r python/requirements/CI-docs/requirements.txt | |
- name: Build C module | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: venv-latest/bin/activate && make -C python | |
- name: Build Docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
venv-latest/bin/activate | |
cd docs | |
make dist | |
- name: Copy docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p dist | |
cp -r docs/_build/html dist/latest | |
- name: Checkout latest stable tag | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
git stash | |
git fetch --tags --recurse-submodules=no | |
git checkout `git tag --list --sort=creatordate | grep -vi "[baC]" | tail -n1` | |
git submodule update --init --recursive | |
git status | |
- uses: actions/setup-python@v4 | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
name: Setup Python | |
with: | |
python-version: 3.8 | |
- name: Build virtualenv | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: python -m venv venv-stable | |
- name: Downgrade pip (for conflicting dependencies) | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: venv-stable/bin/activate && pip install pip==20.0.2 | |
- name: Install deps | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
# Remove this second line after next release of tskit | |
run: | | |
venv-stable/bin/activate && pip install -r python/requirements/CI-docs/requirements.txt | |
venv-stable/bin/activate && pip install nbclient==0.5.13 | |
- name: Build C module | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: venv-stable/bin/activate && make -C python | |
- name: Build Docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
rm -rf docs/_build | |
venv-stable/bin/activate | |
# Install jsonschema for bugfix | |
pip install jsonschema[format-nongpl]==4.17.3 | |
cd docs | |
### Temp changes for theme | |
pip install tskit-book-theme | |
sed -i 's/ config:/ config:\n html_theme: tskit_book_theme\n pygments_style: monokai/g' _config.yml | |
### Temp changes for theme | |
make dist || make | |
- name: Copy docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
cp -r docs/_build/html dist/stable | |
- name: Upload tskit docs | |
uses: actions/upload-artifact@v2 | |
with: | |
name: tskit-docs | |
path: dist/* | |
build-pyslim-docs: | |
name: Build pyslim docs | |
needs: cancel-superseded | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
name: Checkout pyslim | |
with: | |
ref: main | |
repository: tskit-dev/pyslim | |
submodules: true | |
fetch-depth: 0 # Needed for setuptools_scm to work correctly | |
- name: Get commit SHA1 for cache | |
run: git rev-parse HEAD > SHA1 | |
- uses: actions/cache@v2 | |
id: docs-cache | |
name: Docs cache | |
with: | |
path: dist | |
key: pyslim-docs-v6-${{ hashFiles('SHA1') }} | |
- uses: actions/setup-python@v2 | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
name: Setup Python | |
with: | |
python-version: 3.8 | |
- name: Build latest SLiM | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
git clone https://github.com/messerlab/SLiM.git | |
mkdir -p SLiM/Release | |
cd SLiM/Release | |
cmake -D CMAKE_BUILD_TYPE=Release .. | |
make -j 2 | |
- name: Build virtualenv | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: python -m venv venv-latest | |
- name: Install deps | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
venv-latest/bin/activate | |
pip install -r requirements/CI-docs/requirements.txt | |
- name: Build Docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
venv-latest/bin/activate | |
export PATH=$PATH:$PWD/SLiM/Release | |
cd docs | |
# don't re-generate these which require tricky prerequisites (inkscape, xmlstarlet) | |
touch _static/{pedigree0.svg,pedigree1.svg,pedigree2.svg,pedigree_recapitate.svg,pedigree_simplify.svg,pedigree_mutate.svg} | |
touch _static/{pedigree01.png,pedigree0.png,pedigree1.png,pedigree2.png,pedigree_recapitate.png,pedigree_simplify.png,pedigree_mutate.png} | |
make dist | |
# make dist changes the _conf.yml file to write the version number, so drop the change | |
git checkout . | |
- name: Copy docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p dist | |
cp -r docs/_build/html dist/latest | |
- name: Build stable SLiM | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p SLiM/Stable | |
cd SLiM/Stable | |
git fetch --tags --recurse-submodules=no | |
git checkout `git tag --list --sort=creatordate | grep -vi "[baC]" | tail -n1` | |
git status | |
cmake -D CMAKE_BUILD_TYPE=Release .. | |
make -j 2 | |
- name: Checkout latest stable tag | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
git fetch --tags --recurse-submodules=no | |
git checkout `git tag --list --sort=creatordate | grep -vi "[baC]" | tail -n1` | |
git submodule update --init --recursive | |
git status | |
# As docs build has had issues with dependancies, just use venv-latest for now | |
# - name: Build virtualenv | |
# if: steps.docs-cache.outputs.cache-hit != 'true' | |
# run: python -m venv venv-stable | |
# | |
# - name: Install deps | |
# if: steps.docs-cache.outputs.cache-hit != 'true' | |
# run: | | |
# venv-stable/bin/activate | |
# pip install -r requirements/CI-docs/requirements.txt | |
- name: Build Docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | | |
rm -rf docs/_build | |
venv-latest/bin/activate | |
export PATH=$PWD/SLiM/Stable:$PATH | |
cd docs | |
# don't re-generate these which require tricky prerequisites (inkscape, xmlstarlet) | |
touch _static/{pedigree0.svg,pedigree1.svg,pedigree2.svg,pedigree_recapitate.svg,pedigree_simplify.svg,pedigree_mutate.svg} | |
touch _static/{pedigree01.png,pedigree0.png,pedigree1.png,pedigree2.png,pedigree_recapitate.png,pedigree_simplify.png,pedigree_mutate.png} | |
make dist | |
# make dist changes the _conf.yml file to write the version number, so drop the change | |
git checkout . | |
- name: Copy docs | |
if: steps.docs-cache.outputs.cache-hit != 'true' | |
run: | |
cp -r docs/_build/html dist/stable | |
- name: Upload pyslim docs | |
uses: actions/upload-artifact@v2 | |
with: | |
name: pyslim-docs | |
path: dist/* | |
import-tutorials: | |
name: Import tutorials | |
needs: cancel-superseded | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
name: Checkout tutorials | |
with: | |
ref: gh-pages | |
repository: tskit-dev/tutorials | |
- name: Upload tutorials | |
uses: actions/upload-artifact@v2 | |
with: | |
name: tutorials | |
path: . | |
import-rust-tutorial: | |
name: Import rust tutorials | |
needs: cancel-superseded | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
name: Checkout tutorials | |
with: | |
ref: gh-pages | |
repository: tskit-dev/tskit-rust | |
- name: Upload tutorials | |
uses: actions/upload-artifact@v2 | |
with: | |
name: rust-tutorials | |
path: . | |
deploy: | |
name: Deploy 🚀 (if on main branch) | |
needs: | |
- build-core-site | |
- build-msprime-docs | |
- build-tsinfer-docs | |
- build-tskit-docs | |
- build-pyslim-docs | |
- import-tutorials | |
- import-rust-tutorial | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Download core site | |
uses: actions/download-artifact@v2 | |
with: | |
name: core-site | |
path: site | |
- name: Download msprime-docs | |
uses: actions/download-artifact@v2 | |
with: | |
name: msprime-docs | |
path: site/msprime/docs | |
- name: Download tsinfer-docs | |
uses: actions/download-artifact@v2 | |
with: | |
name: tsinfer-docs | |
path: site/tsinfer/docs | |
- name: Download tskit-docs | |
uses: actions/download-artifact@v2 | |
with: | |
name: tskit-docs | |
path: site/tskit/docs | |
- name: Download pyslim-docs | |
uses: actions/download-artifact@v2 | |
with: | |
name: pyslim-docs | |
path: site/pyslim/docs | |
- name: Download tutorials | |
uses: actions/download-artifact@v2 | |
with: | |
name: tutorials | |
path: site/tutorials | |
- name: Download rust tutorial | |
uses: actions/download-artifact@v2 | |
with: | |
name: rust-tutorials | |
path: site/tutorials/rust | |
- name: Pages config and tweaks | |
run: | | |
touch site/.nojekyll | |
echo "tskit.dev" > site/CNAME | |
echo "<meta http-equiv=\"Refresh\" content=\"0; url=/msprime/docs/stable\" />" > site/msprime/docs/index.html | |
echo "<meta http-equiv=\"Refresh\" content=\"0; url=/tsinfer/docs/stable\" />" > site/tsinfer/docs/index.html | |
echo "<meta http-equiv=\"Refresh\" content=\"0; url=/tskit/docs/stable\" />" > site/tskit/docs/index.html | |
echo "<meta http-equiv=\"Refresh\" content=\"0; url=/pyslim/docs/stable\" />" > site/pyslim/docs/index.html | |
- name: List site contents | |
run: | | |
ls -R | |
- name: Upload site (for PR inspection) | |
uses: actions/upload-artifact@v2 | |
with: | |
name: site | |
path: . | |
- name: Deploy | |
if: github.ref == 'refs/heads/main' | |
uses: JamesIves/github-pages-deploy-action@3.7.1 | |
with: | |
GITHUB_TOKEN: ${{ secrets.ADMINBOT_TOKEN }} | |
BRANCH: gh-pages | |
FOLDER: site | |
SINGLE_COMMIT: true |