Skip to content

Commit

Permalink
[WIP] Build rpm packages from zuul opendev depends-on
Browse files Browse the repository at this point in the history
Signed-off-by: Chandan Kumar <raukadah@gmail.com>
  • Loading branch information
raukadah committed Apr 8, 2024
1 parent fd4c2f8 commit 09e1dc3
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 14 deletions.
1 change: 0 additions & 1 deletion ci/playbooks/tcib/tcib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
cifmw_bop_dlrn_target: centos9-stream
cifmw_bop_initial_dlrn_config: centos9-local
cifmw_bop_dlrn_baseurl: https://trunk.rdoproject.org/centos9-antelope
cifmw_bop_openstack_project_path: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/tcib"
cifmw_bop_yum_repos_dir: "{{ cifmw_build_containers_repo_dir }}"
tags:
- container_img_build
Expand Down
7 changes: 7 additions & 0 deletions roles/build_openstack_packages/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,10 @@ cifmw_bop_dlrn_cleanup: false

cifmw_bop_timestamper_cmd: >-
| awk '{ print strftime("%Y-%m-%d %H:%M:%S |"), $0; fflush(); }'
cifmw_bop_branchless_projects:
- openstack-k8s-operators/tcib

cifmw_bop_skipped_projects:
- testproject
- openstack-k8s-operators/ci-framework
4 changes: 2 additions & 2 deletions roles/build_openstack_packages/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
- name: Install dlrn
ansible.builtin.import_tasks: install_dlrn.yml

- name: Run dlrn
ansible.builtin.import_tasks: run_dlrn.yml
- name: Parse Zuul changes and Build RPM packages
ansible.builtin.import_tasks: parse_and_build_pkgs.yml

- name: Create repo
ansible.builtin.import_tasks: create_repo.yml
Expand Down
62 changes: 62 additions & 0 deletions roles/build_openstack_packages/tasks/parse_and_build_pkgs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
- name: Parse Zuul changes
with_items: "{{ zuul['items'] }}"
when:
- zuul is defined
- "'change_url' in item"
- item.project.name not in cifmw_bop_change_list|default([]) | map(attribute='project') |list
- >-
(cifmw_bop_openstack_release is defined and cifmw_bop_openstack_release in item.branch) or
(cifmw_bop_openstack_release is not defined and item.branch == zuul.override_checkout | default(zuul.branch)) or
(cifmw_bop_osp_release is defined and cifmw_bop_osp_release in item.branch) or
item.project.name in cifmw_bop_branchless_projects
ansible.builtin.set_fact:
cacheable: true
cifmw_bop_change_list: >-
{{
cifmw_bop_change_list|default([]) +
[
{
'host': item.change_url | regex_search('(^https?://.*?)/', '\\1') | first,
'project': item.project.name,
'branch': item.branch,
'change': change.branch,
'refspec': '/'.join(
[
'refs',
'changes',
item.change[-2:],
item.change,
item.patchset
]
)
}
]
}}
- name: Print Zuul change list
ansible.builtin.debug:
var: cifmw_bop_change_list

- name: Build DLRN packages from zuul changes
when:
- cifmw_bop_openstack_project_path is not defined
- '"-distgit" not in item.project'
- item.project not in cifmw_bop_skipped_projects
- >-
cifmw_bop_openstack_release in item.branch or
(zuul.project.name | default("") == cifmw_bop_rdoinfo_repo_name) or
(cifmw_bop_osp_release is defined and cifmw_bop_osp_release in item.branch) or
item.project in cifmw_bop_branchless_projects
loop: "{{ criteria[cifmw_dlrn_promote_promotion_target] }}"
loop: "{{ cifmw_bop_change_list }}"
loop_control:
loop_var: "_project"
ansible.builtin.include_tasks: run_dlrn.yml

- name: Build DLRN packages from Local change
when: cifmw_bop_openstack_project_path is defined
vars:
_project:
branch: "{{ cifmw_bop_openstack_release }}"
ansible.builtin.include_tasks: run_dlrn.yml
46 changes: 35 additions & 11 deletions roles/build_openstack_packages/tasks/run_dlrn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
# License for the specific language governing permissions and limitations
# under the License.

- name: Set proper branch name
ansible.builtin.set_fact:
_project_branch: "{{ _project.branch | replace('stable/', '') }}"

- name: Set RDO release for master openstack release
when: cifmw_bop_openstack_release in ['master']
when: _project_release in ['master']
ansible.builtin.set_fact:
cifmw_bop_rdo_release: "rpm-{{ cifmw_bop_openstack_release }}"
cifmw_bop_rdo_release: "rpm-{{ _project_branch }}"

- name: Set RDO release for non-master openstack release
when: cifmw_bop_openstack_release not in ['master']
when: _project_release not in ['master']
ansible.builtin.set_fact:
cifmw_bop_rdo_release: "{{ cifmw_bop_openstack_release }}-rdo"
cifmw_bop_rdo_release: "{{ _project_branch }}-rdo"

- name: Make sure /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT exists (RHEL)
ansible.builtin.shell:
Expand All @@ -42,9 +46,9 @@
with_items:
- {regexp: 'baseurl=.*', line: 'baseurl={{ cifmw_bop_dlrn_baseurl }}'}
- {regexp: 'distro=.*', line: 'distro={{ cifmw_bop_rdo_release }}'}
- {regexp: 'source=.*', line: 'source={{ cifmw_bop_openstack_release }}'}
- {regexp: 'source=.*', line: 'source={{ _project_branch }}'}

- name: Mapp project
- name: Map project
block:
- name: Map project name to DLRN project name
register: project_name_mapped
Expand Down Expand Up @@ -76,10 +80,6 @@
- name: Mapping succeeded
when: project_name_mapped is success
block:
- name: Append project name to package list
ansible.builtin.set_fact:
artg_rdo_packages: "{{ project_name_mapped.stdout }}"

- name: Create data directory if doesn't exist yet
ansible.builtin.file:
path: "{{ cifmw_bop_build_repo_dir }}/DLRN/data/"
Expand All @@ -90,12 +90,36 @@
path: '{{ cifmw_bop_build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}/.git'
register: repo_status

- name: "Clone {{ project_name_mapped.stdout }}" # noqa: latest[git]
- name: "Sync {{ project_name_mapped.stdout }} from local repo" # noqa: latest[git]
when:
- cifmw_bop_openstack_project_path is defined
- not repo_status.stat.exists
ansible.builtin.git:
accept_hostkey: true
repo: '{{ cifmw_bop_openstack_project_path }}'
dest: '{{ cifmw_bop_build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}'

- name: "Clone {{ project_name_mapped.stdout }} from Github" # noqa: latest[git]
when:
- cifmw_bop_openstack_project_path is not defined
- not repo_status.stat.exists
- 'github.com' in _project.host
ansible.builtin.git:
repo: '{{ _project.host }}/{{ _project.project }}'
dest: '{{ cifmw_bop_build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}'
refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
version: 'origin/pr/{{ _project.change }}/head'

- name: "Clone Openstack {{ project_name_mapped.stdout }} " # noqa: latest[git]
when:
- cifmw_bop_openstack_project_path is not defined
- not repo_status.stat.exists
- not 'github.com' in _project.host
ansible.builtin.git:
repo: '{{ _project.host }}/{{ _project.project }}'
dest: '{{ cifmw_bop_build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}'
refspec: "{{ _project.refspec }}"

- name: Ensure distgit repo is absent, DLRN takes care of cloning based on config
ansible.builtin.file:
path: "{{ cifmw_bop_build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}_distro"
Expand Down

0 comments on commit 09e1dc3

Please sign in to comment.