Add ensure-hatch
Change-Id: I4425af049cbbf29a9e112e38e6d1674e6fe3ca31
diff --git a/playbooks/generic-test/run.yaml b/playbooks/generic-test/run.yaml
new file mode 100644
index 0000000..f4ed439
--- /dev/null
+++ b/playbooks/generic-test/run.yaml
@@ -0,0 +1,5 @@
+- hosts: all
+ tasks:
+ - name: Test role
+ ansible.builtin.include_role:
+ name: "{{ role_name }}"
diff --git a/roles/ensure-hatch/defaults/main.yaml b/roles/ensure-hatch/defaults/main.yaml
new file mode 100644
index 0000000..3d8c5b5
--- /dev/null
+++ b/roles/ensure-hatch/defaults/main.yaml
@@ -0,0 +1 @@
+ensure_hatch_path: /usr/local/bin
diff --git a/roles/ensure-hatch/tasks/main.yaml b/roles/ensure-hatch/tasks/main.yaml
new file mode 100644
index 0000000..46250de
--- /dev/null
+++ b/roles/ensure-hatch/tasks/main.yaml
@@ -0,0 +1,29 @@
+- name: Download and extract Depot
+ block:
+ - name: Create a temporary file
+ ansible.builtin.tempfile:
+ prefix: hatch
+ suffix: .tar.gz
+ state: file
+ register: ensure_hatch_tar
+
+ - name: Download Hatch release
+ ansible.builtin.get_url:
+ url: https://github.com/pypa/hatch/releases/download/hatch-v{{ ensure_hatch_version }}/hatch-x86_64-unknown-linux-gnu.tar.gz
+ dest: "{{ ensure_hatch_tar.path }}"
+ force: true
+
+ - name: Extract into {{ ensure_hatch_path }}
+ become: true
+ ansible.builtin.unarchive:
+ src: "{{ ensure_hatch_tar.path }}"
+ dest: "{{ ensure_hatch_path }}"
+ remote_src: yes
+ always:
+ - name: Remove the temporary file
+ ansible.builtin.file:
+ path: "{{ ensure_hatch_tar.path }}"
+ state: absent
+
+- name: Assert that Hatch is functional
+ ansible.builtin.command: hatch --version
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
new file mode 100644
index 0000000..383ad69
--- /dev/null
+++ b/zuul.d/jobs.yaml
@@ -0,0 +1,11 @@
+- job:
+ name: zuul-jobs-generic-test
+ abstract: true
+ run: playbooks/generic-test/run.yaml
+
+- job:
+ name: zuul-jobs-test-ensure-hatch
+ parent: zuul-jobs-generic-test
+ vars:
+ role_name: ensure-hatch
+ ensure_hatch_version: 1.14.0
diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml
new file mode 100644
index 0000000..6142211
--- /dev/null
+++ b/zuul.d/project.yaml
@@ -0,0 +1,7 @@
+- project:
+ check:
+ jobs:
+ - zuul-jobs-test-ensure-hatch
+ gate:
+ jobs:
+ - zuul-jobs-test-ensure-hatch