Skip to content

Commit d6f367b

Browse files
committed
Build: show the YAML config file before validating it
This moves the `cat readthedocs.yaml` command _before_ validating the YAML file. This allows the user to inspect the configuration file in case it fails due to a validation error. Closes #11097
1 parent 695667e commit d6f367b

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

readthedocs/doc_builder/director.py

+21-14
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from django.utils.translation import gettext_lazy as _
1717

1818
from readthedocs.builds.constants import EXTERNAL
19+
from readthedocs.config.config import CONFIG_FILENAME_REGEX
20+
from readthedocs.config.find import find_one
1921
from readthedocs.core.utils.filesystem import safe_open
2022
from readthedocs.doc_builder.config import load_yaml_config
2123
from readthedocs.doc_builder.exceptions import BuildUserError
@@ -108,20 +110,6 @@ def setup_vcs(self):
108110
# self.run_build_job("pre_checkout")
109111
self.checkout()
110112

111-
# Output the path for the config file used.
112-
# This works as confirmation for us & the user about which file is used,
113-
# as well as the fact that *any* config file is used.
114-
if self.data.config.source_file:
115-
cwd = self.data.project.checkout_path(self.data.version.slug)
116-
command = self.vcs_environment.run(
117-
"cat",
118-
# Show user the relative path to the config file
119-
# TODO: Have our standard path replacement code catch this.
120-
# https://github.com/readthedocs/readthedocs.org/pull/10413#discussion_r1230765843
121-
self.data.config.source_file.replace(cwd + "/", ""),
122-
cwd=cwd,
123-
)
124-
125113
self.run_build_job("post_checkout")
126114

127115
commit = self.data.build_commit or self.vcs_repository.commit
@@ -240,6 +228,25 @@ def checkout(self):
240228

241229
if custom_config_file:
242230
log.info("Using a custom .readthedocs.yaml file.", path=custom_config_file)
231+
232+
checkout_path = self.data.project.checkout_path(self.data.version.slug)
233+
default_config_file = find_one(checkout_path, CONFIG_FILENAME_REGEX)
234+
235+
# Output the path for the config file used.
236+
# This works as confirmation for us & the user about which file is used,
237+
# as well as the fact that *any* config file is used.
238+
if custom_config_file or default_config_file:
239+
command = self.vcs_environment.run(
240+
"cat",
241+
# Show user the relative path to the config file
242+
# TODO: Have our standard path replacement code catch this.
243+
# https://github.com/readthedocs/readthedocs.org/pull/10413#discussion_r1230765843
244+
(custom_config_file or default_config_file).replace(
245+
checkout_path + "/", ""
246+
),
247+
cwd=checkout_path,
248+
)
249+
243250
self.data.config = load_yaml_config(
244251
version=self.data.version,
245252
readthedocs_yaml_path=custom_config_file,

0 commit comments

Comments
 (0)