We're still before a new release of standard-test-roles, so keep updating this role here.
49 lines
1.3 KiB
YAML
49 lines
1.3 KiB
YAML
---
|
|
- name: Install testing requirements
|
|
package: name={{ item }} state=present
|
|
with_items:
|
|
- rsync
|
|
when: ansible_pkg_mgr != 'unknown'
|
|
|
|
- name: Copy test scripts to target
|
|
synchronize:
|
|
src: "{{ item }}"
|
|
dest: /var/tmp/tests/
|
|
ssh_args: "-o UserKnownHostsFile=/dev/null"
|
|
with_items:
|
|
- "{{ tests }}"
|
|
- "{{ files }}"
|
|
|
|
- block:
|
|
- name: Execute test scripts
|
|
shell: |
|
|
set -e
|
|
mkdir -p /var/tmp/artifacts
|
|
logfile=/var/tmp/artifacts/test.$(echo {{ item }} | sed -e 's/\//-/g').log
|
|
exec 2>>$logfile 1>>$logfile
|
|
cd /var/tmp/tests
|
|
if [ -x {{ item }} ]; then
|
|
./$(basename {{ item }}) && result="PASS" || result="FAIL"
|
|
else
|
|
/bin/sh -e ./$(basename {{ item }}) && result="PASS" || result="FAIL"
|
|
fi
|
|
echo "$result {{ item }}" >> /var/tmp/artifacts/test.log
|
|
with_items:
|
|
- "{{ tests }}"
|
|
|
|
always:
|
|
- name: Pull out the logs
|
|
synchronize:
|
|
dest: "{{ artifacts }}"
|
|
src: "/var/tmp/artifacts/./"
|
|
mode: pull
|
|
ssh_args: "-o UserKnownHostsFile=/dev/null"
|
|
when: artifacts|default("") != ""
|
|
|
|
# Can't go in block. See
|
|
# https://github.com/ansible/ansible/issues/20736
|
|
- name: Check the results
|
|
shell: grep "^FAIL" /var/tmp/artifacts/test.log
|
|
register: test_fails
|
|
failed_when: test_fails.stdout or test_fails.stderr
|