Skip to content

Commit

Permalink
Include get_collections_from_package_and_version.py scripts and README
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 May 31, 2024
1 parent fce6534 commit 9f3592b
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
50 changes: 50 additions & 0 deletions jenkins-scripts/dsl/tools/README.md
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
```
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)}")

0 comments on commit 9f3592b

Please sign in to comment.