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
46 changes: 46 additions & 0 deletions hooks/playbooks/tempest_store_timing_data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
- name: Store stestr timing data in 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://repo.example.org/project/timing-data"
tasks:
- name: All tasks required for storing timing data
# Note(kstrenko): This playbook introduces an additional feature
# and should not interfere with existing jobs.
ignore_errors: true # noqa: ignore-errors
block:
- 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: ../tasks/tempest_store_timing_data_each.yaml
Copy link
Contributor

@danpawlik danpawlik Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally I like it, nice work, but...
I don't see "tasks" in hooks. Maybe would be better to... create role and add it there then call the role? WDYT
NIT: you need to rebase to get roles symlink available in hooks/playbooks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @danpawlik, the only reason I added it under task folder is that playbook folder expects playbooks :D.
About your suggestion, I did the rebase and have the symlink, but I find it hard to imagine creating a role for one task 🤔

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/tasks/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