Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Sort jobs in molecule.yaml file when adding new role
Browse files Browse the repository at this point in the history
This patch adds a mechanism to keep the job names in
zuul.d/molecule.yaml sorted. Therefore, the to_nice_yaml filter is not
indenting lists correctly, due to [1][2].

[1] ansible/ansible#48865
[2] yaml/pyyaml#234

Signed-off-by: Gael Chamoulaud (Strider) <[email protected]>
Change-Id: Ia8f787631c55fabb3a097919971d17b93711d4b7
  • Loading branch information
strider committed Jul 5, 2021
1 parent 41dcda8 commit ae59abe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions roles/validation_init/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
- name: Create molecule entry
copy:
content: |-
# Managed via ./role-addition.yml, do not edit manually without testing that
# new role addition does not reformat it.
---
{% set items = molecule_yaml['content'] | b64decode | from_yaml %}
{% set job_index = [] %}
Expand Down Expand Up @@ -153,11 +155,14 @@
"vars": {
"tripleo_validations_role_name": validation_init_prefix ~ "_" ~ _role_name
}
}
}
%}
{% set _ = items.append({"job": new_job}) %}
{% endif %}
{{ items | to_nice_yaml(indent=2, width=1337) }}
{% set project = items.pop(0) %}
{% set sorted_jobs = items | sort(attribute='job.name') %}
{% set _ = sorted_jobs.insert(0, project) %}
{{ sorted_jobs | to_nice_yaml(indent=2, width=1337) }}
dest: "{{ validation_init_zuuld_molecule }}"

- name: Create role documentation
Expand Down

0 comments on commit ae59abe

Please sign in to comment.