Added Zuul artifacts for builds
Change-Id: I586ffaed81e516f8f1806044f9191533404a5b3c
diff --git a/.gitignore b/.gitignore
index 6ffdefe..79f3920 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
.tox
.vscode
doc/build/*
-doc/source/roles/*/defaults
\ No newline at end of file
+doc/source/roles/*/defaults
+galaxy.yml
+*.tar.gz
\ No newline at end of file
diff --git a/releasenotes/notes/add-zuul-artifacts-fc8ce46d3a43414e.yaml b/releasenotes/notes/add-zuul-artifacts-fc8ce46d3a43414e.yaml
new file mode 100644
index 0000000..cac50bb
--- /dev/null
+++ b/releasenotes/notes/add-zuul-artifacts-fc8ce46d3a43414e.yaml
@@ -0,0 +1,3 @@
+---
+features:
+ - Added Zuul artifacts with built collections for all commits.
diff --git a/tools/generate-galaxy-yml.py b/tools/generate-galaxy-yml.py
new file mode 100644
index 0000000..17f787e
--- /dev/null
+++ b/tools/generate-galaxy-yml.py
@@ -0,0 +1,28 @@
+import yaml
+from pbr.version import VersionInfo
+
+GALAXY_YML = {
+ 'namespace': 'vexxhost',
+ 'name': 'atmosphere',
+ 'version': VersionInfo('ansible-collection-atmosphere').release_string(),
+ 'readme': 'README.md',
+ 'authors': [
+ "Mohammed Naser <mnaser@vexxhost.com>",
+ ],
+ 'dependencies': {
+ 'ansible.posix': '1.3.0',
+ 'ansible.utils': '2.5.2',
+ 'community.crypto': '2.2.3',
+ 'community.general': '4.5.0',
+ 'kubernetes.core': '2.2.3',
+ 'openstack.cloud': '1.7.0',
+ },
+ 'build_ignore': [
+ '.tox',
+ '.vscode',
+ 'doc',
+ ],
+}
+
+with open('galaxy.yml', 'w') as f:
+ yaml.dump(GALAXY_YML, f, default_flow_style=False)
diff --git a/tox.ini b/tox.ini
index 1f4cb11..8d42a68 100644
--- a/tox.ini
+++ b/tox.ini
@@ -23,6 +23,15 @@
TERM
STACK_NAME
+[testenv:build]
+deps =
+ ansible-core
+ pbr
+ pyyaml
+commands =
+ python3 {toxinidir}/tools/generate-galaxy-yml.py
+ ansible-galaxy collection build --force
+
[testenv:molecule]
deps =
ansible
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
index 435207e..8f19a49 100644
--- a/zuul.d/jobs.yaml
+++ b/zuul.d/jobs.yaml
@@ -13,6 +13,14 @@
# under the License.
- job:
+ name: ansible-collection-atmosphere-tox-build
+ parent: tox
+ post-run:
+ - zuul.d/playbooks/ansible-collection-atmosphere-tox-build/post-run.yml
+ vars:
+ tox_envlist: build
+
+- job:
name: ansible-collection-atmosphere-tox-molecule
parent: vexxhost-tox-molecule
pre-run:
diff --git a/zuul.d/playbooks/ansible-collection-atmosphere-tox-build/post-run.yml b/zuul.d/playbooks/ansible-collection-atmosphere-tox-build/post-run.yml
new file mode 100644
index 0000000..6ec1ba2
--- /dev/null
+++ b/zuul.d/playbooks/ansible-collection-atmosphere-tox-build/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: "{{ zuul.project.src_dir }}"
+ 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: Ansible Collection
+ url: "artifacts/{{ item.path | basename }}"
+ metadata:
+ type: ansible_collection
\ No newline at end of file
diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml
index 860720c..682ee36 100644
--- a/zuul.d/project.yaml
+++ b/zuul.d/project.yaml
@@ -15,10 +15,12 @@
- project:
check:
jobs:
+ - ansible-collection-atmosphere-tox-build
- ansible-collection-atmosphere-tox-molecule-default
- opendev-tox-docs
gate:
jobs:
+ - ansible-collection-atmosphere-tox-build
- ansible-collection-atmosphere-tox-molecule-default
- opendev-tox-docs
promote: