From 8cfa80e9cba0878ca8c01357729108ad6af26df4 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Fri, 12 Jun 2015 22:41:19 +0000 Subject: [PATCH] Update .gitreview file for project rename Added bootstrap.sh to allow gate to work Change-Id: I73187d3bfaa1980cb730f01afa2fa50afb15ae31 --- .gitreview | 2 +- Gemfile | 15 ------ Guardfile | 14 ------ Rakefile | 96 ++++++++++++-------------------------- bootstrap.sh | 9 ++++ spec/_example_nova_spec.rb | 6 +-- 6 files changed, 43 insertions(+), 99 deletions(-) delete mode 100644 Guardfile create mode 100755 bootstrap.sh diff --git a/.gitreview b/.gitreview index 5f4c91b..b525a43 100644 --- a/.gitreview +++ b/.gitreview @@ -1,4 +1,4 @@ [gerrit] host=review.openstack.org port=29418 -project=stackforge/cookbook-openstack-client.git +project=openstack/cookbook-openstack-client.git diff --git a/Gemfile b/Gemfile index d4c25dc..7259cef 100644 --- a/Gemfile +++ b/Gemfile @@ -1,19 +1,4 @@ source 'https://rubygems.org' -gem 'chef', '~> 11.18.6' -gem 'json', '<= 1.7.7' # chef 11 dependency -gem 'berkshelf', '~> 3.2.1' -gem 'hashie', '~> 2.0' -gem 'chefspec', '~> 4.0.0' -gem 'rspec', '~> 3.0.0' -gem 'foodcritic', '~> 4.0' -gem 'rubocop', '~> 0.29.1' gem 'chef-sugar' gem 'fog' - -gem 'rake', '~> 10.0' -gem 'test-kitchen' -gem 'kitchen-vagrant' -gem 'guard', '>= 2.6' -gem 'guard-rubocop', '>= 1.1' -gem 'guard-foodcritic', '>= 1.0.2' diff --git a/Guardfile b/Guardfile deleted file mode 100644 index 124ed4b..0000000 --- a/Guardfile +++ /dev/null @@ -1,14 +0,0 @@ -# Guardfile for testing your chef cookbooks. - -guard :rubocop do - watch(%r{.+\.rb$}) - watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } -end - -guard :foodcritic, cookbook_paths: '.', cli: ['--epic-fail', 'any'] do - watch(%r{attributes/.+\.rb$}) - watch(%r{providers/.+\.rb$}) - watch(%r{recipes/.+\.rb$}) - watch(%r{resources/.+\.rb$}) - watch(%r{metadata\.rb$}) -end diff --git a/Rakefile b/Rakefile index 128268b..eff27c8 100644 --- a/Rakefile +++ b/Rakefile @@ -1,77 +1,41 @@ -# Encoding: utf-8 +task default: ["test"] -namespace :prepare do - - desc 'Install ChefDK' - task :chefdk do - begin - gem 'chef-dk', '0.3.0' - rescue Gem::LoadError - puts 'ChefDK not found. Installing it for you...' - sh %(wget -O /tmp/chefdk.deb https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chefdk_0.3.0-1_amd64.deb) - sh %(sudo dpkg -i /tmp/chefdk.deb) - end - end - - task :bundle do - if ENV['CI'] - sh %(chef exec bundle install --path=.bundle --jobs 1 --retry 3 --verbose) - else - sh %(chef exec bundle install --path .bundle) - end - end - - task :berks do - sh %(chef exec berks vendor) - end +task :test => [:lint, :style, :unit] +desc "Vendor the cookbooks in the Berksfile" +task :berks_prep do + sh %{chef exec berks vendor} end -desc 'Install required Gems and Cookbooks' -task prepare: ['prepare:bundle', 'prepare:berks'] - -namespace :style do - task :rubocop do - sh %(chef exec rubocop) - end - - task :foodcritic do - sh %(chef exec foodcritic .) - end +desc "Get the gems installed" +task :bundle do + sh %(chef exec gem install -g) end -desc 'Run all style checks' -task style: ['style:foodcritic', 'style:rubocop'] - -namespace :integration do - task :kitchen do - sh %(chef exec kitchen test) - end +desc "Run FoodCritic (lint) tests" +task :lint do + sh %{chef exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .} end -task integration: ['integration:kitchen'] - -namespace :unit do - task :chefspec do - sh %(chef exec rspec test/unit/spec) - end +desc "Run RuboCop (style) tests" +task :style do + sh %{chef exec rubocop} end -desc 'Run all unit tests' -task unit: ['unit:chefspec'] -task spec: ['unit'] - -# Run all tests -desc 'Run all tests' -task test: ['style', 'unit', 'integration'] - -# The default rake task should just run it all -desc 'Install required Gems and Cookbook then run all tests' -task default: ['prepare', 'test'] - -begin - require 'kitchen/rake_tasks' - Kitchen::RakeTasks.new -rescue LoadError - puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI'] +desc "Run RSpec (unit) tests" +task :unit => [:berks_prep, :bundle] do + sh %{chef exec rspec --format documentation} +end + +desc "Remove the berks-cookbooks directory and the Berksfile.lock" +task :clean do + rm_rf [ + 'berks-cookbooks', + 'Berksfile.lock' + ] +end + +desc "Integration test" +task :integration => [:berks_prep, :bundle] do + sh %(chef exec kitchen test) end diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..fe49ef2 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,9 @@ +#!/bin/bash -x +## This script is for installing all the needed packages on trusty to run the chef tests with 'chef exec rake'. +## It relies on the common bootstrap.sh from openstack/cookbook-openstack-common for installing common dependencies. + +curl https://raw.githubusercontent.com/openstack/cookbook-openstack-common/master/bootstrap.sh \ + --retry 3 \ + --silent \ + --show-error \ + | /bin/bash -x diff --git a/spec/_example_nova_spec.rb b/spec/_example_nova_spec.rb index 90d464a..d7f5dd7 100644 --- a/spec/_example_nova_spec.rb +++ b/spec/_example_nova_spec.rb @@ -3,7 +3,7 @@ require_relative 'spec_helper' describe 'openstack_client::_example_nova' do - let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) } + let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } let(:node) { runner.node } let(:chef_run) { runner.converge(described_recipe) } @@ -17,7 +17,7 @@ describe 'openstack_client::_example_nova' do end describe 'openstack_client::_example_nova' do - let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) } + let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } let(:node) { runner.node } let(:chef_run) { runner.converge(described_recipe) } @@ -31,7 +31,7 @@ describe 'openstack_client::_example_nova' do end describe 'openstack_client::_example_nova' do - let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) } + let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } let(:node) { runner.node } let(:chef_run) { runner.converge(described_recipe) }