Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include a script to obtain gazebo releases for a given library #1148

Merged
merged 7 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ Gazebo software.
## Scripts

* [release.py](release.py): Triggers new debian and homebrew releases (major, minor, patch, pre-release...).
* For -release repository scripts, please see [release-repo-scripts/README.md](release-repo-scripts/README.md)
* For source repository scripts, please see [source-repo-scripts/README.md](source-repo-scripts/README.md)
* For scripts working on -release repositories, please see [release-repo-scripts/README.md](release-repo-scripts/README.md)
* For scripts working on library source repositories, please see [source-repo-scripts/README.md](source-repo-scripts/README.md)
* For scripts related to unofficial ROS packages, please see [bloom scripts](bloom/ros_gazebo_pkgs/README.md)
* For scripts working on DSL Jenkins code and/or gz-collections.yaml, please see [dsl/tools](jenkins-scripts/dsl/tools/README.md)

### Making releases

Expand Down
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

DSL is the Jenkins plugins that allows to use code for creating
the different Jenkins jobs and configurations.

### 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 provided as a space separated list in a single line. If
no match is found, the result is an empty string.

#### 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,42 @@
#!/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) -> list:
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) -> int:
elements = version.split('.')
return int(elements[0])


def main() -> int:
if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} <lib_name> <major_version> <collection-yaml-file>")
return 2

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))
if not collection_names:
return 1
print(f"{' '.join(collection_names)}")
return 0


if __name__ == '__main__':
sys.exit(main())
Loading