-
Notifications
You must be signed in to change notification settings - Fork 8
Role junit2json
and its infrastructure
#179
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
base: main
Are you sure you want to change the base?
Conversation
- name: Expand the input list to list of existing files | ||
ansible.builtin.include_tasks: | ||
file: expand.yml | ||
loop: "{{ junit2_input_reports_list }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a list - in the default.yml it set as a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is a list of str, defined here: playbooks/infra/reporting/roles/junit2json/meta/argument_specs.yml
, the 1st variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats not a var location - it's metadata
under ./default/main.yml the var is defined as str
file: expand.yml | ||
loop: "{{ junit2_input_reports_list }}" | ||
loop_control: | ||
loop_var: file_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is the var coming from ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also change the name -- file_name is too generic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
junit2_input_reports_list
is role's variable (refer todefaults/main.yml
andmeta/argument_spec.yml
),loop_var
is how I set the name of the variable instead ofitem
(for the loop, to be used insideexpand.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very complex - there is a lot of naming issues / redandant tasks and vars
please go over the comment - and try to make it simpler and shorter
we can skip / merge quite a few steps here
I'll review it once your done
file: expand.yml | ||
loop: "{{ junit2_input_reports_list }}" | ||
loop_control: | ||
loop_var: file_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also change the name -- file_name is too generic
- name: Collect file_name stat | ||
ansible.builtin.stat: | ||
path: "{{ file_name }}" | ||
register: _junit2json_path_item_stat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name should include the task name or the file name
example
register: _junit2json_path_item_stat | |
register: _expand_file_stat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want the file_name
to be as generic, so that I can do ansible.builtin.import_tasks
from this role in another role.
- not(_junit2json_path_item_stat.stat.isdir | default(false)) | ||
- _junit2json_path_item_stat.stat.exists | default(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for default
- not(_junit2json_path_item_stat.stat.isdir | default(false)) | |
- _junit2json_path_item_stat.stat.exists | default(false) | |
- not(_junit2json_path_item_stat.stat.isdir | |
- _junit2json_path_item_stat.stat.exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ansible.builtin.set_fact: | ||
junit2_reports_list: "{{ junit2_reports_list + [file_name] }}" | ||
when: | ||
- _junit2json_path_item_stat.stat.exists | default(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- _junit2json_path_item_stat.stat.exists | default(false) | |
- _junit2json_path_item_stat.stat.exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
- name: Update junit2_reports_list with a JUnit XML report item | ||
ansible.builtin.set_fact: | ||
junit2_reports_list: "{{ junit2_reports_list + [file_name] }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you initialize this as empty value and then you trying to add empty with the file_name?
lets do the initialisation here and remove it from main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eifrach because I am testing this role in several calls to the role, the list must be reset this list each time the code is in tasks/main.yml
. (Otherwise this list will be updated each run)
It is possible to put it deeper than tasks/main.yml, but I think
tasks/main.yml` is more readable.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to change you're code to make you test work
it should be the other way around
- name: Ensure junit2_output_dir is created | ||
ansible.builtin.include_tasks: | ||
file: ensure-dir.yml | ||
loop: | ||
- "{{ junit2_output_dir }}" | ||
loop_control: | ||
loop_var: folder_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this a loop ? are we creating more than one folder?
also if you only create the folder once no need to put it in a new file / playboolk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eifrach 👍 thank you, good catch, it is a left-over
content: "{{ junit2_result_data | junit2obj | to_nice_json(indent=2) }}" | ||
dest: "{{ junit2_output_report_path }}" | ||
mode: '0644' | ||
when: not junit2_out_str | bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this please explain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 use cases:
- with the filter
to_nice_json(indent=2)
creates a serializable JSON data, is easy to read and compare, load and merge. - without the filter, a single string is created. It is more convenient for dumping all of it in a template.
content: "{{ junit2_result_data | junit2obj }}" | ||
dest: "{{ junit2_output_report_path }}" | ||
mode: '0644' | ||
when: junit2_out_str | bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
ansible.builtin.include_tasks: | ||
file: merge.yml | ||
when: | ||
- junit2_do_merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are cases when we don't merge it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if so when does it change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during tests mainly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to test a case we don't use
- name: Load dummy variables configuration | ||
ansible.builtin.include_vars: | ||
file: dummy_variables.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the data inside test reports sometimes contains parts of jinja code, Please refer to this file:
https://github.com/mvk/eco-ci-cd/blob/role-junit2obj/playbooks/infra/reporting/roles/junit2json/doc/dummy_variables.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The name of the role and the file are not related to what it's for
- can you explain why we shouldn't create a simple python script to do this instead of this complex steps ?
General comment - you added a role under playbooks/infra/reporting but this path is not included under roles_path in ansible.cfg. Also, it's very difficult to review this since it's too long, I would split it into several much shorter PRs with proper documentation. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
ee0df99
to
948ee49
Compare
@shaior, I referred to storing-and-finding-roles, namely:
this means we don't have to update |
splitting this one into several commits now, will comment on it, then I will break it down to several PRs by those commits. |
d9ddf94
to
19bffd2
Compare
Signed-off-by: Maxim Kovgan <makovgan@redhat.com>
- code - tests + data Signed-off-by: Maxim Kovgan <makovgan@redhat.com>
Signed-off-by: Maxim Kovgan <makovgan@redhat.com>
Signed-off-by: Maxim Kovgan <makovgan@redhat.com>
let's talk to the team and re evaluate this |
implements:
junuit2obj
converts a junit xml report to json report of similar structurereportsmerger
merges several json reports into 1 big report, updating aggregate metrics (counters, times)junit2json
the role to be used to convert and merge junit xml reports