From 05aaa0b956af5e06b15bf1b760874f99f3d86a79 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Wed, 8 May 2013 19:44:50 -0400 Subject: [PATCH] Add gate job configuration for Chef cookbooks This commit adds the Jenkins job builders and gate configuration for the Chef cookbooks. Only the cookbook-openstack-common repo is changed from a NOOP gate to the lint + unit gate at this time, as that cookbook is the first that will be going into the Stackforge repo. Change-Id: I999a990f15829730495ab0891e4d38f1a5795d60 Reviewed-on: https://review.openstack.org/28640 Reviewed-by: Clark Boylan Reviewed-by: Khai Do Reviewed-by: Jeremy Stanley Approved: Jeremy Stanley Tested-by: Jenkins --- doc/source/gerrit.rst | 2 +- .../config/chef-cookbooks-jobs.yaml | 29 +++++++++++++++++++ .../jenkins_job_builder/config/macros.yaml | 23 +++++++++++++++ .../jenkins_job_builder/config/projects.yaml | 9 ++++++ .../openstack_project/files/zuul/layout.yaml | 6 ++-- 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 modules/openstack_project/files/jenkins_job_builder/config/chef-cookbooks-jobs.yaml diff --git a/doc/source/gerrit.rst b/doc/source/gerrit.rst index 6e83b49e22..289d9b18d0 100644 --- a/doc/source/gerrit.rst +++ b/doc/source/gerrit.rst @@ -680,7 +680,7 @@ Have Zuul Monitor a Gerrit Project ===================================== Define the required jenkins jobs for this project using the Jenkins Job -Builder. Edit openstack-infra/config:modules/openstack_project/files/jenkins_jobs/config/projects.yaml +Builder. Edit openstack-infra/config:modules/openstack_project/files/jenkins_job_builder/config/projects.yaml and add the desired jobs. Most projects will use the python jobs template. A minimum config:: diff --git a/modules/openstack_project/files/jenkins_job_builder/config/chef-cookbooks-jobs.yaml b/modules/openstack_project/files/jenkins_job_builder/config/chef-cookbooks-jobs.yaml new file mode 100644 index 0000000000..84db2fbbb3 --- /dev/null +++ b/modules/openstack_project/files/jenkins_job_builder/config/chef-cookbooks-jobs.yaml @@ -0,0 +1,29 @@ +- job-template: + name: 'gate-{name}-chef-unit' + node: '{node}' + + triggers: + - zuul + + builders: + - gerrit-git-prep + - chef-cookbook-prep + - chef-cookbook-rspec + + publishers: + - console-log + +- job-template: + name: 'gate-{name}-chef-lint' + node: '{node}' + + triggers: + - zuul + + builders: + - gerrit-git-prep + - chef-cookbook-prep + - chef-cookbook-lint + + publishers: + - console-log diff --git a/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml b/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml index 082000a9d8..098efba37f 100644 --- a/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml +++ b/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml @@ -76,6 +76,29 @@ erb -x -T '-' $f | ruby -c done +- builder: + name: chef-cookbook-prep + builders: + - shell: | + mkdir -p .cookbooks .bundle + bundle install --path=.bundle + bundle exec berks install --path=.cookbooks + export COOKBOOK=$(awk '/^name/ {print $NF}' metadata.rb |tr -d \"\') + if [ -z $COOKBOOK ]; then + echo "Cookbook name not defined in metadata.rb" + exit 1 + fi + +- builder: + name: chef-cookbook-lint + builders: + - shell: "bundle exec foodcritic -f any -t ~FC003 -t ~FC023 .cookbooks/$COOKBOOK" + +- builder: + name: chef-cookbook-rspec + builders: + - shell: "bundle exec rspec .cookbooks/$COOKBOOK" + - builder: name: selenium builders: diff --git a/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml b/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml index 947f1dbb84..c3bf535c80 100644 --- a/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml +++ b/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml @@ -879,3 +879,12 @@ jobs: - python-jobs + +- project: + name: cookbook-openstack-common + github-org: stackforge + node: quantal + + jobs: + - gate-{name}-chef-lint + - gate-{name}-chef-unit diff --git a/modules/openstack_project/files/zuul/layout.yaml b/modules/openstack_project/files/zuul/layout.yaml index c2f941f687..33e47fcfb6 100644 --- a/modules/openstack_project/files/zuul/layout.yaml +++ b/modules/openstack_project/files/zuul/layout.yaml @@ -1668,9 +1668,11 @@ projects: - name: stackforge/cookbook-openstack-common check: - - gate-noop + - gate-cookbook-openstack-common-chef-lint + - gate-cookbook-openstack-common-chef-unit gate: - - gate-noop + - gate-cookbook-openstack-common-chef-lint + - gate-cookbook-openstack-common-chef-unit - name: stackforge/cookbook-openstack-compute check: