name: Test Documentation Build
on:
  pull_request:
    paths:
      - src/**
      - '**.rst'
      - '.github/workflows/doc_build_test.yml'
  push:
    branches:
      - main

jobs:
  test-sphinx-build:
    name: test-sphinx-build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          persist-credentials: false
      - name: Set up Python
        uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
        with:
          python-version: 3.12
          cache: 'pip'
          cache-dependency-path: |
            **/requirements*.txt
            pyproject.toml
      - name: Install dependencies
        run: |
          python -W ignore -m pip install --upgrade pip
          python -W ignore -m pip install . --group docs
      - name: Build docs
        run: sphinx-build docs/source docs/build/html -W --keep-going -j auto
