From 0270ae1809b393642cc2b8830cd059477f34c6ed Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Nov 05 2024 09:30:34 +0000 Subject: [PATCH 1/3] Add check-for-arches-ng for a better discovering of build arches See: - https://pagure.io/fedora-ci/general/issue/495 - https://pagure.io/fedora-ci/general/issue/496 --- diff --git a/playbooks/rpm/check-for-arches-ng.yaml b/playbooks/rpm/check-for-arches-ng.yaml new file mode 100644 index 0000000..1c837f6 --- /dev/null +++ b/playbooks/rpm/check-for-arches-ng.yaml @@ -0,0 +1,18 @@ +- hosts: all + tasks: + - name: Copy discover-arches script + ansible.builtin.copy: + src: files/discover-arches.py + dest: /tmp/discover-arches.py + + - name: Run discover-arches.py + ansible.builtin.shell: python3 /tmp/discover-arches.py *.spec + register: cmd_out + failed_when: false + args: + chdir: "{{ zuul.project.src_dir }}" + + - zuul_return: + data: + zuul: + child_jobs: "{{ cmd_out.stdout | from_json }}" diff --git a/playbooks/rpm/files/discover-arches.py b/playbooks/rpm/files/discover-arches.py new file mode 100644 index 0000000..86d0ba8 --- /dev/null +++ b/playbooks/rpm/files/discover-arches.py @@ -0,0 +1,27 @@ +import rpm +import sys +import json + +DEFAULT_ARCHES = {"x86_64", "i686", "aarch64", "ppc64le", "s390x"} + + +def arch_to_job(arch): + if arch in ("noarch", "x86_64"): + return "rpm-scratch-build" + else: + return "rpm-sratch-build-%s" % arch + + +s = rpm.spec(sys.argv[1]) +arch = s.sourceHeader[rpm.RPMTAG_ARCH] + +if arch == "noarch": + print(json.dumps([arch_to_job("noarch")])) +else: + exclusive_arch = set(s.sourceHeader[rpm.RPMTAG_EXCLUSIVEARCH]) + exclude_arch = set(s.sourceHeader[rpm.RPMTAG_EXCLUDEARCH]) + if exclusive_arch: + build_on = (DEFAULT_ARCHES & exclusive_arch) - exclude_arch + else: + build_on = DEFAULT_ARCHES - exclude_arch + print(json.dumps([arch_to_job(arch) for arch in build_on])) From aabab27f62bfe86dacd298e13b5788d22b442581 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Nov 05 2024 09:30:34 +0000 Subject: [PATCH 2/3] Typo fix --- diff --git a/playbooks/rpm/files/discover-arches.py b/playbooks/rpm/files/discover-arches.py index 86d0ba8..db0fe5d 100644 --- a/playbooks/rpm/files/discover-arches.py +++ b/playbooks/rpm/files/discover-arches.py @@ -9,7 +9,7 @@ def arch_to_job(arch): if arch in ("noarch", "x86_64"): return "rpm-scratch-build" else: - return "rpm-sratch-build-%s" % arch + return "rpm-scratch-build-%s" % arch s = rpm.spec(sys.argv[1]) From 23119dbd4cf13baad99f073f8a51e8bb0d8679a9 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Nov 05 2024 09:36:03 +0000 Subject: [PATCH 3/3] Use debug instead of zuul_return just for monitoring purpose --- diff --git a/playbooks/rpm/check-for-arches-ng.yaml b/playbooks/rpm/check-for-arches-ng.yaml index 1c837f6..8650e35 100644 --- a/playbooks/rpm/check-for-arches-ng.yaml +++ b/playbooks/rpm/check-for-arches-ng.yaml @@ -12,7 +12,10 @@ args: chdir: "{{ zuul.project.src_dir }}" - - zuul_return: - data: - zuul: - child_jobs: "{{ cmd_out.stdout | from_json }}" + # - zuul_return: + # data: + # zuul: + # child_jobs: "{{ cmd_out.stdout | from_json }}" + + - ansible.builtin.debug: + msg: "{{ cmd_out.stdout | from_json }}"