Add wheel builds

Sem-Ver: feature
Change-Id: I2e9799c142669ee58973779c07c574f9c2854203
diff --git a/zuul.d/playbooks/ansible-collection-atmosphere-build-wheels/post-run.yml b/zuul.d/playbooks/ansible-collection-atmosphere-build-wheels/post-run.yml
new file mode 100644
index 0000000..09b306e
--- /dev/null
+++ b/zuul.d/playbooks/ansible-collection-atmosphere-build-wheels/post-run.yml
@@ -0,0 +1,55 @@
+# Copyright (c) 2022 VEXXHOST, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+- hosts: all
+  tasks:
+    - name: Find tarballs in the project directory
+      find:
+        file_type: file
+        paths: "{{ build_openstack_requirements_wheels_directory }}"
+        patterns: "*.tar.gz"
+      register: result
+
+    - name: Display stat for tarballs
+      stat:
+        path: "{{ item.path }}"
+      with_items: "{{ result.files }}"
+
+    - name: Create destination directory on executor
+      delegate_to: localhost
+      file:
+        path: "{{ zuul.executor.work_root }}/artifacts"
+        state: directory
+        mode: 0755
+
+    - name: Collect tarball artifacts
+      synchronize:
+        dest: "{{ zuul.executor.work_root }}/artifacts"
+        mode: pull
+        src: "{{ item.path }}"
+        verify_host: true
+        owner: no
+        group: no
+      with_items: "{{ result.files }}"
+
+    - name: Return artifacts to Zuul
+      loop: "{{ result.files }}"
+      zuul_return:
+        data:
+          zuul:
+            artifacts:
+              - name: "Wheels ({{ ansible_architecture }})"
+                url: "artifacts/{{ item.path | basename }}"
+                metadata:
+                  type: wheels
\ No newline at end of file
diff --git a/zuul.d/playbooks/ansible-collection-atmosphere-build-wheels/pre-run.yml b/zuul.d/playbooks/ansible-collection-atmosphere-build-wheels/pre-run.yml
new file mode 100644
index 0000000..17680c5
--- /dev/null
+++ b/zuul.d/playbooks/ansible-collection-atmosphere-build-wheels/pre-run.yml
@@ -0,0 +1,17 @@
+# Copyright (c) 2022 VEXXHOST, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+- hosts: all
+  roles:
+    - ensure-pip
\ No newline at end of file
diff --git a/zuul.d/playbooks/ansible-collection-atmosphere-merge-wheels/post-run.yml b/zuul.d/playbooks/ansible-collection-atmosphere-merge-wheels/post-run.yml
new file mode 100644
index 0000000..073c2fe
--- /dev/null
+++ b/zuul.d/playbooks/ansible-collection-atmosphere-merge-wheels/post-run.yml
@@ -0,0 +1,45 @@
+# Copyright (c) 2022 VEXXHOST, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+- hosts: all
+  tasks:
+    - name: Display stat for tarballs
+      stat:
+        path: /tmp/wheels.tar.gz
+
+    - name: Create destination directory on executor
+      delegate_to: localhost
+      file:
+        path: "{{ zuul.executor.work_root }}/artifacts"
+        state: directory
+        mode: 0755
+
+    - name: Collect tarball artifacts
+      synchronize:
+        dest: "{{ zuul.executor.work_root }}/artifacts"
+        mode: pull
+        src: /tmp/wheels.tar.gz
+        verify_host: true
+        owner: no
+        group: no
+
+    - name: Return artifacts to Zuul
+      zuul_return:
+        data:
+          zuul:
+            artifacts:
+              - name: Wheels
+                url: artifacts/wheels.tar.gz
+                metadata:
+                  type: wheels
\ No newline at end of file
diff --git a/zuul.d/playbooks/ansible-collection-atmosphere-merge-wheels/run.yml b/zuul.d/playbooks/ansible-collection-atmosphere-merge-wheels/run.yml
new file mode 100644
index 0000000..519aabb
--- /dev/null
+++ b/zuul.d/playbooks/ansible-collection-atmosphere-merge-wheels/run.yml
@@ -0,0 +1,44 @@
+# Copyright (c) 2022 VEXXHOST, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+- hosts: all
+  gather_facts: false
+  tasks:
+    - name: Download all artifacts
+      ansible.builtin.get_url:
+        url: "{{ item.url }}"
+        dest: "/tmp/{{ item.url | basename }}"
+        mode: '0440'
+      loop: "{{ zuul.artifacts }}"
+      when: item.metadata.get("type") == "wheels"
+
+    - name: Create a folder for all wheels
+      ansible.builtin.file:
+        path: "/tmp/wheels"
+        state: directory
+
+    - name: Extract all wheels into the same folder
+      ansible.builtin.unarchive:
+        src: "/tmp/{{ item.url | basename }}"
+        dest: /tmp/wheels
+        remote_src: true
+      loop: "{{ zuul.artifacts }}"
+      when: item.metadata.get("type") == "wheels"
+
+    - name: Create archive with all wheels
+      # TODO(mnaser): Switch this to "community.general.archive" once Zuul is using
+      #               a new enough Ansible.
+      archive:
+        path: "/tmp/wheels/*.whl"
+        dest: /tmp/wheels.tar.gz
\ No newline at end of file
diff --git a/zuul.d/wheels-wallaby.yaml b/zuul.d/wheels-wallaby.yaml
new file mode 100644
index 0000000..2f10d80
--- /dev/null
+++ b/zuul.d/wheels-wallaby.yaml
@@ -0,0 +1,57 @@
+# Copyright (c) 2022 VEXXHOST, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+- job:
+    name: ansible-collection-atmosphere-build-wheels-wallaby
+    parent: ansible-collection-atmosphere-build-wheels
+    vars:
+      build_openstack_requirements_release: wallaby
+
+- job:
+    name: ansible-collection-atmosphere-build-wheels-wallaby-amd64
+    parent: ansible-collection-atmosphere-build-wheels-wallaby
+    nodeset: ubuntu-focal
+
+- job:
+    name: ansible-collection-atmosphere-build-wheels-wallaby-aarch64
+    parent: ansible-collection-atmosphere-build-wheels-wallaby
+    nodeset: ubuntu-focal-arm64
+
+- job:
+    name: ansible-collection-atmosphere-merge-wheels-wallaby
+    parent: ansible-collection-atmosphere-merge-wheels
+    dependencies:
+      - ansible-collection-atmosphere-build-wheels-wallaby-amd64
+      - ansible-collection-atmosphere-build-wheels-wallaby-aarch64
+
+- job:
+    name: ansible-collection-atmosphere-promote-wheels-wallaby
+    parent: ansible-collection-atmosphere-promote-wheels
+    vars:
+      artifact_extra_name: wheels-wallaby
+
+- project:
+    check:
+      jobs:
+        - ansible-collection-atmosphere-build-wheels-wallaby-amd64
+        - ansible-collection-atmosphere-build-wheels-wallaby-aarch64
+        - ansible-collection-atmosphere-merge-wheels-wallaby
+    gate:
+      jobs:
+        - ansible-collection-atmosphere-build-wheels-wallaby-amd64
+        - ansible-collection-atmosphere-build-wheels-wallaby-aarch64
+        - ansible-collection-atmosphere-merge-wheels-wallaby
+    promote:
+      jobs:
+        - ansible-collection-atmosphere-promote-wheels-wallaby
\ No newline at end of file
diff --git a/zuul.d/wheels.yaml b/zuul.d/wheels.yaml
new file mode 100644
index 0000000..ee7ab18
--- /dev/null
+++ b/zuul.d/wheels.yaml
@@ -0,0 +1,47 @@
+# Copyright (c) 2022 VEXXHOST, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+- job:
+    name: ansible-collection-atmosphere-build-wheels
+    abstract: true
+    pre-run:
+      - zuul.d/playbooks/ansible-collection-atmosphere-build-wheels/pre-run.yml
+    run:
+      - playbooks/build_wheels.yml
+    post-run:
+      - zuul.d/playbooks/ansible-collection-atmosphere-build-wheels/post-run.yml
+    files: &build-wheels-files
+      - playbooks/build_wheels.yml
+      - roles/build_openstack_requirements/.*
+    vars:
+      build_openstack_requirements_wheels_directory: /tmp
+
+- job:
+    name: ansible-collection-atmosphere-merge-wheels
+    abstract: true
+    run:
+      - zuul.d/playbooks/ansible-collection-atmosphere-merge-wheels/run.yml
+    post-run:
+      - zuul.d/playbooks/ansible-collection-atmosphere-merge-wheels/post-run.yml
+    files: *build-wheels-files
+
+- job:
+    name: ansible-collection-atmosphere-promote-wheels
+    parent: opendev-promote-python
+    abstract: true
+    vars:
+      download_artifact_job: "{{ zuul.job | replace('promote', 'merge') }}"
+      download_artifact_type:
+        - wheels
+    files: *build-wheels-files
\ No newline at end of file