Skip to content

Commit 31bd5ad

Browse files
Build: fail builds if there is no index.html in the output dir (#10550)
* Build: fail builds if there is no `index.html` in the output dir We announced we deprecated this in readthedocs/blog#230 and we already contacted the users to warn about this. This PR has to be merged after July 25th, 2023 and it has to be deployed on August 1st. Closes #1800 * Test: create an "index.html" to run build successfully --------- Co-authored-by: Eric Holscher <[email protected]>
1 parent 752cfeb commit 31bd5ad

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

readthedocs/projects/tasks/builds.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -574,24 +574,13 @@ def get_valid_artifact_types(self):
574574

575575
if artifact_type == "html":
576576
index_html_filepath = os.path.join(artifact_directory, "index.html")
577-
readme_html_filepath = os.path.join(artifact_directory, "README.html")
578-
if not os.path.exists(index_html_filepath) and not os.path.exists(
579-
readme_html_filepath
580-
):
581-
log.warning(
577+
if not os.path.exists(index_html_filepath):
578+
log.info(
582579
"Failing the build. "
583580
"HTML output does not contain an 'index.html' at its root directory.",
584581
index_html=index_html_filepath,
585-
readme_html=readme_html_filepath,
586582
)
587-
# TODO: uncomment this line to fail the build once we have
588-
# communicated with projects without an index.html or
589-
# README.html
590-
#
591-
# NOTE: we want to deprecate serving README.html as an
592-
# index.html file as well.
593-
#
594-
# raise BuildUserError(BuildUserError.BUILD_OUTPUT_HTML_NO_INDEX_FILE)
583+
raise BuildUserError(BuildUserError.BUILD_OUTPUT_HTML_NO_INDEX_FILE)
595584

596585
if not os.path.exists(artifact_directory):
597586
# There is no output directory.

readthedocs/projects/tests/test_build_tasks.py

+16
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,14 @@ def test_build_updates_documentation_type(self, load_yaml_config):
294294
)
295295
).touch()
296296

297+
# Create an "index.html" at root to avoid failing the builds
298+
pathlib.Path(
299+
os.path.join(
300+
self.project.artifact_path(version=self.version.slug, type_="html"),
301+
"index.html",
302+
)
303+
).touch()
304+
297305
self._trigger_update_docs_task()
298306

299307
# Update version state
@@ -438,6 +446,14 @@ def test_successful_build(
438446
)
439447
).touch()
440448

449+
# Create an "index.html" at root to avoid failing the builds
450+
pathlib.Path(
451+
os.path.join(
452+
self.project.artifact_path(version=self.version.slug, type_="html"),
453+
"index.html",
454+
)
455+
).touch()
456+
441457
self._trigger_update_docs_task()
442458

443459
# It has to be called twice, ``before_start`` and ``after_return``

0 commit comments

Comments
 (0)