Skip to content

build docs

build docs #14505

Workflow file for this run

name: build docs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'main'
- 'release/*'
tags:
- 'v*'
pull_request:
merge_group:
branches: ['main']
permissions:
contents: read
jobs:
builddocs:
runs-on: ${{ matrix.os }}
strategy:
# don't stop other jobs if one fails
# this is often due to network issues
# and or flaky tests
# and the time lost in such cases
# is bigger than the gain from canceling the job
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
exclude:
- os: windows-latest
python-version: 3.9
- os: windows-latest
python-version: 3.10
- os: windows-latest
python-version: 3.11
env:
OS: ${{ matrix.os }}
SPHINX_WARNINGS_AS_ERROR: true
SPHINX_OPTS: "-v -j 2"
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
# we need full history with tags for the version number
fetch-depth: '0'
- name: set-sphinx-opts
run: |
echo "SPHINX_OPTS=-W -v --keep-going -j 2" >> $GITHUB_ENV
if: ${{ fromJSON(env.SPHINX_WARNINGS_AS_ERROR) }}
- name: install pandoc linux
# add the || true logic to not error in case the index cannot be fetched.
# this is known to have happened before e.g.
# https://github.com/microsoft/linux-package-repositories/issues/130
run: |
sudo apt update || true
sudo apt install pandoc
if: runner.os == 'Linux'
- name: Install pandoc on windows
uses: Wandalen/wretry.action@0dd1d5d77d019a6f85beb53d29e2ea2c7294d4f2 # v3.4.0
with:
action: crazy-max/ghaction-chocolatey@v1.6.0
with: |
args: install pandoc
attempt_limit: 5
attempt_delay: 1000
if: runner.os == 'Windows'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements.txt
docs/conf.py
- name: upgrade pip setuptools wheel
run: python -m pip install --upgrade pip setuptools wheel
shell: bash
- name: install qcodes
run: pip install -c requirements.txt .[docs]
- name: Build docs on linux
run: |
cd docs
export SPHINXOPTS="${{ env.SPHINX_OPTS }}"
make html
if: runner.os == 'Linux'
- name: Build docs on windows
run: |
cd docs
$env:SPHINXOPTS = "${{ env.SPHINX_OPTS }}"
./make.bat html
if: runner.os == 'Windows'
- name: Upload build docs
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: docs_${{ matrix.python-version }}_${{ matrix.os }}
path: ${{ github.workspace }}/docs/_build/html
deploydocs:
needs: builddocs
runs-on: "ubuntu-latest"
permissions:
contents: write # we need to be allowed to push to gh-pages
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Download artifact
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: docs_3.11_ubuntu-latest
path: build_docs
- name: Deploy to gh pages
uses: JamesIves/github-pages-deploy-action@ec9c88baef04b842ca6f0a132fd61c762aa6c1b0 # v4.6.0
with:
branch: gh-pages
folder: ${{ github.workspace }}/build_docs/
clean: true
single-commit: true
git-config-email: "bot"
git-config-name: "Documentation Bot"