Skip to content

Commit dad04d1

Browse files
authored
CI: Stop workflow on HTML build failure (#191)
1 parent 5bb7409 commit dad04d1

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

.github/workflows/ci_cd.yml

+7
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,19 @@ jobs:
6565
6666
# Use environment variable to keep the doctree and avoid redundant build for PDF pages
6767
- name: Create HTML documentation
68+
id: create_html
6869
env:
6970
SPHINXBUILD_KEEP_DOCTREEDIR: "1"
7071
run: |
7172
.venv\Scripts\Activate.ps1
7273
. .\doc\make.bat html
7374
75+
- name: Check on failures
76+
if: steps.create_html.outcome != 'success'
77+
run: |
78+
echo "Sphinx build failed, stopping the workflow."
79+
exit 1
80+
7481
- name: Upload HTML documentation artifact
7582
uses: actions/upload-artifact@v4
7683
with:

doc/source/conf.py

-15
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,6 @@ def remove_examples(app: Sphinx, exception: None | Exception):
190190
shutil.rmtree(destination_dir, ignore_errors=True)
191191
logger.info(f"Directory removed.")
192192

193-
def check_build_finished_without_error(app: Sphinx, exception: None | Exception):
194-
"""Check that no error is detected along the documentation build process.
195-
196-
Parameters
197-
----------
198-
app : sphinx.application.Sphinx
199-
Sphinx instance containing all the configuration for the documentation build.
200-
exception : None or Exception
201-
Exception raised during the build process.
202-
"""
203-
if exception is not None:
204-
logger.error("Build failed due to an error.")
205-
exit(1)
206-
207193
def remove_doctree(app: Sphinx, exception: None | Exception):
208194
"""Remove the .doctree directory created during the documentation build.
209195
@@ -243,7 +229,6 @@ def setup(app):
243229
# Build finished hooks
244230
app.connect("build-finished", remove_examples)
245231
app.connect("build-finished", remove_doctree)
246-
app.connect("build-finished", check_build_finished_without_error)
247232

248233
# -- General configuration ---------------------------------------------------
249234

0 commit comments

Comments
 (0)