tripleo-ci/roles/build-containers/tasks/build-report.yaml

101 lines
3.1 KiB
YAML

---
- name: Container build report
block:
- name: Move container-builds dir to workspace/logs
shell: "mv {{ ansible_user_dir }}/container-* ./logs/"
become: true
args:
chdir: "{{ workspace }}"
failed_when: false
- name: Set ci_branch for building containers check jobs
include_tasks: set_ci_branch.yml
- name: Set branch
set_fact:
branch: "{{ osp_branch | default(ci_branch) }}"
- name: fetch tripleo_containers.yaml into ansible controller
fetch:
src: "{{ openstack_git_root }}/{% if zuul_internal is defined %}openstack-{% endif %}tripleo-common/container-images/tripleo_containers.yaml"
dest: "{{ zuul.executor.work_root }}/"
flat: true
- name: Load list of containers expected to build
include_vars:
file: "{{ zuul.executor.work_root }}/tripleo_containers.yaml"
- name: build list of expected images w/ prefix
set_fact:
expected_images: "{{ expected_images|default([]) + [item['imagename'].split(':')[0].split('/')[2]] }}"
when: item['image_source'] == "tripleo"
with_items: "{{ container_images }}"
- name: remove prefix from expected containers list
vars:
prefix: "{{ container_name_prefix }}-"
set_fact:
expected_containers: "{{ expected_containers|default([]) + [item | replace(prefix, '')] }}"
with_items: "{{ expected_images }}"
- name: Get list of excluded containers
shell: |
set -eux
echo {{ item }} >> {{ workspace }}/containers-excluded.log
with_items: "{{ exclude_containers[branch][container_exclude_distro] }}"
when: exclude_containers is defined and branch in exclude_containers
- name: Write containers-expected.log
lineinfile:
line: "{{ item }}"
path: "{{ workspace }}/containers-expected.log"
create: true
state: present
with_items: "{{ expected_containers }}"
- name: Get actual built containers
shell: |
set -eux
{{ container_cli | default('buildah') }} images | grep {{ container_name_prefix }} \
| tee {{ workspace }}/containers-built.log
become: true
- name: Copy build-report files
copy:
src: "files/{{ item }}"
dest: "{{ workspace }}"
with_items:
- build-report.py
- conftest.py
- name: construct images args
set_fact:
images_args: "{{ images_args | default('') + ' --image ' + item }}"
with_items: "{{ expected_containers }}"
- name: Install pytest
pip:
name: "{{ item }}"
virtualenv: "{{ workspace }}/venv_build"
virtualenv_command: '{{ ensure_pip_virtualenv_command }}'
with_items:
- pytest
- pytest-html
- name: install podman
become: true
package:
name: podman
state: present
- name: Execute build-report
shell: |
source "venv_build/bin/activate"
pytest --html=logs/report.html --self-contained-html {{ images_args }} build-report.py
args:
chdir: "{{ workspace }}"
become: true
ignore_errors: true