From e14afd0f8a1c3ca54a835aaa8604e5ccaa745c4e Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Mar 23 2022 06:47:22 +0000 Subject: Simplify run-tests-yml and fetch-tests-yml-artifacts roles Job that use these roles is conditionally run by the check-for-tests. So a tests directory is expected to be there. --- diff --git a/roles/fetch-tests-yml-artifacts/tasks/main.yml b/roles/fetch-tests-yml-artifacts/tasks/main.yml index fec6d12..cb9190b 100644 --- a/roles/fetch-tests-yml-artifacts/tasks/main.yml +++ b/roles/fetch-tests-yml-artifacts/tasks/main.yml @@ -1,14 +1,8 @@ -- name: Discover base directory of tests.yml - shell: mkdir -p tests && find . tests -maxdepth 1 -type f -name tests.yml | head -1 | xargs dirname - register: discover_tests_basedir - args: - chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" - - set_fact: - tests_dir: "{{ discover_tests_basedir.stdout }}" + tests_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests" - name: Fetch test artifacts synchronize: - src: '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/{{ tests_dir }}/artifacts' + src: '{{ tests_dir }}/artifacts' dest: '{{ zuul.executor.log_root }}/' mode: pull diff --git a/roles/run-tests-yml/tasks/main.yaml b/roles/run-tests-yml/tasks/main.yaml index 47aec91..c2826c1 100644 --- a/roles/run-tests-yml/tasks/main.yaml +++ b/roles/run-tests-yml/tasks/main.yaml @@ -12,39 +12,32 @@ use_backend: "dnf" become: yes -- name: Discover base directory of tests.yml - shell: mkdir -p tests && find . tests -maxdepth 1 -type f -name tests.yml | head -1 | xargs dirname - register: discover_tests_basedir - args: - chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" - - set_fact: - tests_dir: "{{ discover_tests_basedir.stdout }}" + tests_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests" - name: Ensure tests/artifacts exists file: - path: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/{{ tests_dir }}/artifacts" + path: "{{ tests_dir }}/artifacts" state: directory - name: Run the tests - shell: ansible-playbook {{ tests_dir }}/tests*.yml + shell: ansible-playbook tests*.yml args: - chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" + chdir: "{{ tests_dir }}" become: yes - name: Dump installed packages list become: yes shell: > - dnf list --installed > - {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/{{ tests_dir }}/artifacts/installed-packages.list + dnf list --installed > {{ tests_dir }}/artifacts/installed-packages.list - name: Check a STI results.yml file exists in the artifacts stat: - path: '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/{{ tests_dir }}/artifacts/results.yml' + path: '{{ tests_dir }}/artifacts/results.yml' register: sti_results_stat - name: Check for test failures in the STI results.yml file - shell: "grep -E '(result: fail)|(result: error)' {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/{{ tests_dir }}/artifacts/results.yml" + shell: "grep -E '(result: fail)|(result: error)' {{ tests_dir }}/artifacts/results.yml" register: grep_failure failed_when: grep_failure.rc == 0 when: sti_results_stat.stat.exists