Skip to content

Commit

Permalink
Change gazebo_libs code to support new format
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero committed Jul 14, 2023
1 parent 872d0df commit eb54989
Showing 1 changed file with 103 additions and 45 deletions.
148 changes: 103 additions & 45 deletions jenkins-scripts/dsl/gazebo_libs.dsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,35 @@ import org.yaml.snakeyaml.Yaml
GLOBAL_SHELL_CMD=''

// GZ COLLECTIONS
arch = 'amd64'
ENABLE_CPPCHECK = true

// Jenkins needs the relative path to work and locally the simulation is done
// using a symlink
file = readFileFromWorkspace("scripts/jenkins-scripts/dsl/gz-collections.yaml")
gz_collections_yaml = new Yaml().load(file)

boolean include_gpu_label_if_needed(job, lib, ci_info)
void generate_label_by_requirements(job, lib_name, ci_config)
{
def nvidia_requirement = ci_config.tests.requirements.nvidia_gpu
def large_memory_requirement = ci_config.build.requirements.large_memory

if (nvidia_requirement.contains(lib_name) &&
large_memory_requirement.contains(lib_name)) {
println ("ERROR: more than one label is generated by requirements")
exit(1)
}

label = nvidia_requirement.contains(lib_name) ? "gpu-nvidia" : null
if (! label)
label = large_memory_requirement.contains(lib_name) ? "large-memory" : null
if (! label)
return

job.with
{
if (ci_info.requirements.nvidia_gpu.contains(lib.name))
{
label Globals.nontest_label("gpu-reliable")
label Globals.nontest_label(label)

if (nvidia_requirement.contains(lib_name)) {
// unstable build if missing valid gpu display
publishers {
consoleParsing {
Expand All @@ -35,44 +48,89 @@ boolean include_gpu_label_if_needed(job, lib, ci_info)
}
}

[ 'harmonic' ].each { collection_name ->
collection = gz_collections_yaml.collections. find { it.name == collection_name }
collection.ci.linux.reference_distro.each { distro ->
collection.libs.findAll { ! collection.ci.exclude.contains(it.name) }.each { lib ->
assert(lib.name)
assert(lib.repo.current_branch)
// 1.2.1 Main PR jobs (-ci-pr_any-) (pulling check every 5 minutes)
// --------------------------------------------------------------
def gz_job_name_prefix = lib.name.replaceAll('-','_')
def gz_ci_job_name = "${gz_job_name_prefix}-ci-pr_any-${distro}-${arch}"
def gz_ci_any_job = job(gz_ci_job_name)
def enable_testing = (collection.ci.tests_disabled?.contains(lib.name)) ? false : true
OSRFLinuxCompilationAnyGitHub.create(gz_ci_any_job,
"gazebosim/${lib.name}",
enable_testing,
ENABLE_CPPCHECK,
[ lib.repo.current_branch ])
include_gpu_label_if_needed(gz_ci_any_job, lib, collection.ci)
gz_ci_any_job.with
boolean is_testing_enabled(lib_name, ci_config)
{
return ! ci_config.tests_disabled?.contains(lib_name)
}


/*
* Generate the indexes that facilitates the operations with the yaml values
* avoiding to parse them several times.
*
* Index 1:
* lib_name : [ ci_config_name : [ branches ] ]
*
* Map main entries keys are the lib names (i.e: gz-cmake) associated them
* another map of CI configuration name entries as keys (i.e: jammy) with
* list of associated branches for that configuration (i.e [gz-cmake3, gz-cmake4])
* Groovy spec
*/
void generate_ciconfigs_by_lib(config, configs_per_lib_index)
{
config.collections.each { collection ->
// TODO(jriveor): limit to harmonic for testing proposes
if (collection.name != 'harmonic')
return

collection.libs.each { lib ->
def libName = lib.name
def branch = lib.repo.current_branch
collection.ci.configs.each { config_name ->
configs_per_lib_index["$libName"]["${config_name}"] = configs_per_lib_index["$libName"]["${config_name}"]?: []
configs_per_lib_index["$libName"]["${config_name}"].contains(branch) ?: configs_per_lib_index["$libName"]["${config_name}"] << branch
}
}
}
}

def configs_per_lib_index = [:].withDefault { [:] }
generate_ciconfigs_by_lib(gz_collections_yaml, configs_per_lib_index)

// Generate PR jobs: 1 per ci configuration on each lib
configs_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 branch_names = ci_configs.getValue()
if (ci_config.exclude.contains(lib_name))
return
assert(lib_name)
assert(branch_names)
assert(ci_config)

if (ci_config.exclude.contains(lib_name))
return

// 1.2.1 Main PR jobs (-ci-pr_any-) (pulling check every 5 minutes)
// --------------------------------------------------------------
def distro = ci_config.system.version
def arch = ci_config.system.arch
def gz_job_name_prefix = lib_name.replaceAll('-','_')
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,
"gazebosim/${lib_name}",
is_testing_enabled(lib_name, ci_config),
ENABLE_CPPCHECK,
branch_names)
generate_label_by_requirements(gz_ci_any_job, lib_name, ci_config)
gz_ci_any_job.with
{
steps
{
if (collection.ci.requirements.large_memory?.contains(lib.name))
label Globals.nontest_label("large-memory")

steps
{
shell("""\
#!/bin/bash -xe

export DISTRO=${distro}

${GLOBAL_SHELL_CMD}

export BUILDING_SOFTWARE_DIRECTORY=${lib.name}
export ARCH=${arch}
/bin/bash -xe ./scripts/jenkins-scripts/docker/${gz_job_name_prefix}-compilation.bash
""".stripIndent())
} // end of steps
} // end of ci_any_job
} //en of lib
} // end of distro
} // end of collection
shell("""\
#!/bin/bash -xe

export DISTRO=${distro}

${GLOBAL_SHELL_CMD}

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

0 comments on commit eb54989

Please sign in to comment.