summaryrefslogtreecommitdiffstats
path: root/.github/workflows/reusable-docs.yml
blob: 39e5ad62924ad38144b49bdf99d17c582617e925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Docs

on:
  workflow_call:
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  build_doc:
    name: 'Docs'
    runs-on: ubuntu-latest
    timeout-minutes: 60
    steps:
    - uses: actions/checkout@v3
    - name: 'Set up Python'
      uses: actions/setup-python@v4
      with:
        python-version: '3'
        cache: 'pip'
        cache-dependency-path: 'Doc/requirements.txt'
    - name: 'Install build dependencies'
      run: make -C Doc/ venv

    # To annotate PRs with Sphinx nitpicks (missing references)
    - name: 'Get list of changed files'
      if: github.event_name == 'pull_request'
      id: changed_files
      uses: Ana06/get-changed-files@v2.2.0
      with:
        filter: "Doc/**"
        format: csv  # works for paths with spaces
    - name: 'Build HTML documentation'
      continue-on-error: true
      run: |
        set -Eeuo pipefail
        # Build docs with the '-n' (nit-picky) option; write warnings to file
        make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going -w sphinx-warnings.txt" html
    - name: 'Check warnings'
      if: github.event_name == 'pull_request'
      run: |
        python Doc/tools/check-warnings.py \
          --check-and-annotate '${{ steps.changed_files.outputs.added_modified }}' \
          --fail-if-regression \
          --fail-if-improved

  # This build doesn't use problem matchers or check annotations
  build_doc_oldest_supported_sphinx:
    name: 'Docs (Oldest Sphinx)'
    runs-on: ubuntu-latest
    timeout-minutes: 60
    steps:
    - uses: actions/checkout@v3
    - name: 'Set up Python'
      uses: actions/setup-python@v4
      with:
        python-version: '3.11'  # known to work with Sphinx 3.2
        cache: 'pip'
        cache-dependency-path: 'Doc/requirements-oldest-sphinx.txt'
    - name: 'Install build dependencies'
      run: make -C Doc/ venv REQUIREMENTS="requirements-oldest-sphinx.txt"
    - name: 'Build HTML documentation'
      run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html

  # Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
  doctest:
    name: 'Doctest'
    runs-on: ubuntu-latest
    timeout-minutes: 60
    steps:
    - uses: actions/checkout@v3
    - uses: actions/cache@v3
      with:
        path: ~/.cache/pip
        key: ubuntu-doc-${{ hashFiles('Doc/requirements.txt') }}
        restore-keys: |
          ubuntu-doc-
    - name: 'Install Dependencies'
      run: sudo ./.github/workflows/posix-deps-apt.sh && sudo apt-get install wamerican
    - name: 'Configure CPython'
      run: ./configure --with-pydebug
    - name: 'Build CPython'
      run: make -j4
    - name: 'Install build dependencies'
      run: make -C Doc/ PYTHON=../python venv
    # Use "xvfb-run" since some doctest tests open GUI windows
    - name: 'Run documentation doctest'
      run: xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="-W --keep-going" doctest