Add generic tox job (multiple playbooks)
Here we now support 3 tox jobs; cover, linters and py27.
As you can see by looking at the code, we are not defining any
variables (vars) in .zuul.yaml. This means, we create 3 separate
playbooks (tox-cover.yaml, tox-py27, tox-linters.yaml) which then
contain the variables we need for our tox role.
Change-Id: I42f8855f44da51cb3d23f1825bd3258937543b2f
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
diff --git a/.zuul.yaml b/.zuul.yaml
index bb9a96d..ed66422 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -1,15 +1,37 @@
- job:
- name: python-linters
- pre-run: pre
- post-run: post
+ name: base
+ pre-run: base-pre
+ post-run: base-post
success-url: http://zuulv3-dev.openstack.org/logs/{build.uuid}/
failure-url: http://zuulv3-dev.openstack.org/logs/{build.uuid}/
+ timeout: 1800
nodes:
- - name: worker
+ - name: ubuntu-xenial
image: ubuntu-xenial
+- job:
+ name: tox
+ parent: base
+ pre-run: tox-pre
+ post-run: tox-post
+
+- job:
+ name: tox-cover
+ parent: tox
+ voting: false
+
+- job:
+ name: tox-linters
+ parent: tox
+
+- job:
+ name: tox-py27
+ parent: tox
+
- project:
name: openstack-infra/zuul
check:
jobs:
- - python-linters
+ - tox-cover
+ - tox-linters
+ - tox-py27
diff --git a/playbooks/base-post.yaml b/playbooks/base-post.yaml
new file mode 100644
index 0000000..2b3450d
--- /dev/null
+++ b/playbooks/base-post.yaml
@@ -0,0 +1,13 @@
+- hosts: all
+ tasks:
+ - name: Collect console log.
+ synchronize:
+ dest: "{{ zuul.launcher.log_root }}"
+ mode: pull
+ src: "/tmp/console.log"
+
+ - name: Publish logs.
+ copy:
+ dest: "/opt/zuul-logs/{{ zuul.uuid}}"
+ src: "{{ zuul.launcher.log_root }}/"
+ delegate_to: 127.0.0.1
diff --git a/playbooks/pre.yaml b/playbooks/base-pre.yaml
similarity index 100%
rename from playbooks/pre.yaml
rename to playbooks/base-pre.yaml
diff --git a/playbooks/post.yaml b/playbooks/post.yaml
deleted file mode 100644
index a11e50a..0000000
--- a/playbooks/post.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-- hosts: all
- tasks:
- - name: Collect console log.
- synchronize:
- dest: "{{ zuul.launcher.log_root }}"
- mode: pull
- src: "/tmp/console.log"
-
- - name: Collect tox logs.
- synchronize:
- dest: "{{ zuul.launcher.log_root }}/tox"
- mode: pull
- src: "/home/zuul/workspace/src/{{ zuul.project }}/.tox/pep8/log/"
-
- - name: publish tox logs.
- copy:
- dest: "/opt/zuul-logs/{{ zuul.uuid}}"
- src: "{{ zuul.launcher.log_root }}/"
- delegate_to: 127.0.0.1
diff --git a/playbooks/python-linters.yaml b/playbooks/python-linters.yaml
deleted file mode 100644
index bc7effe..0000000
--- a/playbooks/python-linters.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-- hosts: all
- tasks:
- - name: Run a tox -e pep8.
- include_role:
- name: run-tox
- vars:
- run_tox_eventlist: pep8
diff --git a/playbooks/roles/run-bindep/tasks/main.yaml b/playbooks/roles/run-bindep/tasks/main.yaml
new file mode 100644
index 0000000..7717c86
--- /dev/null
+++ b/playbooks/roles/run-bindep/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run install-distro-packages.sh
+ shell: /usr/local/jenkins/slave_scripts/install-distro-packages.sh
+ args:
+ chdir: "/home/zuul/workspace/src/{{ zuul.project }}"
diff --git a/playbooks/roles/run-tox/defaults/main.yaml b/playbooks/roles/run-tox/defaults/main.yaml
index 7f0310c..9cb1477 100644
--- a/playbooks/roles/run-tox/defaults/main.yaml
+++ b/playbooks/roles/run-tox/defaults/main.yaml
@@ -1,3 +1,2 @@
---
-# tasks/main.yaml
-run_tox_eventlist:
+run_tox_envlist:
diff --git a/playbooks/roles/run-tox/tasks/main.yaml b/playbooks/roles/run-tox/tasks/main.yaml
index ca8d079..1053690 100644
--- a/playbooks/roles/run-tox/tasks/main.yaml
+++ b/playbooks/roles/run-tox/tasks/main.yaml
@@ -1,4 +1,4 @@
- name: Run tox
- shell: "/usr/local/jenkins/slave_scripts/run-tox.sh {{ run_tox_eventlist }}"
+ shell: "/usr/local/jenkins/slave_scripts/run-tox.sh {{ run_tox_envlist }}"
args:
chdir: "/home/zuul/workspace/src/{{ zuul.project }}"
diff --git a/playbooks/tox-cover.yaml b/playbooks/tox-cover.yaml
new file mode 100644
index 0000000..942aa23
--- /dev/null
+++ b/playbooks/tox-cover.yaml
@@ -0,0 +1,5 @@
+- hosts: all
+ vars:
+ run_tox_envlist: cover
+ roles:
+ - run-tox
diff --git a/playbooks/tox-linters.yaml b/playbooks/tox-linters.yaml
new file mode 100644
index 0000000..9da2e8a
--- /dev/null
+++ b/playbooks/tox-linters.yaml
@@ -0,0 +1,5 @@
+- hosts: all
+ vars:
+ run_tox_envlist: pep8
+ roles:
+ - run-tox
diff --git a/playbooks/tox-post.yaml b/playbooks/tox-post.yaml
new file mode 100644
index 0000000..786a984
--- /dev/null
+++ b/playbooks/tox-post.yaml
@@ -0,0 +1,17 @@
+- hosts: all
+ tasks:
+ - name: Find tox directories to synchrionize.
+ find:
+ file_type: directory
+ paths: "/home/zuul/workspace/src/{{ zuul.project }}/.tox"
+ # NOTE(pabelanger): The .tox/log folder is empty, ignore it.
+ patterns: ^(?!log).*$
+ use_regex: yes
+ register: result
+
+ - name: Collect tox logs.
+ synchronize:
+ dest: "{{ zuul.launcher.log_root }}/tox"
+ mode: pull
+ src: "{{ item.path }}/log/"
+ with_items: "{{ result.files }}"
diff --git a/playbooks/tox-pre.yaml b/playbooks/tox-pre.yaml
new file mode 100644
index 0000000..0bf9b3c
--- /dev/null
+++ b/playbooks/tox-pre.yaml
@@ -0,0 +1,3 @@
+- hosts: all
+ roles:
+ - run-bindep
diff --git a/playbooks/tox-py27.yaml b/playbooks/tox-py27.yaml
new file mode 100644
index 0000000..13756b5
--- /dev/null
+++ b/playbooks/tox-py27.yaml
@@ -0,0 +1,5 @@
+- hosts: all
+ vars:
+ run_tox_envlist: py27
+ roles:
+ - run-tox