Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions hooks/playbooks/tempest_store_timing_data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
- name: Store stestr timing data in internal repository
hosts: localhost
gather_facts: false
vars:
repo_path: "/tmp/timing-data"
tests_log_dir: "{{ ansible_user_dir }}/ci-framework-data/tests/test_operator"
timing_data_repo: "https://user:{{ git_token }}@gitlab.cee.redhat.com/ci-framework/timing-data"
tasks:
- name: Clone timing data repository
ansible.builtin.git:
repo: "{{ timing_data_repo }}"
dest: "{{ repo_path }}"
version: "main"

- name: Configure git settings
community.general.git_config:
repo: "{{ repo_path }}"
scope: local
name: "{{ item.name }}"
value: "{{ item.value }}"
loop:
- {name: 'user.name', value: 'Zuul'}
- {name: 'user.email', value: '[email protected]'}
- {name: 'remote.origin.url', value: '{{ timing_data_repo }}'}

- name: Find all 'tempest' directories
ansible.builtin.find:
paths: "{{ tests_log_dir }}"
file_type: directory
patterns: "*-tempest*"
register: tempest_dirs

- name: Store timing data for every tempest-test directory
ansible.builtin.include_tasks: tempest_store_timing_data_each.yaml
vars:
stestr_tar_path: "{{ tests_log_dir }}/{{ tempest_tests_name.path | basename }}/stestr.tar.gz"
timing_data_repo_dir: "{{ repo_path }}/{{ job_name }}/{{ tempest_tests_name.path | basename }}"
loop: "{{ tempest_dirs.files }}"
loop_control:
loop_var: tempest_tests_name
42 changes: 42 additions & 0 deletions hooks/playbooks/tempest_store_timing_data_each.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
#
# Included by tempest_store_timing_data.yaml playbook
#
# There are two variables passed by the loop
# - stestr_tar_path - a path to the data which will be copied
# - timing_data_repo_dir - a path to a directory to be created
#
- name: Ensure the defined directory exists
ansible.builtin.file:
path: "{{ timing_data_repo_dir }}"
state: directory
mode: '0755'

- name: Copy timing data to commit
ansible.builtin.copy:
src: "{{ stestr_tar_path }}"
dest: "{{ timing_data_repo_dir }}"
mode: '0644'

- name: Add all changes
ansible.builtin.command:
cmd: git add .
chdir: "{{ repo_path }}"
changed_when: false
# noqa command-instead-of-module

- name: Commit changes
ansible.builtin.command:
cmd: git commit -m "Automatic update"
chdir: "{{ repo_path }}"
register: commit_result
changed_when: commit_result.rc == 0
# noqa command-instead-of-module

- name: Push changes to the repository
ansible.builtin.command:
cmd: git push origin main
chdir: "{{ repo_path }}"
when: commit_result.rc == 0
changed_when: false
# noqa command-instead-of-module
Loading