Skip to content

Commit 2a35077

Browse files
committed
Update Gemfile dependencies and Kitchen platforms
1 parent d0f2e6b commit 2a35077

File tree

13 files changed

+209
-99
lines changed

13 files changed

+209
-99
lines changed

.kitchen.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ provisioner:
88
platforms:
99
- name: ubuntu-12.04
1010
- name: ubuntu-14.04
11-
- name: debian-7.4
12-
- name: centos-6.4
13-
- name: fedora-19
11+
- name: ubuntu-15.04
12+
- name: debian-7.8
13+
- name: debian-8.1
14+
- name: centos-6.7
15+
- name: fedora-20
16+
- name: fedora-21
1417

1518
suites:
1619
- name: default

.travis.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
rvm:
2-
- 1.9.3
3-
- 2.0.0
4-
- 2.1
2+
- 1.9.3
3+
- 2.0.0
4+
- 2.1
5+
- 2.2
6+
57
sudo: false
8+
69
env:
7-
- CHEF_VERSION="~> 11.0"
8-
- CHEF_VERSION="~> 12.0"
10+
- CHEF_VERSION="~> 11.0"
11+
- CHEF_VERSION="~> 12.0"
12+
913
matrix:
1014
exclude:
11-
- rvm: 1.9.3
12-
env: CHEF_VERSION="~> 12.0"
13-
bundler_args: --without integration integration_cloud guard
15+
# Chef 12 requires Ruby 2:
16+
- rvm: 1.9.3
17+
env: CHEF_VERSION="~> 12.0"
18+
# Chef 11 cannot resolve dependencies in Ruby 2.2 (mixlib-shellout):
19+
- rvm: 2.2
20+
env: CHEF_VERSION="~> 11.0"
21+
22+
bundler_args: --without doc integration integration_docker integration_vagrant integration_cloud guard
23+
1424
script:
15-
- bundle exec rake travis:ci
25+
- travis_retry bundle exec rake style unit

Berksfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ metadata
2222
# Minitest Chef Handler
2323
# More info at https://github.com/calavera/minitest-chef-handler
2424
if ::File.directory?(::File.join('files', 'default', 'tests', 'minitest')) ||
25-
::File.directory?(::File.join(
26-
'test', 'cookbooks', "#{my_cookbook}_test", 'files', 'default', 'tests',
27-
'minitest'
28-
))
25+
::File.directory?(
26+
::File.join(
27+
'test', 'cookbooks', "#{my_cookbook}_test", 'files', 'default', 'tests',
28+
'minitest'
29+
)
30+
)
2931
cookbook 'minitest-handler'
3032
end
3133

Gemfile

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,62 @@
22
# -*- mode: ruby -*-
33
# vi: set ft=ruby :
44

5+
# More info at http://bundler.io/gemfile.html
6+
57
source 'https://rubygems.org'
68

79
chef_version = ENV.key?('CHEF_VERSION') ? ENV['CHEF_VERSION'] : nil
810

11+
group :doc do
12+
gem 'yard', '~> 0.8'
13+
end
14+
915
group :test do
1016
gem 'rake'
11-
gem 'berkshelf', '~> 3.2'
17+
gem 'berkshelf', '~> 3.1'
1218
end
1319

1420
group :style do
1521
gem 'foodcritic', '= 4.0.0'
16-
gem 'rubocop', '= 0.28.0'
22+
gem 'rubocop', '= 0.33.0'
1723
end
1824

1925
group :unit do
2026
gem 'chef', chef_version unless chef_version.nil? # Ruby 1.9.3 support
27+
gem 'simplecov', '~> 0.9'
2128
gem 'should_not', '~> 1.1'
22-
gem 'chefspec', '~> 4.2'
29+
gem 'chefspec', '~> 4.1'
30+
gem 'chef-vault', '~> 2.4'
31+
gem 'ohai', '~> 7.4' if RUBY_VERSION < '2'
2332
end
2433

2534
group :integration do
35+
gem 'test-kitchen', '~> 1.4'
36+
end
37+
38+
group :integration_docker do
39+
gem 'kitchen-docker', '~> 2.1'
40+
end
41+
42+
group :integration_vagrant do
2643
gem 'vagrant-wrapper', '~> 2.0'
27-
gem 'test-kitchen', '~> 1.2'
28-
gem 'kitchen-vagrant', '~> 0.15'
44+
gem 'kitchen-vagrant', '~> 0.10'
2945
end
3046

31-
group :integration, :integration_cloud do
47+
group :integration_cloud do
3248
gem 'kitchen-ec2', '~> 0.8'
3349
gem 'kitchen-digitalocean', '~> 0.8'
3450
end
3551

3652
group :guard do
37-
gem 'guard', '~> 2.6', '< 2.8'
38-
gem 'guard-foodcritic', '~> 1.0'
53+
gem 'guard', '~> 2.12'
54+
gem 'guard-foodcritic', '~> 1.1'
3955
gem 'guard-rubocop', '~> 1.2'
40-
gem 'guard-rspec', '~> 4.3', '< 4.5'
41-
gem 'guard-kitchen', '~> 0.0'
56+
gem 'guard-rspec', '~> 4.6'
57+
# Temporary disabled: Error is: cannot load such file -- guard/kitchen
58+
# gem 'guard-kitchen', '~> 0.0.0'
59+
end
60+
61+
group :travis do
62+
gem 'coveralls', '~> 0.7', require: false
4263
end

Guardfile

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
group :style,
1313
halt_on_fail: true do
1414
guard :foodcritic,
15-
cli: '--exclude spec',
15+
cli: '--exclude test/unit',
1616
cookbook_paths: '.',
1717
all_on_start: false do
18-
watch(/attributes\/.+\.rb$/)
19-
watch(/definitions\/.+\.rb$/)
20-
watch(/libraries\/.+\.rb$/)
21-
watch(/providers\/.+\.rb$/)
22-
watch(/recipes\/.+\.rb$/)
23-
watch(/resources\/.+\.rb$/)
24-
watch(/templates\/.+\.erb$/)
18+
watch(%r{attributes/.+\.rb$})
19+
watch(%r{definitions/.+\.rb$})
20+
watch(%r{libraries/.+\.rb$})
21+
watch(%r{providers/.+\.rb$})
22+
watch(%r{recipes/.+\.rb$})
23+
watch(%r{resources/.+\.rb$})
24+
watch(%r{templates/.+\.erb$})
2525
watch('metadata.rb')
2626
end
2727

@@ -43,51 +43,49 @@ end # group style
4343

4444
# Unit Tests
4545
# ==========
46-
# - spec/unit/${library}_spec.rb: Unit tests for libraries.
47-
# - spec/functional/${library}_spec.rb: Functional tests for libraries.
48-
# - spec/integration/${library}_spec.rb: Integration tests for libraries.
49-
# - spec/recipes/${recipe}_spec.rb: ChefSpec tests for recipes.
50-
# - spec/resources/${resource}_spec.rb: ChefSpec tests for resources.
46+
# - test/unit/libraries/${library}_spec.rb: Unit tests for libraries.
47+
# - test/unit/recipes/${recipe}_spec.rb: ChefSpec tests for recipes.
48+
# - test/unit/resources/${resource}_spec.rb: ChefSpec tests for resources.
49+
# - test/unit/templates/${template}_spec.rb: ChefSpec tests for templates.
5150

5251
group :unit do
5352
guard :rspec,
54-
cmd: 'bundle exec rspec',
53+
cmd: 'bundle exec rake unit',
5554
all_on_start: false do
56-
watch(/^libraries\/(.+)\.rb$/) do |m|
57-
[
58-
"spec/unit/#{m[1]}_spec.rb",
59-
"spec/functional/#{m[1]}_spec.rb",
60-
"spec/integration/#{m[1]}_spec.rb"
61-
]
55+
watch(%r{^libraries/(.+)\.rb$}) do |m|
56+
"test/unit/libraries/#{m[1]}_spec.rb"
6257
end
63-
watch(/^recipes\/(.+)\.rb$/) { |m| "spec/recipes/#{m[1]}_spec.rb" }
64-
watch(/^(?:providers|resources)\/(.+)\.rb$/) do |m|
65-
"spec/resources/#{m[1]}_spec.rb"
58+
watch(%r{^recipes/(.+)\.rb$}) { |m| "test/unit/recipes/#{m[1]}_spec.rb" }
59+
watch(%r{^(?:providers|resources)/(.+)\.rb$}) do |m|
60+
"test/unit/resources/#{m[1]}_spec.rb"
6661
end
67-
watch(/^spec\/.+_spec\.rb$/)
68-
watch('spec/spec_helper.rb') { 'spec' }
62+
watch(%r{^templates/(.+)\.rb$}) { 'test/unit/templates' }
63+
watch(%r{^test/unit/.+_spec\.rb$})
64+
watch('test/unit/spec_helper.rb') { 'spec' }
6965
end
7066
end # group unit
7167

7268
# Integration Tests
7369
# =================
7470
# - test-kitchen
71+
#
72+
# Temporary disabled. See the Gemfile.
7573

76-
group :integration do
77-
guard 'kitchen',
78-
all_on_start: false do
79-
watch(/attributes\/.+\.rb$/)
80-
watch(/definitions\/.+\.rb$/)
81-
watch(/libraries\/.+\.rb$/)
82-
watch(/providers\/.+\.rb$/)
83-
watch(/recipes\/.+\.rb$/)
84-
watch(/resources\/.+\.rb$/)
85-
watch(/files\/.+/)
86-
watch(/templates\/.+\.erb$/)
87-
watch('metadata.rb')
88-
watch(/test\/.+$/)
89-
watch('Berksfile')
90-
end
91-
end # group integration
74+
# group :integration do
75+
# guard 'kitchen',
76+
# all_on_start: false do
77+
# watch(%r{attributes/.+\.rb$})
78+
# watch(%r{definitions/.+\.rb$})
79+
# watch(%r{libraries/.+\.rb$})
80+
# watch(%r{providers/.+\.rb$})
81+
# watch(%r{recipes/.+\.rb$})
82+
# watch(%r{resources/.+\.rb$})
83+
# watch(%r{files/.+})
84+
# watch(%r{templates/.+\.erb$})
85+
# watch('metadata.rb')
86+
# watch(%r{test/.+$})
87+
# watch('Berksfile')
88+
# end
89+
# end # group integration
9290

9391
scope groups: [:style, :unit]

Rakefile

Lines changed: 94 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,119 @@
11
# encoding: UTF-8
22
# -*- mode: ruby -*-
33
# vi: set ft=ruby :
4-
# Based on magic_shell cookbook code, thanks @sethvargo.
54

6-
# More info at https://github.com/jimweirich/rake/blob/master/doc/rakefile.rdoc
5+
#
6+
# Available Rake tasks:
7+
#
8+
# $ rake -T
9+
# rake clean # Clean some generated files
10+
# rake default # Run doc, style, unit and integration tests
11+
# rake doc # Generate Ruby documentation
12+
# rake integration # Run Test Kitchen integration tests
13+
# rake integration:cloud # Run Test Kitchen tests in the cloud
14+
# rake integration:docker # Run Test Kitchen tests using docker
15+
# rake integration:vagrant # Run Test Kitchen tests using vagrant
16+
# rake style # Run all style checks
17+
# rake style:chef # Run Chef style checks using foodcritic
18+
# rake style:ruby # Run Ruby style checks using rubocop
19+
# rake style:ruby:auto_correct # Auto-correct RuboCop offenses
20+
# rake unit # Run ChefSpec unit tests
21+
# rake yard # Generate Ruby documentation using yard
22+
#
23+
# More info at https://github.com/ruby/rake/blob/master/doc/rakefile.rdoc
24+
#
725

826
require 'bundler/setup'
927

28+
# Checks if we are inside Travis CI.
29+
#
30+
# @return [Boolean] whether we are inside Travis CI.
31+
# @example
32+
# travis? #=> false
33+
def travis?
34+
ENV['TRAVIS'] == 'true'
35+
end
36+
37+
desc 'Clean some generated files'
38+
task :clean do
39+
%w(
40+
Berksfile.lock
41+
.bundle
42+
.cache
43+
Gemfile.lock
44+
.kitchen
45+
metadata.json
46+
).each { |f| FileUtils.rm_rf(Dir.glob(f)) }
47+
end
48+
49+
desc 'Generate Ruby documentation using yard'
50+
task :yard do
51+
require 'yard'
52+
YARD::Rake::YardocTask.new do |t|
53+
t.stats_options = %w(--list-undoc)
54+
end
55+
end
56+
57+
desc 'Generate Ruby documentation'
58+
task doc: %w(yard)
59+
1060
namespace :style do
1161
require 'rubocop/rake_task'
12-
desc 'Run Ruby style checks'
62+
desc 'Run Ruby style checks using rubocop'
1363
RuboCop::RakeTask.new(:ruby)
1464

1565
require 'foodcritic'
16-
desc 'Run Chef style checks'
66+
desc 'Run Chef style checks using foodcritic'
1767
FoodCritic::Rake::LintTask.new(:chef)
1868
end
1969

2070
desc 'Run all style checks'
2171
task style: %w(style:chef style:ruby)
2272

23-
require 'rspec/core/rake_task'
2473
desc 'Run ChefSpec unit tests'
25-
RSpec::Core::RakeTask.new(:unit) do |t|
26-
t.rspec_opts = '--color --format progress'
74+
task :unit do
75+
require 'rspec/core/rake_task'
76+
RSpec::Core::RakeTask.new(:unit) do |t|
77+
t.rspec_opts = '--color --format progress'
78+
t.pattern = 'spec/**{,/*/**}/*_spec.rb'
79+
end
2780
end
2881

29-
desc 'Run Test Kitchen integration tests'
30-
task :integration do
31-
require 'kitchen'
32-
Kitchen.logger = Kitchen.default_file_logger
33-
Kitchen::Config.new.instances.each do |instance|
34-
instance.test(:always)
82+
namespace :integration do
83+
def kitchen_config(loader_config = {})
84+
{}.tap do |config|
85+
unless loader_config.empty?
86+
@loader = Kitchen::Loader::YAML.new(loader_config)
87+
config[:loader] = @loader
88+
end
89+
end
90+
end
91+
92+
def run_kitchen(loader_config = {})
93+
require 'kitchen'
94+
Kitchen.logger = Kitchen.default_file_logger
95+
config = kitchen_config(loader_config)
96+
Kitchen::Config.new(config).instances.each { |i| i.test(:always) }
97+
end
98+
99+
desc 'Run Test Kitchen integration tests using vagrant'
100+
task :vagrant do
101+
run_kitchen
35102
end
36-
end
37103

38-
namespace :travis do
39-
desc 'Run tests on Travis'
40-
task ci: %w(style unit)
104+
desc 'Run Test Kitchen integration tests using docker'
105+
task :docker do
106+
run_kitchen(local_config: '.kitchen.docker.yml')
107+
end
108+
109+
desc 'Run Test Kitchen integration tests in the cloud'
110+
task :cloud do
111+
run_kitchen(local_config: '.kitchen.cloud.yml')
112+
end
41113
end
42114

43-
task default: %w(style unit integration)
115+
desc 'Run Test Kitchen integration tests'
116+
task integration: travis? ? %w(integration:docker) : %w(integration:vagrant)
117+
118+
desc 'Run doc, style, unit and integration tests'
119+
task default: %w(doc style unit integration)

TODO.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TODO
22
====
33

4-
* LVM support.
5-
* Support for resize unmounted file systems.
6-
* Add RSpec unit tests for libraries.
4+
* [ ] LVM support.
5+
* [ ] Support for resize unmounted file systems.
6+
* [ ] Add RSpec unit tests for libraries.

0 commit comments

Comments
 (0)