-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Syntax/lint checks / unit tests / integration tests
- Loading branch information
Showing
22 changed files
with
496 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*~ | ||
*# | ||
.#* | ||
\#*# | ||
.*.sw[a-z] | ||
*.un~ | ||
|
||
Berksfile.lock | ||
Gemfile.lock | ||
.vagrant | ||
Vagrantfile | ||
.bundle | ||
.coverage | ||
.kitchen | ||
.kitchen.local.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
driver_plugin: vagrant | ||
driver_config: | ||
require_chef_omnibus: true | ||
|
||
platforms: | ||
# - name: ubuntu-12.04 | ||
# driver_config: | ||
# box: opscode-ubuntu-12.04 | ||
# box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box | ||
- name: ubuntu-13.04 | ||
driver_config: | ||
box: opscode-ubuntu-13.04 | ||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box | ||
|
||
suites: | ||
- name: default | ||
run_list: | ||
- recipe[pdepend::default] | ||
attributes: | ||
pdepend: | ||
install_method: composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
AlignParameters: | ||
Enabled: false | ||
|
||
Encoding: | ||
Enabled: false | ||
|
||
LineLength: | ||
Max: 200 | ||
|
||
HashSyntax: | ||
EnforcedStyle: hash_rockets | ||
|
||
RedundantBegin: | ||
Enabled: false | ||
|
||
UselessAssignment: | ||
Enabled: false | ||
|
||
MethodLength: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
language: ruby | ||
|
||
rvm: | ||
- 1.9.3 | ||
- 2.0.0 | ||
- 2.1.0 | ||
|
||
before_script: | ||
- bundle exec berks install | ||
|
||
script: | ||
- bundle exec rake travis | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
notifications: | ||
email: | ||
- [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
site :opscode | ||
|
||
metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Contributing | ||
========= | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. [Add tests for your changes](https://github.com/escapestudios-cookbooks/pdepend/blob/master/TESTING.md) | ||
4. Push your changes to your feature branch (`git push origin my-new-feature`) | ||
5. Create a new Pull Request (PR) | ||
|
||
## Testing | ||
Contributions will only be accepted if they are fully tested as specified in [TESTING.md](https://github.com/escapestudios-cookbooks/pdepend/blob/master/TESTING.md). | ||
|
||
## metadata.rb | ||
Please do not modify the version number in the metadata.rb; not all changes to the cookbook may be merged and released in the same version. We will handle the version updates during the release process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'rake' | ||
|
||
group :lint do | ||
gem 'rubocop', '~> 0.18' | ||
gem 'foodcritic', '~> 3.0' | ||
end | ||
|
||
group :unit, :integration do | ||
gem 'berkshelf', '~> 2.0' | ||
end | ||
|
||
group :unit do | ||
gem 'chefspec', '~> 3.1' | ||
end | ||
|
||
group :integration do | ||
gem 'test-kitchen', '~> 1.2' | ||
gem 'kitchen-vagrant', '~> 0.11' | ||
gem 'serverspec', '~> 1.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,9 +48,9 @@ References | |
License and Authors | ||
=================== | ||
|
||
Author: David Joos <[email protected]> | ||
Author: David Joos <david.joos@escapestudios.com> | ||
Author: Escape Studios Development <[email protected]> | ||
Copyright: 2013, Escape Studios | ||
Copyright: 2013-2014, Escape Studios | ||
|
||
Unless otherwise noted, all files are released under the MIT license, | ||
possible exceptions will contain licensing information in them. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'rspec/core/rake_task' | ||
|
||
# syntax/lint checks: RuboCop & Foodcritic | ||
namespace :lint do | ||
require 'rubocop/rake_task' | ||
require 'foodcritic' | ||
|
||
desc 'Run Ruby syntax/lint checks' | ||
Rubocop::RakeTask.new(:ruby) | ||
|
||
desc 'Run Chef syntax/lint checks' | ||
FoodCritic::Rake::LintTask.new(:chef) do |task| | ||
task.options = { | ||
:tags => ['~FC048'], | ||
:fail_tags => ['any'] | ||
} | ||
end | ||
end | ||
|
||
desc 'Run all syntax/lint checks' | ||
task :lint => ['lint:ruby', 'lint:chef'] | ||
|
||
# unit testing: ChefSpec | ||
desc 'Run RSpec and ChefSpec unit tests' | ||
RSpec::Core::RakeTask.new(:unit) | ||
|
||
# integration testing: Test Kitchen | ||
namespace :integration do | ||
require 'kitchen' | ||
|
||
desc 'Run Test Kitchen integration tests with Vagrant' | ||
task :vagrant do | ||
Kitchen.logger = Kitchen.default_file_logger | ||
Kitchen::Config.new.instances.each do |instance| | ||
instance.test(:always) | ||
end | ||
end | ||
end | ||
|
||
desc 'Run all integration tests' | ||
task :integration => ['integration:vagrant'] | ||
|
||
# Travic CI | ||
desc 'Run tests on Travis CI' | ||
task :travis => [:lint, :unit] | ||
|
||
# the default rake task should just run it all | ||
task :default => [:lint, :unit, :integration] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Testing the cookbook | ||
==================== | ||
|
||
Contributions to this cookbook will only be accepted if all tests pass successfully: | ||
|
||
* Ruby syntax/lint checks: [RuboCop](http://batsov.com/rubocop/) | ||
* Chef syntax/lint checks: [Foodcritic](http://acrmp.github.io/foodcritic/) | ||
* Unit tests: [ChefSpec](http://code.sethvargo.com/chefspec/) | ||
* Integration tests: [Test Kitchen](http://kitchen.ci/) | ||
|
||
Setting up the test environment | ||
------------------------------- | ||
|
||
Install the latest version of [Vagrant](http://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads) (free) or [VMWare Fusion](http://www.vmware.com/products/fusion) (paid). | ||
|
||
Clone the latest version of the cookbook from the repository. | ||
|
||
git clone [email protected]:escapestudios-cookbooks/pdepend.git | ||
cd pdepend | ||
|
||
Install the gems used for testing: | ||
|
||
bundle install | ||
|
||
Install the berkshelf plugin for vagrant: | ||
|
||
vagrant plugin install vagrant-berkshelf | ||
|
||
Running syntax/lint checks | ||
-------------------------- | ||
|
||
bundle exec rake lint | ||
|
||
Running unit tests | ||
------------------ | ||
|
||
bundle exec rake unit | ||
|
||
Running integration tests | ||
------------------------- | ||
|
||
bundle exec rake integration | ||
|
||
Running all checks/tests | ||
------------------------ | ||
|
||
bundle exec rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# encoding: utf-8 | ||
|
||
require 'bundler' | ||
require 'bundler/setup' | ||
require 'berkshelf/thor' | ||
|
||
class Default < Thor | ||
attr_reader :cookbook_name | ||
attr_reader :cookbook_category | ||
|
||
def initialize(*args) | ||
@cookbook_name = "pdepend" | ||
@cookbook_category = "Utilities" | ||
|
||
super(*args) | ||
end | ||
|
||
class_option :verbose, | ||
:type => :boolean, | ||
:aliases => "-v", | ||
:default => false | ||
|
||
method_option :knife_config, | ||
:type => :string, | ||
:aliases => "-c", | ||
:desc => "Path to your knife configuration file", | ||
:default => "~/.chef/knife.rb" | ||
|
||
desc "release", "Create a tag from metadata version and push to the community site." | ||
def release | ||
unless clean? | ||
say "Sorry, there are files that need to be committed first.", :red | ||
exit 1 | ||
end | ||
|
||
tag_version{ publish_cookbook(options) } | ||
end | ||
|
||
private | ||
def current_version | ||
Berkshelf::CachedCookbook.from_path(source_root).version | ||
end | ||
|
||
def clean? | ||
sh_with_excode("git diff --exit-code")[1] == 0 | ||
end | ||
|
||
def tag_version | ||
sh "git tag -a -m \"#{current_version}\" #{current_version}" | ||
say "Tagged: #{current_version}", :green | ||
yield if block_given? | ||
sh "git push --tags" | ||
rescue => e | ||
say "Untagging: #{current_version} due to error", :red | ||
sh_with_excode "git tag -d #{current_version}" | ||
say e , :red | ||
say "Please increase the version in metadata.rb", :red | ||
exit 1 | ||
end | ||
|
||
def publish_cookbook(options) | ||
cmd = "knife cookbook site share #{cookbook_name} \"#{cookbook_category}\" -o #{source_root.join("..")} -c #{options[:knife_config]}" | ||
cmd << " -V" if options[:verbose] | ||
sh cmd | ||
say "Version #{current_version} of the #{cookbook_name} cookbook has been uploaded to the Opscode community site.", :green | ||
end | ||
|
||
def source_root | ||
Pathname.new File.dirname(File.expand_path(__FILE__)) | ||
end | ||
|
||
def sh(cmd, dir = source_root, &block) | ||
out, code = sh_with_excode(cmd, dir, &block) | ||
code == 0 ? out : raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out) | ||
end | ||
|
||
def sh_with_excode(cmd, dir = source_root, &block) | ||
cmd << " 2>&1" | ||
outbuf = '' | ||
|
||
Dir.chdir(dir) { | ||
outbuf = `#{cmd}` | ||
if $? == 0 | ||
block.call(outbuf) if block | ||
end | ||
} | ||
|
||
[ outbuf, $? ] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.