Skip to content

Commit

Permalink
Plumb 'build_environment_variables' into doc jobs
Browse files Browse the repository at this point in the history
This buildfarm configuration variable has always been included for doc
job configurations, but has been left unused. With this change, those
variables are now used in 'doc' and 'rosdoc2' jobs in the same way that
they're used for devel, CI, and release jobs.
  • Loading branch information
cottsay committed Dec 12, 2024
1 parent c196ca5 commit c5d6e3a
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 2 deletions.
7 changes: 7 additions & 0 deletions ros_buildfarm/doc_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ def _get_doc_job_config(
repository_args, script_generating_key_files = \
get_repositories_and_script_generating_key_files(build_file=build_file)

build_environment_variables = []
if build_file.build_environment_variables:
build_environment_variables = [
'%s=%s' % (var, value)
for var, value in sorted(build_file.build_environment_variables.items())]

maintainer_emails = set([])
if build_file.notify_maintainers and dist_cache and repo_name and \
repo_name in dist_cache.distribution_file.repositories:
Expand Down Expand Up @@ -311,6 +317,7 @@ def _get_doc_job_config(
'arch': arch,
'build_tool': build_file.build_tool,
'repository_args': repository_args,
'build_environment_variables': build_environment_variables,

'upload_user': build_file.upload_user,
'upload_host': build_file.upload_host,
Expand Down
10 changes: 8 additions & 2 deletions ros_buildfarm/scripts/doc/create_doc_task_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
add_argument_distribution_repository_key_files
from ros_buildfarm.argument import add_argument_distribution_repository_urls
from ros_buildfarm.argument import add_argument_dockerfile_dir
from ros_buildfarm.argument import add_argument_env_vars
from ros_buildfarm.argument import add_argument_force
from ros_buildfarm.argument import add_argument_output_dir
from ros_buildfarm.argument import add_argument_repository_name
Expand Down Expand Up @@ -108,6 +109,7 @@ def main(argv=sys.argv[1:]):
add_argument_vcs_information(parser)
add_argument_distribution_repository_urls(parser)
add_argument_distribution_repository_key_files(parser)
add_argument_env_vars(parser)
add_argument_force(parser)
add_argument_output_dir(parser, required=True)
add_argument_dockerfile_dir(parser)
Expand Down Expand Up @@ -578,6 +580,11 @@ def main(argv=sys.argv[1:]):
debian_pkg_names.remove(debian_pkg_name)
print('# END SUBSECTION')

env_vars = {
**args.env_vars,
'ROS_PYTHON_VERSION': condition_context['ROS_PYTHON_VERSION'],
}

# generate Dockerfile
data = {
'os_name': args.os_name,
Expand All @@ -590,8 +597,7 @@ def main(argv=sys.argv[1:]):
args.distribution_repository_urls,
args.distribution_repository_key_files),

'environment_variables': [
'ROS_PYTHON_VERSION={}'.format(condition_context['ROS_PYTHON_VERSION'])],
'environment_variables': ['%s=%s' % key_value for key_value in env_vars.items()],

'rosdistro_name': args.rosdistro_name,

Expand Down
4 changes: 4 additions & 0 deletions ros_buildfarm/scripts/doc/create_rosdoc2_task_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
add_argument_distribution_repository_key_files
from ros_buildfarm.argument import add_argument_distribution_repository_urls
from ros_buildfarm.argument import add_argument_dockerfile_dir
from ros_buildfarm.argument import add_argument_env_vars
from ros_buildfarm.common import get_distribution_repository_keys
from ros_buildfarm.common import get_user_id
from ros_buildfarm.templates import create_dockerfile
Expand All @@ -45,6 +46,7 @@ def main(argv=sys.argv[1:]):
help="The architecture (e.g. 'amd64')")
add_argument_distribution_repository_urls(parser)
add_argument_distribution_repository_key_files(parser)
add_argument_env_vars(parser)
add_argument_dockerfile_dir(parser)
args = parser.parse_args(argv)

Expand All @@ -60,6 +62,8 @@ def main(argv=sys.argv[1:]):
args.distribution_repository_urls,
args.distribution_repository_key_files),

'environment_variables': ['%s=%s' % key_value for key_value in args.env_vars.items()],

'uid': get_user_id(),
}
create_dockerfile('doc/rosdoc2_task.Dockerfile.em', data, args.dockerfile_dir)
Expand Down
2 changes: 2 additions & 0 deletions ros_buildfarm/scripts/doc/run_doc_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
add_argument_distribution_repository_key_files
from ros_buildfarm.argument import add_argument_distribution_repository_urls
from ros_buildfarm.argument import add_argument_dockerfile_dir
from ros_buildfarm.argument import add_argument_env_vars
from ros_buildfarm.argument import add_argument_force
from ros_buildfarm.argument import add_argument_os_code_name
from ros_buildfarm.argument import add_argument_os_name
Expand Down Expand Up @@ -56,6 +57,7 @@ def main(argv=sys.argv[1:]):
add_argument_custom_rosdep_urls(parser)
add_argument_custom_rosdep_update_options(parser)
add_argument_force(parser)
add_argument_env_vars(parser)
add_argument_dockerfile_dir(parser)
args = parser.parse_args(argv)

Expand Down
2 changes: 2 additions & 0 deletions ros_buildfarm/scripts/doc/run_rosdoc2_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
add_argument_distribution_repository_key_files
from ros_buildfarm.argument import add_argument_distribution_repository_urls
from ros_buildfarm.argument import add_argument_dockerfile_dir
from ros_buildfarm.argument import add_argument_env_vars
from ros_buildfarm.argument import add_argument_os_code_name
from ros_buildfarm.argument import add_argument_os_name
from ros_buildfarm.common import get_distribution_repository_keys
Expand All @@ -36,6 +37,7 @@ def main(argv=sys.argv[1:]):
add_argument_arch(parser)
add_argument_distribution_repository_urls(parser)
add_argument_distribution_repository_key_files(parser)
add_argument_env_vars(parser)
add_argument_dockerfile_dir(parser)
args = parser.parse_args(argv)

Expand Down
1 change: 1 addition & 0 deletions ros_buildfarm/templates/doc/doc_create_task.Dockerfile.em
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ cmds = [
' --vcs-info "%s"' % vcs_info + \
' --distribution-repository-urls ' + ' '.join(distribution_repository_urls) + \
' --distribution-repository-key-files ' + ' ' .join(['/tmp/keys/%d.key' % i for i in range(len(distribution_repository_keys))]) + \
' --env-vars ' + ' ' .join(['%s=%s' % key_value for key_value in env_vars.items() + \
(' --force' if force else '') + \
' --output-dir /tmp/generated_documentation' + \
' --dockerfile-dir /tmp/docker_doc',
Expand Down
1 change: 1 addition & 0 deletions ros_buildfarm/templates/doc/doc_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ else:
' ' + os_code_name +
' ' + arch +
' --build-tool ' + build_tool +
' --env-vars ' + ' '.join([v.replace('$', '\\$',) for v in build_environment_variables]) +
' --vcs-info "%s %s %s"' % (doc_repo_spec.type, doc_repo_spec.version if doc_repo_spec.version is not None else '', doc_repo_spec.url) +
' ' + ' '.join(repository_args) +
' $FORCE_FLAG' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ cmds = [
' --arch ' + arch + \
' --distribution-repository-urls ' + ' '.join(distribution_repository_urls) + \
' --distribution-repository-key-files ' + ' ' .join(['/tmp/keys/%d.key' % i for i in range(len(distribution_repository_keys))]) + \
' --env-vars ' + ' ' .join(['%s=%s' % key_value for key_value in env_vars.items() + \
' --dockerfile-dir /tmp/docker_doc',
]
}@
Expand Down
1 change: 1 addition & 0 deletions ros_buildfarm/templates/doc/rosdoc2_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ else:
' ' + os_code_name +
' ' + arch +
' ' + ' '.join(repository_args) +
' --env-vars ' + ' '.join([v.replace('$', '\\$',) for v in build_environment_variables]) +
' --dockerfile-dir $WORKSPACE/docker_generating_docker',
'echo "# END SECTION"',
'',
Expand Down
5 changes: 5 additions & 0 deletions ros_buildfarm/templates/doc/rosdoc2_task.Dockerfile.em
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ ENV DEBIAN_FRONTEND noninteractive
uid=uid,
))@

@(TEMPLATE(
'snippet/set_environment_variables.Dockerfile.em',
environment_variables=environment_variables,
))@

@(TEMPLATE(
'snippet/add_distribution_repositories.Dockerfile.em',
distribution_repository_keys=distribution_repository_keys,
Expand Down

0 comments on commit c5d6e3a

Please sign in to comment.