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) <gchamoul@redhat.com>
Change-Id: Ia8f787631c55fabb3a097919971d17b93711d4b7
(cherry picked from commit ae59abe)
(cherry picked from commit cc29577)
(cherry picked from commit da80177)
  • Loading branch information
strider authored and jpodivin committed Aug 20, 2021
1 parent 9a07b74 commit 39d5f55
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 @@ -120,6 +120,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 @@ -158,11 +160,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 39d5f55

Please sign in to comment.