[skip ci] #4809
Workflow file for this run
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: PsyNeuLink Docs CI | |
on: | |
push: | |
branches-ignore: | |
- 'dependabot/**' | |
tags: | |
- 'v*' | |
pull_request: | |
# run only the latest instance of this workflow job for the current branch/PR | |
# cancel older runs | |
# fall back to run id if not available (run id is unique -> no cancellations) | |
concurrency: | |
group: ci-${{ github.ref || github.run_id }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
docs-build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
# Matrix setup is a hacky way to include 'base' build in pull requests | |
# The entire matrix is set up and 'base' builds are pruned based | |
# on event name and final configuration (ubuntu, python3.7). | |
matrix: | |
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] | |
python-architecture: ['x64'] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
event: | |
- ${{ github.event_name }} | |
pnl-version: ['head', 'base'] | |
exclude: | |
- event: 'push' | |
pnl-version: 'base' | |
- os: macos-latest | |
pnl-version: 'base' | |
- os: windows-latest | |
pnl-version: 'base' | |
- python-version: '3.8' | |
pnl-version: 'base' | |
- python-version: '3.9' | |
pnl-version: 'base' | |
- python-version: '3.10' | |
pnl-version: 'base' | |
- python-version: '3.11' | |
pnl-version: 'base' | |
outputs: | |
on_master: ${{ steps.on_master.outputs.on-branch }} | |
steps: | |
# increased fetch-depth and tag checkout needed as in pnl-ci.yml | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
if: ${{ matrix.pnl-version == 'head' }} | |
with: | |
fetch-depth: 200 | |
ref: ${{ github.ref }} | |
- name: Checkout pull base | |
uses: actions/checkout@v3 | |
if: ${{ matrix.pnl-version == 'base' }} | |
with: | |
fetch-depth: 200 | |
ref: ${{ github.base_ref }} | |
- name: Checkout tags | |
run: git fetch --tags origin master | |
- name: Check if on master | |
if: ${{ github.event_name == 'push' }} | |
id: on_master | |
uses: ./.github/actions/on-branch | |
with: | |
branch: master | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
# Block python3.7.17 on macos. see: | |
# https://github.com/actions/setup-python/issues/682 | |
python-version: ${{ (matrix.os == 'macos-latest' && matrix.python-version == '3.7') && '3.7.16' || matrix.python-version }} | |
architecture: ${{ matrix.python-architecture }} | |
- name: Get pip cache location | |
shell: bash | |
id: pip_cache | |
run: | | |
python -m pip install -U pip | |
python -m pip --version | |
echo "pip_cache_dir=$(python -m pip cache dir)" | tee -a $GITHUB_OUTPUT | |
- name: Wheels cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pip_cache.outputs.pip_cache_dir }}/wheels | |
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-${{ hashFiles('requirements.txt', 'doc_requirements.txt') }}-${{ github.sha }} | |
restore-keys: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-${{ hashFiles('requirements.txt', 'doc_requirements.txt') }} | |
# We need to install all PNL deps since docs config imports psyneulink module | |
- name: Install local, editable PNL package | |
uses: ./.github/actions/install-pnl | |
with: | |
features: 'doc' | |
- name: Add git tag | |
# The generated docs include PNL version, | |
# set it to a fixed value to prevent polluting the diff | |
# This needs to be done after installing PNL | |
# to not interfere with dependency resolution | |
id: add_zero_tag | |
if: github.event_name == 'pull_request' | |
run: git tag --force 'v0.0.0.0' | |
- name: Build Documentation | |
run: make -C docs/ html -e SPHINXOPTS="-aE -j auto" | |
- name: Remove git tag | |
# The generated docs include PNL version, | |
# A special tag was set to a fixed value | |
# to prevent polluting the diff | |
if: steps.add_zero_tag.outcome != 'skipped' | |
run: git tag -d 'v0.0.0.0' | |
- name: Upload Documentation | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Documentation-${{matrix.pnl-version}}-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.python-architecture }} | |
retention-days: 1 | |
path: docs/build/html | |
- name: Store PR number | |
if: ${{ github.event_name == 'pull_request' }} | |
run: echo ${{ github.event.pull_request.number }} > ./pr_number.txt | |
- name: Upload PR number for other workflows | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pr_number | |
path: ./pr_number.txt | |
docs-deploy: | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [3.7] | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
permissions: | |
contents: write | |
needs: [docs-build] | |
environment: github-pages | |
if: github.event_name == 'push' && | |
(github.ref == 'refs/heads/master' || | |
github.ref == 'refs/heads/devel' || | |
github.ref == 'refs/heads/docs' || | |
(startsWith(github.ref, 'refs/tags/') && contains(needs.*.outputs.on_master, 'master')) | |
) | |
steps: | |
- name: Checkout docs | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Download branch docs | |
uses: actions/download-artifact@v3 | |
with: | |
name: Documentation-head-${{ matrix.os }}-${{ matrix.python-version }}-x64 | |
path: _built_docs/${{ github.ref }} | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/devel' || github.ref == 'refs/heads/docs' | |
- name: Update branch docs | |
shell: bash | |
run: | | |
mkdir -p branch | |
rm -rf "branch/${GITHUB_REF##*/}" | |
# Remove '.doctrees' and move to correct location | |
rm -rf "_built_docs/${GITHUB_REF}/.doctrees" | |
mv -f "_built_docs/${GITHUB_REF}" branch/ | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/devel' || github.ref == 'refs/heads/docs' | |
- name: Download main docs | |
uses: actions/download-artifact@v3 | |
with: | |
name: Documentation-head-${{ matrix.os }}-${{ matrix.python-version }}-x64 | |
# This overwrites files in current directory | |
if: startsWith(github.ref, 'refs/tags/') && contains(needs.*.outputs.on_master, 'master') | |
- name: Update main docs | |
shell: bash | |
run: | | |
# Remove '.doctrees' | |
rm -rf ".doctrees" | |
if: startsWith(github.ref, 'refs/tags/') && contains(needs.*.outputs.on_master, 'master') | |
- name: Commit docs changes | |
shell: bash | |
run: | | |
# Commit changes to git | |
git add . | |
git config user.name "Documentation Bot" | |
git config user.email "[email protected]" | |
git commit -m "Docs changes for $GITHUB_REF $GITHUB_SHA" | |
git push |