Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace indexes by looping over directly to respect ci_config
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
j-rivero committed May 15, 2024
1 parent 54a15c9 commit d127be0
Showing 1 changed file with 87 additions and 97 deletions.
184 changes: 87 additions & 97 deletions jenkins-scripts/dsl/gazebo_libs.dsl
Original file line number Diff line number Diff line change
@@ -323,7 +323,13 @@ def generate_debbuilder_job(src_name, ArrayList pre_setup_script_hooks)
def ciconf_per_lib_index = [:].withDefault { [:] }
def pkgconf_per_src_index = [:].withDefault { [:] }
generate_ciconfigs_by_lib(gz_collections_yaml, ciconf_per_lib_index, pkgconf_per_src_index)

/*
*
* Loop over each collection, inside each collection loop over the ci configurations assigned
* and finally loop over each collection library listed.
*
*/
def branch_index = [:].withDefault { [:] }
gz_collections_yaml.collections.each { collection ->
collection.ci.configs.each { config_name ->
def ci_config = gz_collections_yaml.ci_configs.find{ it.name == config_name }
@@ -335,6 +341,32 @@ gz_collections_yaml.collections.each { collection ->
def branch_name = lib.repo.current_branch
def gz_job_name_prefix = lib_name.replaceAll('-','_')

// Build the branch_index while going through all the libraries to avoid
// looping twice.
if (ci_config.system.so == 'linux') {
platform = distro
} else if (ci_config.system.so == 'darwin') {
platform = 'homebrew'
} else if (ci_config.system.so == 'windows') {
platform = 'windows'
}
branch_index[lib_name][platform] = branch_index[lib_name][platform]?: ['pr':[], 'pr_abichecker':[]]
if (! ci_config.exclude.all?.contains(lib_name))
{
if (categories_enabled.contains('pr'))
{
branch_index[lib_name][platform]['pr'].contains(branch_name) ?:
branch_index[lib_name][platform]['pr'] << [branch: branch_name, ci_name: config_name]
}
if (categories_enabled.contains('pr_abichecker') &&
(! ci_config.exclude.abichecker?.contains(lib_name)))
{
branch_index[lib_name][platform]['pr_abichecker'].contains(branch_name) ?:
branch_index[lib_name][platform]['pr_abichecker'] << [branch: branch_name, ci_name: config_name]
}
}

// Generate jobs for the library entry being parsed
if (categories_enabled.contains('stable_branches')) {
if (ci_config.system.so == 'linux') {
gz_ci_job = job("${gz_job_name_prefix}-ci-${branch_name}-${distro}-${arch}")
@@ -379,54 +411,25 @@ gz_collections_yaml.collections.each { collection ->
job_name: gz_ci_job.name])
} // end of daily category enabled
}

if (categories_enabled.contains('pr'))
{
if (ci_config.system.so == 'linux')
{
def pre_setup_script = ci_config.pre_setup_script_hook?.get(lib_name)?.join('\n')
def extra_cmd = pre_setup_script ?: ""
if (categories_enabled.contains('stable_branches') && \
(! ci_config.exclude.abichecker?.contains(lib_name)))
{
// generate_label_by_requirements(gz_ci_any_job, lib_name, ci_config.requirements)
}
} else if (ci_config.system.so == 'darwin') {
} else if (ci_config.system.so == 'windows') {
}

}
}

return

// Generate PR jobs: 1 per ci configuration on each lib
ciconf_per_lib_index.each { lib_name, lib_configs ->
lib_configs.each { ci_configs ->
def config_name = ci_configs.getKey()
def ci_config = gz_collections_yaml.ci_configs.find{ it.name == config_name }
def branches_with_collections = ci_configs.getValue()
def branch_names = branches_with_collections.collect { it.branch }.unique()
def script_name_prefix = cleanup_library_name(lib_name)
def gz_job_name_prefix = lib_name.replaceAll('-','_')
def distro = ci_config.system.version
def arch = ci_config.system.arch
def categories_enabled = ci_config.ci_categories_enabled
def ws_checkout_dir = lib_name
if (ci_config.exclude.all?.contains(lib_name))
return
assert(lib_name)
assert(branch_names)
assert(ci_config)
assert(categories_enabled)

if (categories_enabled.contains('pr'))
{
branch_index.each { lib_name, distro_configs ->
distro_configs.each { distro, branches_with_ciconfig ->
if (branches_with_ciconfig['pr']) {
def branch_names = branches_with_ciconfig['pr'].collect { it.branch }.unique()
// Hack that assumes that pre_setup_script_hook, arch and requirements are equal on all
// ciconfigs associated to a given branch and distro combination
def config_name = branches_with_ciconfig['pr'].collect { it.ci_name }.unique()[0]
def ci_config = gz_collections_yaml.ci_configs.find{ it.name == config_name }
def script_name_prefix = cleanup_library_name(lib_name)
def gz_job_name_prefix = lib_name.replaceAll('-','_')
def arch = ci_config.system.arch
def ws_checkout_dir = lib_name
if (ci_config.system.so == 'linux')
{
def pre_setup_script = ci_config.pre_setup_script_hook?.get(lib_name)?.join('\n')
def extra_cmd = pre_setup_script ?: ""

def gz_ci_job_name = "${gz_job_name_prefix}-ci-pr_any-${distro}-${arch}"
def gz_ci_any_job = job(gz_ci_job_name)
OSRFLinuxCompilationAnyGitHub.create(gz_ci_any_job,
@@ -435,57 +438,6 @@ ciconf_per_lib_index.each { lib_name, lib_configs ->
ENABLE_CPPCHECK,
branch_names)
generate_label_by_requirements(gz_ci_any_job, lib_name, ci_config.requirements)
gz_ci_any_job.with
{
steps
{
shell("""\
#!/bin/bash -xe

export DISTRO=${distro}

${GLOBAL_SHELL_CMD}
${extra_cmd}

export BUILDING_SOFTWARE_DIRECTORY=${lib_name}
export ARCH=${arch}
/bin/bash -xe ./scripts/jenkins-scripts/docker/${script_name_prefix}-compilation.bash
""".stripIndent())
} // end of steps
} // end of ci_any_job

if (categories_enabled.contains('stable_branches') && \
(! ci_config.exclude.abichecker?.contains(lib_name)))
{
// ABI branch jobs (-ci-abichecker-) for non main branches
def abi_job_name = "${gz_job_name_prefix}-abichecker-any_to_any-ubuntu-${distro}-${arch}"
def abi_job = job(abi_job_name)
OSRFLinuxABIGitHub.create(abi_job)
GenericAnyJobGitHub.create(abi_job,
"gazebosim/${lib_name}",
branch_names - [ 'main'])
generate_label_by_requirements(abi_job, lib_name, ci_config.requirements)
abi_job.with
{
steps {
shell("""\
#!/bin/bash -xe

export DISTRO=${distro}

${GLOBAL_SHELL_CMD}
${extra_cmd}

export ARCH=${arch}
export DEST_BRANCH=\${DEST_BRANCH:-\$ghprbTargetBranch}
export SRC_BRANCH=\${SRC_BRANCH:-\$ghprbSourceBranch}
export SRC_REPO=\${SRC_REPO:-\$ghprbAuthorRepoGitUrl}
export ABI_JOB_SOFTWARE_NAME=${lib_name}
/bin/bash -xe ./scripts/jenkins-scripts/docker/gz-abichecker.bash
""".stripIndent())
} // end of steps
} // end of with
}
} else if (ci_config.system.so == 'darwin') {
// --------------------------------------------------------------
def gz_brew_ci_any_job_name = "${gz_job_name_prefix}-ci-pr_any-homebrew-amd64"
@@ -510,9 +462,48 @@ ciconf_per_lib_index.each { lib_name, lib_configs ->
add_win_devel_bat_call(gz_win_ci_any_job, lib_name, ws_checkout_dir)
Globals.gazebodistro_branch = false
}
} //end of pr enabled
} //end of lib_configs
} // end of lib
}

if (branches_with_ciconfig['pr_abichecker']) {
def branch_names = branches_with_ciconfig['pr_abichecker'].collect { it.branch }.unique()
// Hack that assumes that pre_setup_script_hook, arch and requirements are equal on all
// ciconfigs associated to a given branch and distro combination
def config_name = branches_with_ciconfig['pr_abichecker'].collect { it.ci_name }.unique()[0]
def ci_config = gz_collections_yaml.ci_configs.find{ it.name == config_name }
def pre_setup_script = ci_config.pre_setup_script_hook?.get(lib_name)?.join('\n')
def extra_cmd = pre_setup_script ?: ""
def arch = ci_config.system.arch
def gz_job_name_prefix = lib_name.replaceAll('-','_')
def abi_job_name = "${gz_job_name_prefix}-abichecker-any_to_any-ubuntu-${distro}-${arch}"
def abi_job = job(abi_job_name)
OSRFLinuxABIGitHub.create(abi_job)
GenericAnyJobGitHub.create(abi_job,
"gazebosim/${lib_name}",
branch_names - [ 'main'])
generate_label_by_requirements(abi_job, lib_name, ci_config.requirements)
abi_job.with
{
steps {
shell("""\
#!/bin/bash -xe

export DISTRO=${distro}

${GLOBAL_SHELL_CMD}
${extra_cmd}

export ARCH=${arch}
export DEST_BRANCH=\${DEST_BRANCH:-\$ghprbTargetBranch}
export SRC_BRANCH=\${SRC_BRANCH:-\$ghprbSourceBranch}
export SRC_REPO=\${SRC_REPO:-\$ghprbAuthorRepoGitUrl}
export ABI_JOB_SOFTWARE_NAME=${lib_name}
/bin/bash -xe ./scripts/jenkins-scripts/docker/gz-abichecker.bash
""".stripIndent())
} // end of steps
} // end of with
}
}
}

pkgconf_per_src_index.each { pkg_src, pkg_src_configs ->
// For each entry in the index perform two steps:
@@ -615,7 +606,6 @@ collection_job_names.each { collection_name, job_names ->
name(jobname)
}
def collection = gz_collections_yaml.collections.find { it.name == collection_name }
println(collection)
if (collection.packaging?.linux?.nightly) {
collection.libs.each { lib ->
name(get_debbuilder_name(lib, collection.packaging))

0 comments on commit d127be0

Please sign in to comment.