Skip to content

build docs

build docs #16606

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.10", "3.11", "3.12"]
exclude:
- 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@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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@ffdd254f4eaf1562b8a2c66aeaa37f1ff2231179 # v3.7.3
with:
action: crazy-max/[email protected]
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@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.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@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Download artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: docs_3.11_ubuntu-latest
path: build_docs
- name: Deploy to gh pages
uses: JamesIves/github-pages-deploy-action@62fec3add6773ec5dbbf18d2ee4260911aa35cf4 # v4.6.9
with:
branch: gh-pages
folder: ${{ github.workspace }}/build_docs/
clean: true
single-commit: true
git-config-email: "bot"
git-config-name: "Documentation Bot"