From 088bae16d0fdeccc3ba178a595f296c03be8fdec Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Fri, 7 Apr 2023 16:36:31 -0400 Subject: [PATCH] Refactor Copr support into modules --- obal/data/modules/check_copr_build.py | 52 +++++++++ obal/data/modules/copr_build.py | 59 ++++++++++ obal/data/modules/copr_chroot.py | 17 ++- obal/data/modules/copr_fork.py | 57 ++++++++++ obal/data/modules/copr_project.py | 4 + .../data/playbooks/release/metadata.obal.yaml | 16 +++ .../roles/build_package/defaults/main.yaml | 2 + obal/data/roles/build_package/tasks/copr.yml | 56 +--------- .../roles/build_package/tasks/copr_build.yml | 102 ++++++++++++++++++ obal/data/roles/build_package/tasks/wait.yml | 6 +- .../roles/copr_project/defaults/main.yaml | 1 + obal/data/roles/copr_repo/tasks/main.yml | 35 +++--- tests/fixtures/help/release.txt | 11 +- tests/fixtures/mockbin/mockbin | 53 ++++++++- .../testrepo/copr/package_manifest.yaml | 19 +--- tests/test_functional.py | 40 +++---- 16 files changed, 411 insertions(+), 119 deletions(-) create mode 100644 obal/data/modules/check_copr_build.py create mode 100644 obal/data/modules/copr_build.py create mode 100644 obal/data/modules/copr_fork.py create mode 100644 obal/data/roles/build_package/tasks/copr_build.yml diff --git a/obal/data/modules/check_copr_build.py b/obal/data/modules/check_copr_build.py new file mode 100644 index 00000000..9c50f856 --- /dev/null +++ b/obal/data/modules/check_copr_build.py @@ -0,0 +1,52 @@ +""" +Check if a build already exists in Copr +""" + +import json +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.copr import copr_cli, CoprCliCommandError, full_name # pylint:disable=import-error,no-name-in-module + + +def main(): + """ + Check if a build already exists in Copr + """ + module = AnsibleModule( + argument_spec=dict( + user=dict(type='str', required=True), + project=dict(type='str', required=True), + nvr=dict(type='str', required=True), + package=dict(type='str', required=True), + ) + ) + + user = module.params['user'] + project = module.params['project'] + nvr = module.params['nvr'] + package = module.params['package'] + + command = [ + 'get-package', + full_name(user, project), + '--name', + package, + '--with-all-builds' + ] + + try: + package_info = json.loads(copr_cli(command)) + except CoprCliCommandError as error: + if "Error: No package with name {} in copr {}".format(package, project): + module.exit_json(changed=True, exists=False) + else: + module.fail_json(msg='Retrieval of package from Copr failed', command=command, output=error.message, + repo_name=full_name(user, project), package=package) + + builds = (build for build in package_info['builds'] if build['state'] == 'succeeded') + exists = any("{}-{}".format(package, build['source_package']['version']) == nvr for build in builds) + + module.exit_json(changed=not exists, exists=exists) + + +if __name__ == '__main__': + main() diff --git a/obal/data/modules/copr_build.py b/obal/data/modules/copr_build.py new file mode 100644 index 00000000..d93ddfb9 --- /dev/null +++ b/obal/data/modules/copr_build.py @@ -0,0 +1,59 @@ +""" +Release a package to Copr +""" + +import re + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.copr import copr_cli, CoprCliCommandError, full_name # pylint:disable=import-error,no-name-in-module + + +def main(): + """ + Release a package to Copr + """ + module = AnsibleModule( + argument_spec=dict( + user=dict(type='str', required=True), + project=dict(type='str', required=True), + srpm=dict(type='path', required=True), + wait=dict(type='bool', required=False, default=False), + chroots=dict(type='list', required=False), + ) + ) + + user = module.params['user'] + project = module.params['project'] + srpm = module.params['srpm'] + wait = module.params['wait'] + chroots = module.params['chroots'] + + command = [ + 'build', + full_name(user, project), + srpm + ] + + if not wait: + command.append('--nowait') + + if chroots: + for chroot in chroots: + command.extend(['--chroot', chroot]) + + try: + output = copr_cli(command) + except CoprCliCommandError as error: + module.fail_json(msg='Copr build failed', command=error.command, output=error.message, + repo_name=full_name(user, project), srpm=srpm) + + build_urls = re.findall(r'^Build was added to.+:\n^\s(.+)', output, re.MULTILINE) + build_urls = [url.strip() for url in build_urls] + + builds = re.findall(r'^Created builds:\s(\d+)', output, re.MULTILINE) + + module.exit_json(changed=True, output=output, builds=builds, build_urls=build_urls) + + +if __name__ == '__main__': + main() diff --git a/obal/data/modules/copr_chroot.py b/obal/data/modules/copr_chroot.py index 1e0f2ba1..adfa504f 100644 --- a/obal/data/modules/copr_chroot.py +++ b/obal/data/modules/copr_chroot.py @@ -15,9 +15,9 @@ def main(): user=dict(type='str', required=True), project=dict(type='str', required=True), chroot=dict(type='str', required=True), - external_repos=dict(type='list', required=False), - buildroot_packages=dict(type='list', required=False), - modules=dict(type='list', required=False), + external_repos=dict(type='list', required=False, default=[]), + buildroot_packages=dict(type='list', required=False, default=[]), + modules=dict(type='list', required=False, default=[]), ) ) @@ -33,14 +33,9 @@ def main(): "{}/{}".format(full_name(user, project), chroot) ] - if external_repos: - command.extend(['--repos', ' '.join(external_repos)]) - - if buildroot_packages: - command.extend(['--packages', ' '.join(buildroot_packages)]) - - if modules: - command.extend(['--modules', ','.join(modules)]) + command.extend(['--repos', ' '.join(external_repos)]) + command.extend(['--packages', ' '.join(buildroot_packages)]) + command.extend(['--modules', ','.join(modules)]) try: output = copr_cli(command) diff --git a/obal/data/modules/copr_fork.py b/obal/data/modules/copr_fork.py new file mode 100644 index 00000000..28dea95a --- /dev/null +++ b/obal/data/modules/copr_fork.py @@ -0,0 +1,57 @@ +""" +Fork a Copr project +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.copr import copr_cli, CoprCliCommandError, full_name # pylint:disable=import-error,no-name-in-module + + +def main(): + """ + Fork a Copr project + """ + module = AnsibleModule( + argument_spec=dict( + src_user=dict(type='str', required=True), + src_project=dict(type='str', required=True), + dest_user=dict(type='str', required=True), + dest_project=dict(type='str', required=True), + delete_after_days=dict(type='str', required=False, default=None), + ) + ) + + src_user = module.params['src_user'] + src_project = module.params['src_project'] + dest_user = module.params['dest_user'] + dest_project = module.params['dest_project'] + delete_after_days = module.params['delete_after_days'] + + command = [ + 'fork', + full_name(src_user, src_project), + full_name(dest_user, dest_project) + ] + + try: + fork_output = copr_cli(command) + except CoprCliCommandError as error: + module.fail_json(msg='Copr project forking failed', command=' '.join(error.command), output=error.message) + + if delete_after_days: + modify_command = [ + 'modify', + full_name(dest_user, dest_project), + '--delete-after-days', + delete_after_days + ] + + try: + copr_cli(modify_command) + except CoprCliCommandError as error: + module.fail_json(msg='Copr project forking failed', command=' '.join(error.command), output=error.message) + + module.exit_json(changed=True, output=fork_output) + + +if __name__ == '__main__': + main() diff --git a/obal/data/modules/copr_project.py b/obal/data/modules/copr_project.py index 65d54626..791f9808 100644 --- a/obal/data/modules/copr_project.py +++ b/obal/data/modules/copr_project.py @@ -35,6 +35,7 @@ def main(): description=dict(type='str', required=False), unlisted_on_homepage=dict(type='bool', required=False, default=False), delete_after_days=dict(type='str', required=False), + appstream=dict(type='str', required=False, default='off'), ) ) @@ -44,6 +45,7 @@ def main(): description = module.params['description'] unlisted_on_homepage = module.params['unlisted_on_homepage'] delete_after_days = module.params['delete_after_days'] + appstream = module.params['appstream'] if not description: description = project @@ -59,6 +61,8 @@ def main(): description ]) + command.extend(['--appstream', appstream]) + for chroot in chroots: command.extend(['--chroot', chroot]) diff --git a/obal/data/playbooks/release/metadata.obal.yaml b/obal/data/playbooks/release/metadata.obal.yaml index 43ba70e5..cc562723 100644 --- a/obal/data/playbooks/release/metadata.obal.yaml +++ b/obal/data/playbooks/release/metadata.obal.yaml @@ -8,3 +8,19 @@ variables: action: store_false parameter: --skip-koji-whitelist-check help: ignore koji whitelist check and release the package anyway + build_package_copr_chroots: + action: append + parameter: --copr-chroot + help: Specify a Copr chroot to release for, can be specified multiple times + build_package_copr_rebuild: + action: store_true + parameter: --copr-rebuild + help: Forces a rebuild of a package in Copr + build_package_skip_failed_build: + action: store_true + parameter: --skip-failed-build + help: Skips failing builds and continues execution + build_package_wait: + action: store_false + parameter: --nowait + help: Do not wait on builds to complete diff --git a/obal/data/roles/build_package/defaults/main.yaml b/obal/data/roles/build_package/defaults/main.yaml index 9750aed4..62ac9ba4 100644 --- a/obal/data/roles/build_package/defaults/main.yaml +++ b/obal/data/roles/build_package/defaults/main.yaml @@ -12,3 +12,5 @@ build_package_waitrepo: false build_package_koji_whitelist_check: false build_package_tito_builder: build_package_use_koji_build: false +build_package_copr_rebuild: false +build_package_skip_failed_build: false diff --git a/obal/data/roles/build_package/tasks/copr.yml b/obal/data/roles/build_package/tasks/copr.yml index 41487cc1..289fed74 100644 --- a/obal/data/roles/build_package/tasks/copr.yml +++ b/obal/data/roles/build_package/tasks/copr.yml @@ -1,53 +1,5 @@ --- -- when: not build_package_scratch - block: - - name: 'Release to copr' - tito_release: - directory: "{{ inventory_dir }}/{{ package_base_dir }}/{{ inventory_hostname }}" - arguments: "{{ build_package_tito_args }}" - test: "{{ build_package_test }}" - scratch: "{{ build_package_scratch }}" - releasers: "{{ releasers }}" - releaser_arguments: "{{ build_package_tito_releaser_args }}" - register: build_package_tito_release - - - name: 'Wait for tasks to finish' - include_tasks: wait.yml - when: build_package_wait|bool - -- when: build_package_scratch - block: - - name: Define copr repo name - set_fact: - copr_repo_name: "{{ copr_user }}/{{ build_package_scratch_repo }}-{{ 999999999 | random | to_uuid }}" - run_once: true - when: copr_repo_name is not defined - - - name: 'Write copr repo name to vars file' - copy: - content: "{{ 'copr_repo: ' + copr_repo_name | to_yaml }}" - dest: "{{ obal_tmp_dir }}/copr_repo" - mode: '0640' - run_once: true - - - include_role: - name: copr_repo - run_once: true - - - name: 'Build SRPM' - tito_build: - directory: "{{ inventory_dir }}/{{ package_base_dir }}/{{ inventory_hostname }}" - srpm: true - scl: "{{ scl }}" - register: srpm_build - - - name: 'Run build' - command: >- - copr-cli build - {% if not build_package_wait | bool %}--nowait{% endif %} - {{ copr_repo_name }} - {{ srpm_build.path }} - register: build_status - - - debug: - msg: "{{ build_status.stdout_lines | join('\n') }}" +- include_tasks: copr_build.yml + loop: "{{ copr_projects }}" + loop_control: + loop_var: copr_project diff --git a/obal/data/roles/build_package/tasks/copr_build.yml b/obal/data/roles/build_package/tasks/copr_build.yml new file mode 100644 index 00000000..a2cdc467 --- /dev/null +++ b/obal/data/roles/build_package/tasks/copr_build.yml @@ -0,0 +1,102 @@ +--- +- when: + - not build_package_scratch + - not build_package_copr_rebuild + block: + - name: "Package name" + rpm_nvr: + spec_file: "{{ spec_file_path }}" + scl: "{{ tag.scl | default(omit) }}" + dist: "{{ tag.dist | default(omit) }}" + macros: "{{ tag.macros | default(omit) }}" + register: package_nvr + + - name: Check build status + check_copr_build: + user: "{{ copr_project_user }}" + project: "{{ copr_project['copr_project_name'] }}" + nvr: "{{ package_nvr.nvr }}" + package: "{{ package_nvr.name }}" + register: build_exists + +- debug: + msg: "{{ build_exists.skipped is defined }}" + +- name: Create temporary build directory + tempfile: + state: directory + suffix: srpms + register: srpm_directory + when: (srpm_directory is not defined and (build_exists.exists is defined and not build_exists.exists)) or build_package_copr_rebuild + +- name: 'Build SRPM' + srpm: + package: "{{ inventory_dir }}/{{ package_base_dir }}/{{ inventory_hostname }}" + output: "{{ srpm_directory.path if 'path' in srpm_directory else srpm_directory }}" + source_location: "{{ source_location | default(omit) }}" + source_system: "{{ source_system | default(omit) }}" + register: srpm_build + when: (srpm_directory is defined and (build_exists.exists is defined and not build_exists.exists)) or build_package_copr_rebuild or build_package_scratch + +- when: (not build_package_scratch and (build_exists.exists is defined and not build_exists.exists)) or build_package_copr_rebuild + block: + - name: 'Run build' + copr_build: + user: "{{ copr_project_user }}" + project: "{{ copr_project['copr_project_name'] }}" + srpm: "{{ srpm_build.path }}" + chroots: "{{ build_package_copr_chroots | default(omit) }}" + register: copr_builds + ignore_errors: "{{ build_package_skip_failed_build | default(false) }}" + + - name: 'Created tasks' + debug: + var: copr_builds.build_urls + when: copr_builds.changed + + - name: 'Wait for tasks to finish' + include_tasks: wait.yml + when: build_package_wait|bool and copr_builds.changed + vars: + copr_build_ids: "{{ copr_builds.builds }}" + +- when: build_package_scratch + block: + - name: Define Copr scratch project name + set_fact: + copr_scratch_project: "{{ copr_project['copr_project_name'] }}-scratch-{{ 999999999 | random | to_uuid }}" + when: copr_scratch_project is not defined + + - name: Define Copr scatch user name + set_fact: + copr_scratch_user: "{{ copr_project_user }}" + when: copr_scratch_user is not defined + + - include_role: + name: copr_project + vars: + copr_project_user: "{{ copr_scratch_user }}" + copr_project_name: "{{ copr_scratch_project }}" + copr_project_chroots: "{{ copr_project['copr_project_chroots'] }}" + copr_project_description: "{{ copr_project['copr_project_description'] | default(omit) }}" + copr_project_delete_after_days: "4" + copr_project_unlisted_on_homepage: "{{ copr_project['copr_project_unlisted_on_homepage'] | default(omit) }}" + + - name: 'Run build' + copr_build: + user: "{{ copr_scratch_user }}" + project: "{{ copr_scratch_project }}" + srpm: "{{ srpm_build.path }}" + chroots: "{{ build_package_copr_chroots | default(omit) }}" + register: copr_builds + + - name: 'Created tasks' + debug: + var: copr_builds.build_urls + when: copr_builds.changed + + - name: 'Wait for tasks to finish' + include_tasks: wait.yml + when: build_package_wait|bool and copr_builds.changed + vars: + copr_build_ids: "{{ copr_builds.builds }}" diff --git a/obal/data/roles/build_package/tasks/wait.yml b/obal/data/roles/build_package/tasks/wait.yml index a0dad277..bf5860a4 100644 --- a/obal/data/roles/build_package/tasks/wait.yml +++ b/obal/data/roles/build_package/tasks/wait.yml @@ -36,13 +36,13 @@ - when: build_package_build_system == 'copr' block: - - name: "Watch copr task(s)" - command: "copr-cli watch-build {{ build_package_tito_release.builds | join(' ') }}" + - name: "Watch copr build(s)" + command: "copr-cli watch-build {{ copr_build_ids | join(' ') }}" ignore_errors: true register: build_package_copr_status changed_when: false - name: 'Failed build' fail: - msg: "The build in Copr has failed" + msg: "The build in Copr has failed" when: (build_package_copr_status is failed) diff --git a/obal/data/roles/copr_project/defaults/main.yaml b/obal/data/roles/copr_project/defaults/main.yaml index ed97d539..0184c98b 100644 --- a/obal/data/roles/copr_project/defaults/main.yaml +++ b/obal/data/roles/copr_project/defaults/main.yaml @@ -1 +1,2 @@ --- +copr_project_chroots: [] diff --git a/obal/data/roles/copr_repo/tasks/main.yml b/obal/data/roles/copr_repo/tasks/main.yml index d52bab75..8b129f55 100644 --- a/obal/data/roles/copr_repo/tasks/main.yml +++ b/obal/data/roles/copr_repo/tasks/main.yml @@ -1,19 +1,20 @@ --- -- name: 'Create copr scratch build repo' - command: > - copr-cli - create - {{ copr_repo_name }} - --chroot {{ copr_repo_chroot }} - --description '{{ copr_repo_description }}' - --unlisted-on-hp on - --repo '{{ copr_repo_external_repos | join(' ') }}' - changed_when: false +- name: 'Create Copr repo' + copr_repo: + repo_name: "{{ copr_repo_name }}" + chroots: "{{ copr_repo_chroots | map(attribute='name') }}" + description: "{{ copr_repo_description | default(omit) }}" + delete_after_days: "{{ copr_repo_delete_after_days | default(omit) }}" + unlisted_on_homepage: "{{ copr_repo_unlisted_on_homepage | default(omit) }}" + register: create_output -- name: 'Add build packages to chroot' - command: > - copr-cli - edit-chroot - {{ copr_repo_name }}/{{ copr_repo_chroot }} - --packages '{{ copr_repo_packages | join(' ') }}' - changed_when: false +- name: Configure chroots + copr_chroot: + repo_name: "{{ copr_repo_name }}" + chroot: "{{ chroot.name }}" + external_repos: "{{ chroot.external_repos | default(omit) }}" + buildroot_packages: "{{ chroot.buildroot_packages | default(omit) }}" + modules: "{{ chroot.modules | default(omit) }}" + loop: "{{ copr_repo_chroots }}" + loop_control: + loop_var: chroot diff --git a/tests/fixtures/help/release.txt b/tests/fixtures/help/release.txt index 138cce6a..eadb0ecd 100644 --- a/tests/fixtures/help/release.txt +++ b/tests/fixtures/help/release.txt @@ -1,4 +1,7 @@ -usage: obal release [-h] [-v] [-e EXTRA_VARS] [--skip-koji-whitelist-check] +usage: obal release [-h] [-v] [-e EXTRA_VARS] + [--copr-chroot BUILD_PACKAGE_COPR_CHROOTS] + [--copr-rebuild] [--skip-koji-whitelist-check] + [--skip-failed-build] [--nowait] target [target ...] This action releases a package to Koji/Brew/Copr @@ -11,9 +14,15 @@ positional arguments: optional arguments: -h, --help show this help message and exit -v, --verbose verbose output + --copr-chroot BUILD_PACKAGE_COPR_CHROOTS + Specify a Copr chroot to release for, can be specified + multiple times + --copr-rebuild Forces a rebuild of a package in Copr --skip-koji-whitelist-check ignore koji whitelist check and release the package anyway + --skip-failed-build Skips failing builds and continues execution + --nowait Do not wait on builds to complete advanced arguments: -e EXTRA_VARS, --extra-vars EXTRA_VARS diff --git a/tests/fixtures/mockbin/mockbin b/tests/fixtures/mockbin/mockbin index 95407c9e..420d4e1b 100755 --- a/tests/fixtures/mockbin/mockbin +++ b/tests/fixtures/mockbin/mockbin @@ -5,6 +5,7 @@ from __future__ import print_function import os import sys import argparse +import json try: from shlex import quote except ImportError: @@ -152,4 +153,54 @@ elif prog in ['koji', 'brew']: print('BUILD: {}\nState: COMPLETE'.format(args.pkg)) elif prog in ['copr-cli']: - print({}) + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest='subcommand') + + parser_build = subparsers.add_parser('get-package') + parser_build.add_argument('project') + parser_build.add_argument('--name') + parser_build.add_argument('--with-all-builds', action='store_true') + + parser_build = subparsers.add_parser('build') + parser_build.add_argument('project') + parser_build.add_argument('pkg') + parser_build.add_argument('--nowait', action='store_true') + + parser_build = subparsers.add_parser('list') + parser_build.add_argument('project') + + parser_build = subparsers.add_parser('fork') + parser_build.add_argument('src') + parser_build.add_argument('dest') + + parser_build = subparsers.add_parser('create') + parser_build.add_argument('project') + parser_build.add_argument('--description') + parser_build.add_argument('--chroot') + parser_build.add_argument('--appstream') + parser_build.add_argument('--delete-after-days') + + parser_build = subparsers.add_parser('modify') + parser_build.add_argument('project') + parser_build.add_argument('--delete-after-days') + + parser_build = subparsers.add_parser('edit-chroot') + parser_build.add_argument('project-chroot') + parser_build.add_argument('--repos') + parser_build.add_argument('--packages') + parser_build.add_argument('--modules') + + parser_build = subparsers.add_parser('watch-build') + parser_build.add_argument('build') + + args = parser.parse_args() + + if args.subcommand == 'get-package': + json_data = json.loads('{"builds": [{"state": "succeeded", "source_package": {"version": "0.0.1"}}]}') + print(json.dumps(json_data, indent=2)) + elif args.subcommand == 'build': + print("Build was added to foreman-1234:") + print("https://copr.fedorainfracloud.org/coprs/build/5678") + print("Created builds: 5678") + else: + print({}) diff --git a/tests/fixtures/testrepo/copr/package_manifest.yaml b/tests/fixtures/testrepo/copr/package_manifest.yaml index 6773ae5f..4a59db04 100644 --- a/tests/fixtures/testrepo/copr/package_manifest.yaml +++ b/tests/fixtures/testrepo/copr/package_manifest.yaml @@ -1,21 +1,12 @@ --- packages: vars: - releasers: - - copr - scl: copr-scl - copr_user: "@fake-user" - copr_repo_name: copr-repo-scratch - diff_package_copr_repo: copr-repo-staging - diff_package_type: copr + copr_project_user: example + copr_project_name: foreman + copr_scratch_project: foreman-1234 build_package_build_system: copr - build_package_scratch_repo: copr-repo-scratch - copr_repo_chroot: epel-7-x86_64 - copr_repo_external_repos: - - http://mirror.centos.org/centos/7/sclo/x86_64/rh/ - copr_repo_packages: - - scl-utils-build - - rh-ruby24-build + copr_projects: + - "{{ hostvars['foreman'] }}" hosts: hello: {} diff --git a/tests/test_functional.py b/tests/test_functional.py index a339cad4..d429187c 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -662,10 +662,10 @@ def test_obal_scratch_copr_hello_nowait(): assert os.path.exists('packages/hello/hello-2.10.tar.gz') expected_log = [ - "copr-cli create copr-repo-scratch --chroot epel-7-x86_64 --description 'Scratch Builds' --unlisted-on-hp on --repo http://mirror.centos.org/centos/7/sclo/x86_64/rh/", # noqa: E501 - "copr-cli edit-chroot copr-repo-scratch/epel-7-x86_64 --packages 'scl-utils-build rh-ruby24-build'", # noqa: E501 - "tito build --srpm --scl copr-scl", - "copr-cli build --nowait copr-repo-scratch hello-2.10-1.src.rpm" + "copr-cli list example", + "copr-cli create example/foreman-1234 --description foreman-1234 --appstream off --chroot epel-7-x86_64 --delete-after-days 4", # noqa: E501 + "copr-cli edit-chroot example/foreman-1234/epel-7-x86_64 --repos http://mirror.centos.org/centos/7/sclo/x86_64/rh/ --packages 'rh-ruby24-build scl-utils-build' --modules ''", # noqa: E501 + "copr-cli build example/foreman-1234 /tmp/SRPMs/hello-2.10-1.src.rpm --nowait" ] assert_mockbin_log(expected_log) @@ -677,11 +677,11 @@ def test_obal_scratch_copr_hello(): assert os.path.exists('packages/hello/hello-2.10.tar.gz') expected_log = [ - "copr-cli create copr-repo-scratch --chroot epel-7-x86_64 --description 'Scratch Builds' --unlisted-on-hp on --repo http://mirror.centos.org/centos/7/sclo/x86_64/rh/", # noqa: E501 - "copr-cli edit-chroot copr-repo-scratch/epel-7-x86_64 --packages 'scl-utils-build rh-ruby24-build'", # noqa: E501 - "tito build --srpm --scl copr-scl", - "copr-cli build copr-repo-scratch hello-2.10-1.src.rpm", - # copr-cli build waits by default, so there is no "watch-build" step here + "copr-cli list example", + "copr-cli create example/foreman-1234 --description foreman-1234 --appstream off --chroot epel-7-x86_64 --delete-after-days 4", # noqa: E501 + "copr-cli edit-chroot example/foreman-1234/epel-7-x86_64 --repos http://mirror.centos.org/centos/7/sclo/x86_64/rh/ --packages 'rh-ruby24-build scl-utils-build' --modules ''", # noqa: E501 + "copr-cli build example/foreman-1234 /tmp/SRPMs/hello-2.10-1.src.rpm --nowait", + "copr-cli watch-build 5678" ] assert_mockbin_log(expected_log) @@ -693,8 +693,8 @@ def test_obal_release_copr_hello_nowait(): assert os.path.exists('packages/hello/hello-2.10.tar.gz') expected_log = [ - "copr-cli get-package @fake-user/copr-repo-staging --name hello --with-latest-build", - "tito release --yes copr", + "copr-cli get-package example/foreman --name hello --with-all-builds", + "copr-cli build example/foreman /tmp/SRPMs/hello-2.10-1.src.rpm --nowait" ] assert_mockbin_log(expected_log) @@ -706,9 +706,9 @@ def test_obal_release_copr_hello(): assert os.path.exists('packages/hello/hello-2.10.tar.gz') expected_log = [ - "copr-cli get-package @fake-user/copr-repo-staging --name hello --with-latest-build", - "tito release --yes copr", - "copr-cli watch-build" + "copr-cli get-package example/foreman --name hello --with-all-builds", + "copr-cli build example/foreman /tmp/SRPMs/hello-2.10-1.src.rpm --nowait", + "copr-cli watch-build 5678" ] assert_mockbin_log(expected_log) @@ -808,8 +808,8 @@ def test_copr_project_one_chroot(): expected_log = [ "copr-cli list example", - "copr-cli create example/foreman --description foreman --chroot epel-7-x86_64", # noqa: E501 - "copr-cli edit-chroot example/foreman/epel-7-x86_64 --repos http://mirror.centos.org/centos/7/sclo/x86_64/rh/ --packages 'rh-ruby24-build scl-utils-build'", # noqa: E501 + "copr-cli create example/foreman --description foreman --appstream off --chroot epel-7-x86_64", # noqa: E501 + "copr-cli edit-chroot example/foreman/epel-7-x86_64 --repos http://mirror.centos.org/centos/7/sclo/x86_64/rh/ --packages 'rh-ruby24-build scl-utils-build' --modules ''", # noqa: E501 ] assert_mockbin_log(expected_log) @@ -821,10 +821,10 @@ def test_copr_project_many_chroots(): expected_log = [ "copr-cli list example", - "copr-cli create example/foreman-client --description foreman-client --chroot rhel-9-x86_64 --chroot rhel-8-x86_64 --chroot rhel-7-x86_64", # noqa: E501 - "copr-cli edit-chroot example/foreman-client/rhel-9-x86_64", - "copr-cli edit-chroot example/foreman-client/rhel-8-x86_64", - "copr-cli edit-chroot example/foreman-client/rhel-7-x86_64" + "copr-cli create example/foreman-client --description foreman-client --appstream off --chroot rhel-9-x86_64 --chroot rhel-8-x86_64 --chroot rhel-7-x86_64", # noqa: E501 + "copr-cli edit-chroot example/foreman-client/rhel-9-x86_64 --repos '' --packages '' --modules ''", + "copr-cli edit-chroot example/foreman-client/rhel-8-x86_64 --repos '' --packages '' --modules ''", + "copr-cli edit-chroot example/foreman-client/rhel-7-x86_64 --repos '' --packages '' --modules ''" ] assert_mockbin_log(expected_log)