Skip to content

Build: show the YAML config file before validating it #11175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions readthedocs/doc_builder/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from django.utils.translation import gettext_lazy as _

from readthedocs.builds.constants import EXTERNAL
from readthedocs.config.config import CONFIG_FILENAME_REGEX
from readthedocs.config.find import find_one
from readthedocs.core.utils.filesystem import safe_open
from readthedocs.doc_builder.config import load_yaml_config
from readthedocs.doc_builder.exceptions import BuildUserError
Expand Down Expand Up @@ -108,20 +110,6 @@ def setup_vcs(self):
# self.run_build_job("pre_checkout")
self.checkout()

# Output the path for the config file used.
# This works as confirmation for us & the user about which file is used,
# as well as the fact that *any* config file is used.
if self.data.config.source_file:
cwd = self.data.project.checkout_path(self.data.version.slug)
command = self.vcs_environment.run(
"cat",
# Show user the relative path to the config file
# TODO: Have our standard path replacement code catch this.
# https://github.com/readthedocs/readthedocs.org/pull/10413#discussion_r1230765843
self.data.config.source_file.replace(cwd + "/", ""),
cwd=cwd,
)

self.run_build_job("post_checkout")

commit = self.data.build_commit or self.vcs_repository.commit
Expand Down Expand Up @@ -240,6 +228,24 @@ def checkout(self):

if custom_config_file:
log.info("Using a custom .readthedocs.yaml file.", path=custom_config_file)

checkout_path = self.data.project.checkout_path(self.data.version.slug)
default_config_file = find_one(checkout_path, CONFIG_FILENAME_REGEX)
final_config_file = custom_config_file or default_config_file

# Output the path for the config file used.
# This works as confirmation for us & the user about which file is used,
# as well as the fact that *any* config file is used.
if final_config_file:
command = self.vcs_environment.run(
"cat",
# Show user the relative path to the config file
# TODO: Have our standard path replacement code catch this.
# https://github.com/readthedocs/readthedocs.org/pull/10413#discussion_r1230765843
final_config_file.replace(checkout_path + "/", ""),
cwd=checkout_path,
)

self.data.config = load_yaml_config(
version=self.data.version,
readthedocs_yaml_path=custom_config_file,
Expand Down
23 changes: 16 additions & 7 deletions readthedocs/projects/tests/test_build_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,11 +810,14 @@ def test_build_commands_executed(
python_version = settings.RTD_DOCKER_BUILD_SETTINGS["tools"]["python"]["3"]
self.mocker.mocks["environment.run"].assert_has_calls(
[
mock.call(
"cat",
"readthedocs.yml",
cwd="/tmp/readthedocs-tests/git-repository",
),
# TODO: check for this in the VCS environment.
# We can't check it here because this is the build environment.
#
# mock.call(
# "cat",
# "readthedocs.yml",
# cwd="/tmp/readthedocs-tests/git-repository",
# ),
mock.call("asdf", "install", "python", python_version),
mock.call("asdf", "global", "python", python_version),
mock.call("asdf", "reshim", "python", record=False),
Expand Down Expand Up @@ -1348,7 +1351,10 @@ def test_conda_config_calls_conda_command(self, load_yaml_config):
]
self.mocker.mocks["environment.run"].assert_has_calls(
[
mock.call("cat", "readthedocs.yml", cwd=mock.ANY),
# TODO: check for this in the VCS environment.
# We can't check it here because this is the build environment.
#
# mock.call("cat", "readthedocs.yml", cwd=mock.ANY),
mock.call("asdf", "install", "python", python_version),
mock.call("asdf", "global", "python", python_version),
mock.call("asdf", "reshim", "python", record=False),
Expand Down Expand Up @@ -1442,7 +1448,10 @@ def test_python_mamba_commands(self, load_yaml_config):

self.mocker.mocks["environment.run"].assert_has_calls(
[
mock.call("cat", "readthedocs.yml", cwd=mock.ANY),
# TODO: check for this in the VCS environment.
# We can't check it here because this is the build environment.
#
# mock.call("cat", "readthedocs.yml", cwd=mock.ANY),
mock.call("asdf", "install", "python", "mambaforge-4.10.3-10"),
mock.call("asdf", "global", "python", "mambaforge-4.10.3-10"),
mock.call("asdf", "reshim", "python", record=False),
Expand Down