From e14dd047ec0eb7ef485b1afb4be9a87a60b2f95b Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Wed, 22 Jun 2016 16:23:25 -0500 Subject: [PATCH] Adds the chacra-pull-requests job Signed-off-by: Andrew Schoen --- chacra-pull-requests/build/build | 12 +++ .../definitions/chacra-pull-requests.yml | 77 +++++++++++++++++++ .../setup/playbooks/setup.yml | 8 ++ .../setup/playbooks/tasks/postgresql.yml | 40 ++++++++++ 4 files changed, 137 insertions(+) create mode 100644 chacra-pull-requests/build/build create mode 100644 chacra-pull-requests/config/definitions/chacra-pull-requests.yml create mode 100644 chacra-pull-requests/setup/playbooks/setup.yml create mode 100644 chacra-pull-requests/setup/playbooks/tasks/postgresql.yml diff --git a/chacra-pull-requests/build/build b/chacra-pull-requests/build/build new file mode 100644 index 00000000..37fe4f1f --- /dev/null +++ b/chacra-pull-requests/build/build @@ -0,0 +1,12 @@ +#!/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/chacra-pull-requests/setup/playbooks" +$VENV/ansible-playbook -i "localhost," -c local setup.yml + +$VENV/tox -rv diff --git a/chacra-pull-requests/config/definitions/chacra-pull-requests.yml b/chacra-pull-requests/config/definitions/chacra-pull-requests.yml new file mode 100644 index 00000000..1347295d --- /dev/null +++ b/chacra-pull-requests/config/definitions/chacra-pull-requests.yml @@ -0,0 +1,77 @@ +- scm: + name: chacra + scm: + - git: + url: https://github.com/ceph/chacra + branches: + - ${sha1} + refspec: +refs/pull/*:refs/remotes/origin/pr/* + browser: auto + timeout: 20 + 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: chacra-pull-requests + description: Runs tox tests for chacra on each GitHub PR + project-type: freestyle + node: trusty && small + block-downstream: false + block-upstream: false + defaults: global + display-name: 'chacra: Pull Requests' + quiet-period: 5 + retry-count: 3 + + logrotate: + daysToKeep: 15 + numToKeep: 30 + artifactDaysToKeep: 15 + artifactNumToKeep: 15 + + properties: + - github: + url: https://github.com/ceph/chacra/ + + 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: + - chacra + - ceph-build + + builders: + - shell: + !include-raw: + - ../../../scripts/build_utils.sh + - ../../build/build diff --git a/chacra-pull-requests/setup/playbooks/setup.yml b/chacra-pull-requests/setup/playbooks/setup.yml new file mode 100644 index 00000000..04dc83a6 --- /dev/null +++ b/chacra-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/chacra-pull-requests/setup/playbooks/tasks/postgresql.yml b/chacra-pull-requests/setup/playbooks/tasks/postgresql.yml new file mode 100644 index 00000000..4e1f3d6a --- /dev/null +++ b/chacra-pull-requests/setup/playbooks/tasks/postgresql.yml @@ -0,0 +1,40 @@ +--- +- 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 + 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 + dest: /etc/postgresql/9.5/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 md5' + backrefs: yes + register: pg_hba_conf + +- service: + name: postgresql + state: restarted + sudo: true + when: pg_hba_conf.changed -- 2.39.5