Skip to content

Commit

Permalink
Add the possibility to create Podman components
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrishtop committed Jan 5, 2024
1 parent b2a4b70 commit 4cef1fe
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 13 deletions.
8 changes: 2 additions & 6 deletions roles/cnf_cert/tasks/pre-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,10 @@
ansible.builtin.set_fact:
tnf_commit_sha: "{{ tnf_commit_sha_cmd.stdout }}"

- name: Create cnf-certification-test component calling to include_components role
- name: Create DCI component for cnf-certification-test
ansible.builtin.include_role:
name: redhatci.ocp.include_components
vars:
gits_list:
- "{{ tnf_dir }}"
ic_gits: "{{ gits_list|flatten }}"
ic_rpms: []
ic_gits: "{{ [tnf_dir] }}"
ic_dev_gits: []

...
6 changes: 5 additions & 1 deletion roles/include_components/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@

- name: Track RPMs
ansible.builtin.include_tasks: track_rpm.yml
loop: "{{ ic_rpms }}"
loop: "{{ ic_rpms | default([]) }}"
when:
- item is not in
( (ic_gits + ic_dev_gits) |
map('regex_replace', '^(?:.*/(.+)|.*/([^/]+))$', '\\1') |
map('regex_replace', 'python', 'python3') | list)
- item in ansible_facts.packages

- name: Track podman components
ansible.builtin.include_tasks: track_podman_component.yml
loop: "{{ ic_podman | default([]) }}"
...
42 changes: 42 additions & 0 deletions roles/include_components/tasks/track_podman_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
- name: Assert repo_url and commit_id
assert:
that:
- item.0 is defined
- item.1 is defined
- item.0 | regex_match('^git@.*\.git$') # Assert that item.0 is a valid repo_url
- item.1 | regex_match('^[0-9a-f]{40}$') # Assert that item.1 is a valid commit_id

- name: Create podman component
vars:
ic_repo_url: "{{ item.0 }}"
ic_last_commit_id: "{{ item.1 }}"
ic_version: "{{ ic_last_commit_id[:7] }}"
ic_repo_name: "{{ ic_repo_url | basename | replace('.git', '') }}"
ic_repo_https: >-
{{
ic_repo_url |
regex_replace('^(.*)@(.*):(.*)', 'https://\\2/\\3') |
regex_replace('^ssh://(.*)@(.*)', 'https://\\2') |
replace('.git', '')
}}
ansible.legacy.dci_component:
display_name: "{{ ic_repo_name }} {{ ic_version }}"
version: "{{ ic_version }}"
uid: "{{ ic_last_commit_id }}"
team_id: "{{ job_info['job']['team_id'] }}"
topic_id: "{{ job_info['job']['topic_id'] }}"
type: "{{ ic_repo_name }}"
url: "{{ ic_repo_https }}/commit/{{ ic_last_commit_id }}"
state: present
register: ic_podman_component

- name: Attach podman component to the job
ansible.legacy.dci_job_component:
component_id: "{{ ic_podman_component.component.id }}"
job_id: " {{ job_id }} "
register: job_component_result
until: job_component_result is not failed
retries: 5
delay: 20
...
1 change: 1 addition & 0 deletions roles/preflight/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
preflight_image: "quay.io/opdev/preflight:1.8.0"
preflight_repo: "[email protected]:redhat-openshift-ecosystem/openshift-preflight.git"
preflight_namespace: preflight-testing
preflight_sa: default
preflight_custom_ca: ""
Expand Down
18 changes: 12 additions & 6 deletions roles/preflight/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,22 @@
# this variable is set in test-runner
when: preflight_source_dir is defined

- name: Create a component when building the preflight image from the source
- name: Extract commit_id from Preflight image
ansible.builtin.shell:
cmd: >
set -o pipefail;
podman run --rm {{ preflight_image }} --version |
grep -oE '[0-9a-f]+'
register: preflight_commit_id
changed_when: false

- name: Create a DCI component from Preflight image
ansible.builtin.include_role:
name: redhatci.ocp.include_components
vars:
gits_list:
- "{{ preflight_source_dir }}"
ic_gits: "{{ gits_list | flatten }}"
ic_rpms: []
ic_podman: [(preflight_repo, preflight_commit_id.stdout)]
ic_gits: []
ic_dev_gits: []
when: preflight_source_dir is defined

# Retrieve scorecard-test image in advance,
# to allow its mirroring in the disconnected cluster.
Expand Down

0 comments on commit 4cef1fe

Please sign in to comment.