Skip to content

Commit

Permalink
Drop wait.yml and put waiting code in each respective build type
Browse files Browse the repository at this point in the history
The logic for how to wait on a task to build across the different
build types supported has diverged to the point where a separate file
is more confusing than it is helpful in understanding the code logic.

Signed-off-by: Eric D. Helms <[email protected]>
  • Loading branch information
ehelms committed Oct 29, 2024
1 parent f8f2645 commit 5becf5a
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 68 deletions.
17 changes: 14 additions & 3 deletions obal/data/roles/build_package/tasks/copr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,20 @@
when:
- build_package_wait|bool
- copr_builds is changed
include_tasks: wait.yml
vars:
copr_build_ids: "{{ copr_builds['results'] | selectattr('builds', 'defined') | map(attribute='builds') | list | flatten }}"
block:
- name: "Watch copr build(s)"
command:
"copr-cli {{ '--config ' + build_package_copr_config if build_package_copr_config is defined else '' }} watch-build {{ copr_build_ids | join(' ') }}"
ignore_errors: true
register: build_package_copr_status
changed_when: false
vars:
copr_build_ids: "{{ copr_builds['results'] | selectattr('builds', 'defined') | map(attribute='builds') | list | flatten }}"

- name: 'Failed build'
fail:
msg: "The build in Copr has failed"
when: (build_package_copr_status is failed)

- when:
- build_package_archive_build_info
Expand Down
24 changes: 18 additions & 6 deletions obal/data/roles/build_package/tasks/koji_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,24 @@
var: koji_build_tasks.task_urls
when: koji_build_tasks.changed

- name: 'Wait for tasks to finish'
include_tasks: wait.yml
- name: Wait for task to finish
when: build_package_wait|bool and koji_build_tasks.changed
vars:
koji_tasks: "{{ koji_build_tasks.tasks }}"
block:
- name: "Watch {{ build_package_koji_command }} task(s)"
command: "{{ build_package_koji_command }} watch-task {{ koji_build_tasks.tasks | join(' ') }}"
ignore_errors: true
register: build_package_koji_status
changed_when: false

- name: 'Download task logs'
include_tasks: download_logs.yml
when: build_package_download_logs|bool

- name: 'Failed build'
fail:
msg: "The build in {{ build_package_koji_command }} has failed"
when: (build_package_koji_status is failed) and ('Build already exists' not in build_package_koji_status.stdout)

- name: 'Download task results'
include_tasks: download_rpms.yml
when: build_package_download_rpms|bool
include_tasks: download_rpms_from_task.yml
with_items: "{{ koji_build_tasks.tasks }}"
40 changes: 37 additions & 3 deletions obal/data/roles/build_package/tasks/tito_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,44 @@
var: build_package_tito_release.task_urls

- name: 'Wait for tasks to finish'
include_tasks: wait.yml
when: build_package_wait|bool
vars:
koji_tasks: "{{ build_package_tito_release.tasks }}"
block:
- name: Define koji_tasks
set_fact:
koji_tasks: "{{ build_package_tito_release.tasks }}"

- name: "Watch {{ build_package_koji_command }} task(s)"
command: "{{ build_package_koji_command }} watch-task {{ koji_tasks | join(' ') }}"
ignore_errors: true
register: build_package_koji_status
changed_when: false

- name: 'Download task logs'
include_tasks: download_logs.yml
when: build_package_download_logs|bool

- name: 'Failed build'
fail:
msg: "The build in {{ build_package_koji_command }} has failed"
when: (build_package_koji_status is failed) and ('Build already exists' not in build_package_koji_status.stdout)

- name: "Get {{ build_package_koji_command }} build detals"
command: "{{ build_package_koji_command }} taskinfo -v {{ item }}"
with_items: "{{ koji_tasks }}"
changed_when: false
register: build_package_koji_task_info

- name: "Filter {{ build_package_build_system }} output"
set_fact:
build_package_koji_task_data:
"{{ build_package_koji_task_info.results | map(attribute='stdout') | map('from_yaml') | list }}"

- name: 'Wait for builds to apear in the repo'
include_tasks: waitrepo.yml
when:
- build_package_waitrepo|bool
- not build_package_scratch
- build_package_koji_status is succeeded

- name: 'Download task results'
include_tasks: download_rpms.yml
Expand Down
49 changes: 0 additions & 49 deletions obal/data/roles/build_package/tasks/wait.yml

This file was deleted.

7 changes: 0 additions & 7 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@ def test_obal_scratch_with_koji_upstream_hello():
expected_log = [
"koji build obaltest-nightly-rhel7 /tmp/SRPMs/hello-2.10-2.src.rpm --scratch",
"koji watch-task 1234",
"koji taskinfo -v 1234",
"koji build obaltest-nightly-el8 /tmp/SRPMs/hello-2.10-2.src.rpm --scratch",
"koji watch-task 1234",
"koji taskinfo -v 1234",
]
assert_mockbin_log(expected_log)
assert os.path.exists('/tmp/SRPMs/hello-2.10-2.src.rpm')
Expand Down Expand Up @@ -201,13 +199,11 @@ def test_obal_release_with_koji_upstream_hello():
"koji latest-build --quiet obaltest-nightly-rhel7 hello",
"koji build obaltest-nightly-rhel7 /tmp/SRPMs/hello-2.10-2.src.rpm",
"koji watch-task 1234",
"koji taskinfo -v 1234",
"koji buildinfo hello-2.10-2.el8",
"koji latest-build --quiet obaltest-nightly-el8 hello",
"koji latest-build --quiet obaltest-nightly-el8 hello",
"koji build obaltest-nightly-el8 /tmp/SRPMs/hello-2.10-2.src.rpm",
"koji watch-task 1234",
"koji taskinfo -v 1234"
]
assert_mockbin_log(expected_log)

Expand All @@ -225,7 +221,6 @@ def test_obal_release_with_koji_upstream_existing_build():
"koji latest-build --quiet obaltest-nightly-el8 package-with-existing-build",
"koji build obaltest-nightly-el8 /tmp/SRPMs/package-with-existing-build-1.0-1.src.rpm",
"koji watch-task 1234",
"koji taskinfo -v 1234"
]
assert_mockbin_log(expected_log)

Expand All @@ -240,7 +235,6 @@ def test_obal_release_with_koji_upstream_two_target_tags():
"koji latest-build --quiet obaltest-nightly-el8 package-with-two-targets",
"koji build obaltest-nightly-el8 /tmp/SRPMs/package-with-two-targets-1.0-1.src.rpm",
"koji watch-task 1234",
"koji taskinfo -v 1234",
"koji buildinfo package-with-two-targets-1.0-1.el8",
"koji latest-build --quiet obalclient-nightly-el8 package-with-two-targets",
"koji tag-build obalclient-nightly-el8 package-with-two-targets-1.0-1.el8"
Expand All @@ -262,7 +256,6 @@ def test_obal_release_with_koji_upstream_whitelist_check():
"koji latest-build --quiet obaltest-nightly-el8 package-with-existing-build",
"koji build obaltest-nightly-el8 /tmp/SRPMs/package-with-existing-build-1.0-1.src.rpm",
"koji watch-task 1234",
"koji taskinfo -v 1234"
]
assert_mockbin_log(expected_log)

Expand Down

0 comments on commit 5becf5a

Please sign in to comment.