Skip to content

Commit 870bcea

Browse files
committed
Add simple EPUB fatals check
1 parent 50cf4cb commit 870bcea

File tree

2 files changed

+54
-7
lines changed

2 files changed

+54
-7
lines changed

.github/workflows/reusable-docs.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ jobs:
7575
--fail-if-regression \
7676
--fail-if-improved \
7777
--fail-if-new-news-nit
78-
- name: 'Build and check EPUB documentation'
79-
continue-on-error: true
80-
run: |
81-
set -Eeuo pipefail
82-
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --fail-on-warning" epub
83-
pip install epubcheck
84-
epubcheck Doc/build/epub/Python.epub
8578
8679
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
8780
doctest:
@@ -109,3 +102,31 @@ jobs:
109102
# Use "xvfb-run" since some doctest tests open GUI windows
110103
- name: 'Run documentation doctest'
111104
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="--fail-on-warning" doctest
105+
106+
epubcheck:
107+
name: 'Docs EPUB check'
108+
runs-on: ubuntu-latest
109+
timeout-minutes: 40
110+
steps:
111+
- uses: actions/checkout@v4
112+
with:
113+
persist-credentials: false
114+
- uses: actions/cache@v4
115+
with:
116+
path: ~/.cache/pip
117+
key: ubuntu-doc-${{ hashFiles('Doc/requirements.txt') }}
118+
restore-keys: |
119+
ubuntu-doc-
120+
- name: 'Install build dependencies'
121+
run: make -C Doc/ PYTHON=../python venv
122+
- name: 'Build and load EPUB checks to file'
123+
continue-on-error: true
124+
run: |
125+
set -Eeuo pipefail
126+
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --fail-on-warning" epub
127+
pip install epubcheck
128+
epubcheck Doc/build/epub/Python.epub &> Doc/epubcheck.txt
129+
- name: 'Check for FATAL errors in EPUB'
130+
if: github.event_name == 'pull_request'
131+
run: |
132+
python Doc/tools/check-epub.py

Doc/tools/check-epub.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
from pathlib import Path
3+
4+
5+
def main():
6+
wrong_directory_msg = "Must run this script from the repo root"
7+
if not Path("Doc").exists() or not Path("Doc").is_dir():
8+
raise RuntimeError(wrong_directory_msg)
9+
10+
with Path("Doc/epubcheck.txt").open(encoding="UTF-8") as f:
11+
warnings = f.read().splitlines()
12+
13+
warnings = [warning.split(" - ") for warning in warnings]
14+
15+
fatals = [warning for warning in warnings if warning[0] == "FATAL"]
16+
17+
if fatals:
18+
print("\nError: must not contain fatal errors:\n")
19+
for fatal in fatals:
20+
print(" - ".join(fatal))
21+
22+
return len(fatals)
23+
24+
25+
if __name__ == "__main__":
26+
sys.exit(main())

0 commit comments

Comments
 (0)