Continue running workflow steps after step failures

Introduce new IR plugin option '--failfast' to abort
execution at the first failing workflow step

Change-Id: Ia79968cf7846f33fdaa05ac5bd511b614ae0784a
This commit is contained in:
Federico Ressi 2020-04-30 16:23:09 +02:00
parent 388426812d
commit 9501f7589a
7 changed files with 31 additions and 4 deletions

View File

@ -127,6 +127,10 @@ subparsers:
type: Value
help: name of workflow to execute
ansible_variable: test_workflow
failfast:
type: Flag
help: Stop the test run on the first step error or failure
ansible_variable: test_failfast
tox-dir:
type: Value
help: directory from where run tox (typically test_dir)

View File

@ -22,6 +22,7 @@ test_git_version: 'master'
test_src_dir: ''
test_user: '{{ ansible_user | default(omit) }}'
test_group: '{{ test_user }}'
test_mode: '{{ omit }}'
# NOTE: if test_dir and tobiko_dir variables endup being the same actual
@ -38,6 +39,7 @@ tobiko_git_version: 'master'
tobiko_src_dir: ''
tobiko_user: '{{ ansible_user | default(omit) }}'
tobiko_group: '{{ tobiko_user }}'
tobiko_mode: '{{ omit }}'
# --- Test configuration options ----------------------------------------------

View File

@ -8,6 +8,7 @@ test_deploy_dirs:
# test suite directory
- clean_dir: '{{ clean_deploy_dir }}'
dest_dir: '{{ test_dir }}'
dest_mode: '{{ test_mode }}'
dest_user: '{{ test_user }}'
dest_group: '{{ test_group }}'
git_repo: '{{ test_git_repo }}'
@ -19,6 +20,7 @@ test_deploy_dirs:
# Tobiko framework directory
- clean_dir: '{{ clean_deploy_dir }}'
dest_dir: '{{ tobiko_dir }}'
dest_mode: '{{ tobiko_mode }}'
dest_user: '{{ tobiko_user }}'
dest_group: '{{ tobiko_group }}'
git_repo: '{{ tobiko_git_repo }}'

View File

@ -22,7 +22,7 @@
state: directory
owner: '{{ dest_user | default(omit) }}'
group: '{{ dest_group | default(omit) }}'
mode: '0755'
mode: '{{ dest_mode | default(omit) }}'
recurse: yes
become: '{{ test_become | bool }}'
register: create_dest_dir

View File

@ -1,5 +1,7 @@
---
test_failfast: false
test_workflow: default
tox_step_name:
tox_step_index: 0
test_step_failures: []

View File

@ -14,3 +14,9 @@
loop_control:
label: '{{ test_step.tox_description }}'
loop_var: test_step
- name: "report test step failures"
debug: var=test_step_failures
when: '(test_step_failures | length) > 0'
failed_when: yes

View File

@ -15,6 +15,17 @@
- (test_workflow_steps | length) > 1
- name: '{{ test_step.tox_description }}'
include_role:
name: tobiko-tox
- block:
- name: '{{ test_step.tox_description }}'
include_role:
name: tobiko-tox
rescue:
- name: "add step failure: '{{ tox_step_name }}'"
set_fact:
test_step_failures: '{{ test_step_failures + [test_step] }}'
- name: "abort execution at first failure"
debug: var=test_step
when: test_failfast
failed_when: yes