-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include get_collections_from_package_and_version.py scripts and README
Signed-off-by: Jose Luis Rivero <[email protected]>
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Scripts for working with Jenkins DSL and gz-collections.yaml | ||
|
||
## DSL | ||
|
||
## setup_local_generation.bash (jobdsl.jar) | ||
|
||
Script use to generate job configuration locally for Jenkins. See | ||
[Jenkins script README](../README.md) | ||
|
||
## gz-collections.yaml | ||
|
||
The `gz-collections.yaml` file stores all the metadata corresponding | ||
to the different collections of Gazebo, the libraries that compose | ||
each release and the metadata for creating the buildfarm jobs that | ||
implement the CI and packaging. | ||
|
||
The file is useful for scripts that use global information about the | ||
Gazebo libraries. | ||
|
||
### get_collections_from_package_and_version.py | ||
|
||
The script return the Gazebo releases (also known as collections) that | ||
contains a given library and major version that are provided as input | ||
parameters. | ||
|
||
The output is provid | ||
|
||
The output is provided as a space separated list in a single line. | ||
Nothing if not found.ed as a space separated list in a single line. | ||
Nothing if not found. | ||
|
||
#### Usage | ||
|
||
``` | ||
./get_collections_from_package_and_version.py <lib_name> <major_version> <path-to-gz-collections.yaml> | ||
``` | ||
|
||
Be sure of not including the major version number in the `<lib_name>` | ||
|
||
#### Example | ||
|
||
``` | ||
$./get_collections_from_package_and_version.py gz-cmake 3 ../gz-collections.yaml | ||
``` | ||
|
||
That generates the result of: | ||
|
||
``` | ||
garden harmonic | ||
``` |
35 changes: 35 additions & 0 deletions
35
jenkins-scripts/dsl/tools/get_collections_from_package_and_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python3 | ||
|
||
import sys | ||
import yaml | ||
|
||
|
||
# Function to find the collection name based on lib name and major version | ||
def find_collection(data, lib_name, major_version): | ||
instances = [] | ||
|
||
for collection in data['collections']: | ||
for lib in collection['libs']: | ||
if lib['name'] == lib_name and lib['major_version'] == major_version: | ||
instances.append(collection['name']) | ||
return instances | ||
|
||
|
||
def get_major_version(version): | ||
elements = version.split('.') | ||
return int(elements[0]) | ||
|
||
|
||
if len(sys.argv) < 3: | ||
print(f"Usage: {sys.argv[0]} <lib_name> <major_version> <collection-yaml-file>") | ||
sys.exit(1) | ||
|
||
lib_name = sys.argv[1] | ||
version = sys.argv[2] | ||
yaml_file = sys.argv[3] | ||
|
||
with open(yaml_file, 'r') as file: | ||
data = yaml.safe_load(file) | ||
|
||
collection_names = find_collection(data, lib_name, get_major_version(version)) | ||
print(f"{' '.join(collection_names)}") |