zuul-jobs/roles/process-test-results/tasks/main.yaml
Andrea Frittoli (andreaf) 7bd86fcd99 Add a generic process-test-results role
Takes an stestr or testr repo as input and generates a subunit
file and an html report out of it. The files are stored in the
staging area on the test node.

This in combination with a generic role to pull the staging
folder to the zuul executor is meant to eventually replace to
existing roles:
- fetch-testr-output
- fetch-stestr-output

Change-Id: Id6149d4e265ab9f0ab6d8faeffdec651c63dc056
2017-11-16 12:02:00 +00:00

50 lines
1.5 KiB
YAML

# NOTE(andreaf) There could be more than one repo in the test folder.
# Since that's unlikely we don't provide a variable to select the
# test runner and we pick the first hit.
- name: Discover stestr repo
stat:
path: "{{ test_results_dir }}/.stestr"
register: stestr_repo
- name: Discover testr repo
stat:
path: "{{ test_results_dir }}/.testrepository"
register: testr_repo
when: not stestr_repo.stat.exists
- name: Use stestr test runner
set_fact:
test_runner: ".tox/{{ tox_envdir }}/bin/stestr"
when: stestr_repo.stat.exists
- name: Use legacy testr test runner
set_fact:
test_runner: ".tox/{{ tox_envdir }}/bin/testr"
when: not stestr_repo.stat.exists and testr_repo.stat.exists
- name: Check if the venv has been created
stat:
path: "{{ test_results_dir }}/.tox/{{ tox_envdir }}"
register: run_venv
- name: Make sure test results are world readable
file:
path: "{{ test_results_dir }}"
mode: "a+rX"
recurse: true
become: true
- name: Create a subunit file from the last run
shell: "{{ test_runner }} last --subunit > {{ stage_dir }}/{{ test_results_stage_name }}.subunit"
args:
chdir: "{{ test_results_dir }}"
when: run_venv.stat.exists and test_runner is defined
register: subunit_report
- name: Generate the html report for the last run
command: "{{ subunit2html }} ./{{ test_results_stage_name}}.subunit {{ test_results_stage_name }}.html"
args:
chdir: "{{ stage_dir }}"
when: run_venv.stat.exists and test_runner is defined
register: html_report