Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ansible-test-sanity job #166

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions playbooks/ansible-test-sanity-base/post.yaml
@@ -0,0 +1,3 @@
---
- hosts: all
tasks: []
8 changes: 8 additions & 0 deletions playbooks/ansible-test-sanity-base/pre.yaml
@@ -0,0 +1,8 @@
---
- hosts: all
tasks:
- name: Install jq
become: true
package:
name: jq
state: present
56 changes: 56 additions & 0 deletions playbooks/ansible-test-sanity-base/run.yaml
@@ -0,0 +1,56 @@
---
- hosts: all
tasks:
- name: Setup base virtualenv_options
set_fact:
_virtualenv_options: "--python python{{ ansible_test_python }}"

- name: Enable --system-site-packages for virtualenv_options
set_fact:
_virtualenv_options: "{{ _virtualenv_options }} --system-site-packages"
when: ansible_os_family == "RedHat"

- name: Create virtualenv for ansible-test
shell: "virtualenv {{ _virtualenv_options }} ~/venv"

- name: Install ara into virtuelenv
shell: ~/venv/bin/pip install yq

- name: Setup base test_options
set_fact:
_test_options: "-vv --requirements --python {{ ansible_test_python }} --lint"

- name: Get collection namespace
args:
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
executable: /bin/bash
shell: cat galaxy.yml | ~/venv/bin/yq -y .namespace | tail -n +1 | head -1
register: _collection_namespace

- name: Get collection name
args:
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
executable: /bin/bash
shell: cat galaxy.yml | ~/venv/bin/yq -y .name | tail -n +1 | head -1
register: _collection_name

- name: Install ansible into virtuelenv
shell: "source ~/venv/bin/activate; pip install {{ ansible_user_dir }}/{{ zuul.projects['github.com/ansible/ansible'].src_dir }}"

- name: Build collection using ansible-galaxy
args:
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
executable: /bin/bash
shell: "source ~/venv/bin/activate; {{ ansible_user_dir }}/{{ zuul.projects['github.com/ansible/ansible'].src_dir }}/bin/ansible-galaxy collection build"

- name: Install collection using ansible-galaxy
args:
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
executable: /bin/bash
shell: "source ~/venv/bin/activate; {{ ansible_user_dir }}/{{ zuul.projects['github.com/ansible/ansible'].src_dir }}/bin/ansible-galaxy collection install -p ~/.ansible/collection *.tar.gz"

- name: Run the sanity test suite
args:
chdir: "~/.ansible/collection/ansible_collections/{{ _collection_namespace.stdout }}/{{ _collection_name.stdout }}"
executable: /bin/bash
shell: "source ~/venv/bin/activate; {{ ansible_user_dir }}/{{ zuul.projects['github.com/ansible/ansible'].src_dir }}/bin/ansible-test sanity {{ _test_options }}"
13 changes: 13 additions & 0 deletions zuul.d/jobs.yaml
Expand Up @@ -366,3 +366,16 @@
nodeset: vyos-1.1.8-python37
vars:
ansible_test_python: 3.7

- job:
name: ansible-test-sanity
parent: unittests
pre-run: playbooks/ansible-test-sanity-base/pre.yaml
run: playbooks/ansible-test-sanity-base/run.yaml
post-run: playbooks/ansible-test-sanity-base/post.yaml
required-projects:
- name: github.com/ansible/ansible
timeout: 7200
nodeset: fedora-latest-1vcpu
vars:
ansible_test_python: 3.6