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

Redefine roles, rewrite readme #28

Merged
merged 1 commit into from
Nov 1, 2023
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
12 changes: 8 additions & 4 deletions roles/colcon_build/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REPOSITORIES
COLCON BUILD
=========

Reads repos file contents similar to existing VCS tool, downloads the repositories in indicated repos file. Downloads repositories from dictionary lists.
Runs the `colcon build` command.

![Ansible Lint](https://github.com/bounverif/ansible-collection-ros/actions/workflows/ansible-lint.yml/badge.svg)

Expand All @@ -27,6 +27,7 @@ Two global variables must be defined to use this role. Definitions and required
| colcon_build_continue_on_error | no| `false` | `bool value` | Continue execution even if an error occurs. For details see Colcon documentation. |
| colcon_build_use_cmake_args | no | `true` | `bool value` | Indicates whether user cmake args flag or not. |
| colcon_build_cmake_args | no | `"-DCMAKE_BUILD_TYPE=Release"`| `directory path` | CMake arguments that will be called while CMake running. |
| colcon_build_packages_up_to | no | `no default` | `list of package names (string)` | Packages are installed up to given package name. For more details see Colcon documentation. |


Dependencies
Expand All @@ -41,17 +42,20 @@ An example playbook is provided below:

```
---
- name: Colcon Build Role - File Read
- name: Colcon Build Role
hosts: localhost
connection: local

vars:
repos_directory: "/tmp/ros/workspace/"
ros_workspace: "/tmp/workspace/"
colcon_build_build_base_dir: "/tmp/workspace/build"
colcon_build_install_base_dir: "/tmp/workspace/install"
colcon_build_symlink_install: true
colcon_build_use_cmake_args: true
colcon_build_cmake_args: "-DCMAKE_BUILD_TYPE=Release"
colcon_build_packages_up_to:
- package1
- package2

roles:
- role: bounverif.ros.colcon_build
Expand Down
2 changes: 1 addition & 1 deletion roles/colcon_build/templates/colcon_build.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ colcon build
{% if colcon_build_test_result_base %}--test-result-base {{ colcon_build_test_result_base_dir }}{% endif %}
{% if colcon_build_continue_on_error %}--continue-on-error{% endif %}
{% if colcon_build_use_cmake_args %}--cmake-args {{ colcon_build_cmake_args }}{% endif %}
{% if colcon_build_packages_up_to %}--packages-up-to {% for __dependency in colcon_build_packages_up_to %} {{ __dependency }} {% endfor %}{% endif %}
{% if colcon_build_packages_up_to is defined %}--packages-up-to {% for __dependency in colcon_build_packages_up_to %} {{ __dependency }} {% endfor %}{% endif %}
17 changes: 7 additions & 10 deletions roles/repositories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ Reads repos file contents similar to existing VCS tool, downloads the repositori
Requirements
------------

A valid path to a directory in which includes files written in `repos` format, or a valid list constructed by dictionaries which have `ansible.builtin.git` module's parameters.
A valid path to a directory in which includes files written in `repos` format no matter what is the file name, or a valid list constructed by dictionaries which have `ansible.builtin.git` module's parameters.

For file reading define `repositories_source_dir` which is a string of a relative or absolute directory path, that directory can also be defined by defining `ROS_WORKSPACE` environment variable. Define `repositories_files` that is a list of strings constructed by file names. Do not define any `repositories` named list or variable. Define `repositories_download_dir` as a directory, if the repository is not defined a specific `dest` value, then the files will be downloaded onto `repositories_download_dir`.
For file reading define `repositories_files` which is a string of a relative or absolute directory path. Define `repositories_files` that is a list of strings constructed by only file names. The repository will read `<collection_name>/files/` directory in the collection. Do not define any `repositories` named list or variable. Until then, it will work same as the VCS tool. Also define `collection_name` as the real collection name.

For variable reading define a `repositories` list variable which consists of dictionaries that have parameters of `ansible.builtin.git` module. Do not define the variable `repositories_files`.

Additionally, for all cases, do not define a variable named `repositories_file_path_list`, this is a meta-variable reserved for calculations.

Role Variables
--------------

These variables must be defined according to the usage to use this role. Definitions and required information on below.

| Variable | Required | Default | Choices | Comments |
|-------------------------|----------|--------------|---------------------------|------------------------------------------|
| repositories_source_dir | yes | `no default` | `directory path` | A directory name. Required when read_repositories_from_file is set `true`. |
| repositories_download_dir | yes | `no default` | `directory path` | Indicates a prefix path where to download repositories, which will be joined with the path on `key` value on repos file. Used when `dest` parameter on git parameter is not set. |
| ros_source_dir | yes | `no default` | `directory path` | A directory name. Required when read_repositories_from_file is set `true`. |
| repositories | yes | `no default` | `list of dictionaries` | List of dictionaries with fields named as git builtin. Do not define if `repositories_files` set. |
| repositories_files | yes | `no default` | `list of file names` | Names of files will be read. If defined, then the role will read files instead of `repositories` list.|
| collection_name | yes | `no default` | `name of collection` | Name of your own collection. |


Dependencies
Expand All @@ -45,8 +43,7 @@ An example playbook using file read feature, runs this role on localhost. For th
hosts: localhost
connection: local
vars:
repositories_source_dir: "/tmp/ros/examples/sample_repos_file/"
repositories_download_dir: "/tmp/ros/src"
ros_source_dir: "/tmp/ros/examples/sample_repos_file/"
repositories_files:
- file1.repos
- file2.yaml
Expand All @@ -61,8 +58,8 @@ An example playbook using file read feature, runs this role on localhost. For th
connection: local
vars:
repositories:
- { url: https://github.com/some/git/repository1.git, dest: "/to/some/download/path/", version: main }
- { url: https://github.com/some/git/repository2.git, dest: "/to/some/download/path/", version: main }
- { url: https://github.com/some/git/repository1.git, dest: "to/some/download/path/", version: main }
- { url: https://github.com/some/git/repository2.git, dest: "to/some/download/path/", version: main }
roles:
- role: bounverif.ros.repositories
```
Expand Down
3 changes: 0 additions & 3 deletions roles/repositories/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
repositories_source_dir: "{{ lookup('ansible.builtin.env', 'ROS_WORKSPACE', default='') }}"
repositories_download_dir: "{{ ros_source_dir }}"
repositories: {}
repositories_file_path_list: []
2 changes: 1 addition & 1 deletion roles/repositories/tasks/from_file.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: Load Repos Files
ansible.builtin.include_vars:
file: "{{ item }}"
file: "../../../{{ collection_name }}/files/{{ item }}"
hash_behaviour: "merge"
name: repositories
loop: "{{ repositories_files }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/repositories/tasks/from_variable.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- name: Clone Repositories
ansible.builtin.git:
repo: "{{ item.url }}"
dest: "{{ item.dest }}"
dest: "{{ ([ros_source_dir, item.dest] | path_join) }}"
version: "{{ item.version | default(omit) }}"
depth: "{{ item.depth | default(omit) }}"
single_branch: "{{ item.single_branch | default(omit) }}"
Expand Down
Loading