From bee12690cf88bf5de6535315b019a79aa9f0d182 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Fri, 1 Jul 2016 15:32:57 -0500 Subject: [PATCH] adds a shaman-pull-requests job Will run tox tests for each PR Signed-off-by: Andrew Schoen --- shaman-pull-requests/build/build | 13 ++++ .../definitions/shaman-pull-requests.yml | 78 +++++++++++++++++++ .../setup/playbooks/ansible.cfg | 2 + .../setup/playbooks/setup.yml | 8 ++ .../setup/playbooks/tasks/postgresql.yml | 51 ++++++++++++ 5 files changed, 152 insertions(+) create mode 100644 shaman-pull-requests/build/build create mode 100644 shaman-pull-requests/config/definitions/shaman-pull-requests.yml create mode 100644 shaman-pull-requests/setup/playbooks/ansible.cfg create mode 100644 shaman-pull-requests/setup/playbooks/setup.yml create mode 100644 shaman-pull-requests/setup/playbooks/tasks/postgresql.yml diff --git a/shaman-pull-requests/build/build b/shaman-pull-requests/build/build new file mode 100644 index 00000000..71fa654c --- /dev/null +++ b/shaman-pull-requests/build/build @@ -0,0 +1,13 @@ +#!/bin/bash + +# the following two methods exist in scripts/build_utils.sh +pkgs=( "ansible" "tox" ) +install_python_packages "pkgs[@]" + +# run ansible to get this current host to meet our requirements, specifying +# a local connection and 'localhost' as the host where to execute +cd "$WORKSPACE/ceph-build/shaman-pull-requests/setup/playbooks" +$VENV/ansible-playbook -i "localhost," -c local setup.yml + +cd "$WORKSPACE/shaman" +$VENV/tox -rv diff --git a/shaman-pull-requests/config/definitions/shaman-pull-requests.yml b/shaman-pull-requests/config/definitions/shaman-pull-requests.yml new file mode 100644 index 00000000..c264773f --- /dev/null +++ b/shaman-pull-requests/config/definitions/shaman-pull-requests.yml @@ -0,0 +1,78 @@ +- scm: + name: shaman + scm: + - git: + url: https://github.com/ceph/shaman + branches: + - ${sha1} + refspec: +refs/pull/*:refs/remotes/origin/pr/* + browser: auto + timeout: 20 + basedir: "shaman" + skip-tag: true + wipe-workspace: true + +- scm: + name: ceph-build + scm: + - git: + url: https://github.com/ceph/ceph-build.git + browser-url: https://github.com/ceph/ceph-build + timeout: 20 + skip-tag: true + wipe-workspace: false + basedir: "ceph-build" + branches: + - origin/master + + +- job: + name: shaman-pull-requests + description: Runs tox tests for shaman on each GitHub PR + project-type: freestyle + node: trusty && small + block-downstream: false + block-upstream: false + defaults: global + display-name: 'shaman: Pull Requests' + quiet-period: 5 + retry-count: 3 + + logrotate: + daysToKeep: 15 + numToKeep: 30 + artifactDaysToKeep: 15 + artifactNumToKeep: 15 + + properties: + - github: + url: https://github.com/ceph/shaman/ + + parameters: + - string: + name: sha1 + description: "A pull request ID, like 'origin/pr/72/head'" + + triggers: + - github-pull-request: + admin-list: + - alfredodeza + - dmick + - ktdreyer + - andrewschoen + org-list: + - ceph + only-trigger-phrase: false + github-hooks: true + permit-all: false + auto-close-on-fail: false + + scm: + - shaman + - ceph-build + + builders: + - shell: + !include-raw: + - ../../../scripts/build_utils.sh + - ../../build/build diff --git a/shaman-pull-requests/setup/playbooks/ansible.cfg b/shaman-pull-requests/setup/playbooks/ansible.cfg new file mode 100644 index 00000000..4b5ea57c --- /dev/null +++ b/shaman-pull-requests/setup/playbooks/ansible.cfg @@ -0,0 +1,2 @@ +[ssh_connection] +pipelining=True diff --git a/shaman-pull-requests/setup/playbooks/setup.yml b/shaman-pull-requests/setup/playbooks/setup.yml new file mode 100644 index 00000000..04dc83a6 --- /dev/null +++ b/shaman-pull-requests/setup/playbooks/setup.yml @@ -0,0 +1,8 @@ +--- + +- hosts: localhost + user: jenkins-build + sudo: True + + tasks: + - include: tasks/postgresql.yml diff --git a/shaman-pull-requests/setup/playbooks/tasks/postgresql.yml b/shaman-pull-requests/setup/playbooks/tasks/postgresql.yml new file mode 100644 index 00000000..d2305f4a --- /dev/null +++ b/shaman-pull-requests/setup/playbooks/tasks/postgresql.yml @@ -0,0 +1,51 @@ +--- +- name: update apt cache + apt: + update_cache: yes + sudo: yes + +- name: install postgresql requirements + sudo: yes + apt: + name: "{{ item }}" + state: present + with_items: + - postgresql + - postgresql-common + - postgresql-contrib + - postgresql-server-dev-9.3 + - python-psycopg2 + tags: + - packages + +- name: ensure database service is up + service: + name: postgresql + state: started + enabled: yes + sudo: yes + +- name: allow users to connect locally + sudo: yes + lineinfile: + # TODO: should not hardcode that version + # 9.3 is available on trusty, 9.5 on Xenial + dest: /etc/postgresql/9.3/main/pg_hba.conf + regexp: '^host\s+all\s+all\s+127.0.0.1/32' + line: 'host all all 127.0.0.1/32 trust' + backrefs: yes + register: pg_hba_conf + +- name: make jenkins-build user + postgresql_user: + name: "jenkins-build" + password: "secret" + role_attr_flags: SUPERUSER + login_user: postgres + become_user: postgres + become: yes + +- service: + name: postgresql + state: restarted + sudo: true -- 2.39.5