Skip to content

Shortcut to compile all the valid build.tools #278

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 19 additions & 4 deletions dockerfiles/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,33 @@ def test(c, arguments='', running=True):
c.run(f'{DOCKER_COMPOSE_COMMAND} run -e GITHUB_USER=$GITHUB_USER -e GITHUB_TOKEN=$GITHUB_TOKEN --rm --no-deps web uv run tox {arguments}', pty=True)

@task(help={
'everything': 'compile all allowed build.tool',
'tool': 'build.tool to compile (python, nodejs, rust, golang)',
'version': 'specific version for the tool',
'os': 'ubuntu-20.04, ubuntu-22.04, ubuntu-24.04 (default)',
})
def compilebuildtool(c, tool, version, os=None):
def compilebuildtool(c, tool=None, version=None, everything=False, os=None):
"""Compile a ``build.tools`` to be able to use that tool/version from a build in a quick way."""
from readthedocs.builds.constants_docker import RTD_DOCKER_BUILD_SETTINGS

if not everything and not tool and not version:
print("You need to specify either 'everything' or a 'tool' and 'version'.")
sys.exit(1)

valid_oss = list(RTD_DOCKER_BUILD_SETTINGS['os'].keys())
valid_tools = RTD_DOCKER_BUILD_SETTINGS['tools'].keys()

if everything:
for os in valid_oss:
for tool in valid_tools:
valid_versions = RTD_DOCKER_BUILD_SETTINGS['tools'][tool].keys()
for version in valid_versions:
print(f"{os=} {tool=} {version=}")
final_version = RTD_DOCKER_BUILD_SETTINGS['tools'][tool][version]
c.run(f'OS={os} ./scripts/compile_version_upload_s3.sh {tool} {final_version}')
print("All the versions were successfully compiled.")
return

if not os:
# Skip `latest` version
# https://github.com/readthedocs/readthedocs.org/blob/7f9c8fd4f306479f228bb9aac02dd70f35270618/readthedocs/builds/constants_docker.py#L88
Expand All @@ -207,16 +225,13 @@ def compilebuildtool(c, tool, version, os=None):
print(f'Invalid os. You must specify one of {", ".join(valid_oss)}')
sys.exit(1)

valid_tools = RTD_DOCKER_BUILD_SETTINGS['tools'].keys()
if tool not in valid_tools:
print(f'Invalid tool. You must specify one of {", ".join(valid_tools)}')
sys.exit(1)

valid_versions = RTD_DOCKER_BUILD_SETTINGS['tools'][tool].keys()
if version not in valid_versions:
print(f'Invalid version for the specified tool. You must specify one of {", ".join(valid_versions)}')
sys.exit(1)

final_version = RTD_DOCKER_BUILD_SETTINGS['tools'][tool][version]

c.run(f'OS={os} ./scripts/compile_version_upload_s3.sh {tool} {final_version}')