Skip to content

Commit

Permalink
QA
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitsuru Y committed May 24, 2017
1 parent 789bfaf commit 9ae538b
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 55 deletions.
51 changes: 51 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
inherit_from: .rubocop_todo.yml

AllCops:
Exclude:
# there is no reason to test external files
- "roles.galaxy/**/*"
- "vendor/**/*"
- "tests/integration/**/roles/*"
- "qansible"
# enable detailed explanations available in cops
# the default output is not enough to understand what is wrong
DisplayCopNames: true
ExtraDetails: true
DisplayStyleGuide: true

Style/StringLiterals:
# https://github.com/reallyenglish/ansible-role-example/issues/60#issuecomment-280573231
EnforcedStyle: double_quotes

Style/SymbolArray:
# perefer brackets for `grep-ability`
EnforcedStyle: brackets

Metrics/BlockLength:
Exclude:
# Vagrantfile is not application code, rather, configuration file and
# blocks in it tends to be long
- "**/Vagrantfile"
ExcludedMethods:
# these two exclude long blocks in `_spec.rb`
- describe
- context

Metrics/LineLength:
Exclude:
# `_spec.rb` often contains one-liner shell command
- "**/*_spec.rb"
# same as in Metrics/BlockLength
- "**/Vagrantfile"
# Gemfile is not application code
- "Gemfile"
# ignore heredoc for readability
AllowHeredoc: true
# URLs are almost always long
AllowURI: true
URISchemes:
- http
- https
- git
- ftp
IgnoreCopDirectives: true
204 changes: 204 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-05-24 11:17:13 +0900 using RuboCop version 0.48.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Lint/DuplicateMethods:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 2
Lint/Void:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 1
Metrics/AbcSize:
Max: 21

# Offense count: 5
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 132

# Offense count: 3
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 21

# Offense count: 1
# Cop supports --auto-correct.
Style/AlignArray:
Exclude:
- 'tests/integration/example/Vagrantfile'

# Offense count: 1
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Style/EmptyLineBetweenDefs:
Exclude:
- 'tests/integration/example/Vagrantfile'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundBlockBody:
Exclude:
- 'tests/integration/example/Vagrantfile'
- 'tests/integration/example/spec/default_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
Style/EmptyLinesAroundClassBody:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Style/ExtraSpacing:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'tests/integration/example/Rakefile'
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: both, prefix, postfix
Style/NegatedIf:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/Not:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'tests/integration/example/Rakefile'
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/ParallelAssignment:
Exclude:
- 'tests/integration/example/Vagrantfile'
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'tests/integration/example/Rakefile'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AllowIfMethodIsEmpty.
Style/SingleLineMethods:
Exclude:
- 'tests/integration/example/Vagrantfile'

# Offense count: 4
# Cop supports --auto-correct.
Style/SpaceBeforeSemicolon:
Exclude:
- 'tests/integration/example/Vagrantfile'

# Offense count: 14
# Cop supports --auto-correct.
Style/SpaceInsideBrackets:
Exclude:
- 'tests/integration/example/Rakefile'
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 4
# Cop supports --auto-correct.
Style/SpaceInsidePercentLiteralDelimiters:
Exclude:
- 'tests/integration/example/Rakefile'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceInsideStringInterpolation:
Exclude:
- 'tests/integration/example/spec/default_spec.rb'

# Offense count: 66
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'tests/integration/example/Rakefile'
- 'tests/integration/example/Vagrantfile'
- 'tests/integration/example/spec/default_spec.rb'
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: respond_to, define_method
Style/SymbolProc:
Exclude:
- 'tests/integration/example/Rakefile'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
Style/TrivialAccessors:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/UnneededInterpolation:
Exclude:
- 'tests/integration/example/spec/spec_helper.rb'
16 changes: 15 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ install:
- ansible --version

# Create ansible.cfg with correct roles_path
- mkdir -p extra_roles
- printf '[defaults]\nroles_path=../:extra_roles' >ansible.cfg

script:
Expand All @@ -44,6 +45,11 @@ script:

# download the QA scripts
- git clone https://github.com/trombik/qansible.git

# checkout the latest release
- ( cd qansible && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) )

# install it
- ( cd qansible && bundle install --path vendor/bundle --with "test" && bundle exec rake build && gem install pkg/*.gem )
- rm -rf qansible

Expand All @@ -54,8 +60,16 @@ script:
# surpress a warning from `qansible qa
- touch .kitchen.local.yml

# run the QA test
# export PATH
- export PATH="${PATH}:`rvm gemdir`/bin"

# bundle up because rubocop is installed via Gemfile
- bundle install --path vendor/bundle

# run rubocop
- bundle exec rubocop

# run the QA test
- qansible qa

notifications:
Expand Down
30 changes: 14 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
source 'https://rubygems.org'
source "https://rubygems.org"

# rack 2.x requires ruby >= 2.2.2
gem 'rack', '~> 1.6.4'

gem 'rake', '~> 11.1.2'
gem 'rspec', '~> 3.4.0'
gem "test-kitchen", '~> 1.6.0'
gem "kitchen-vagrant", '~> 0.19.0'
# use patched kitchen-ansible
gem "kitchen-ansible", '~> 0.40.1', :git => 'https://github.com/trombik/kitchen-ansible.git', :branch => 'freebsd_support'
gem "kitchen-sync", '~> 2.1.1', :git => 'https://github.com/trombik/kitchen-sync.git', :branch => 'without_full_path_to_rsync'
gem 'kitchen-verifier-shell', '~> 0.2.0'
gem 'kitchen-verifier-serverspec', '~> 0.3.0'
gem 'infrataster', '~> 0.3.2', :git => 'https://github.com/trombik/infrataster.git', :branch => 'reallyenglish'
gem 'serverspec', '~> 2.37.2'
gem 'specinfra', '>= 2.63.2' # OpenBSD's `port` is fixed in this version
gem "infrataster", "~> 0.3.2", git: "https://github.com/trombik/infrataster.git", branch: "reallyenglish"
gem "kitchen-ansible", "~> 0.40.1", git: "https://github.com/trombik/kitchen-ansible.git", branch: "freebsd_support" # use patched kitchen-ansible
gem "kitchen-sync", "~> 2.1.1", git: "https://github.com/trombik/kitchen-sync.git", branch: "without_full_path_to_rsync"
gem "kitchen-vagrant", "~> 0.20.0"
gem "kitchen-verifier-serverspec", "~> 0.3.0"
gem "kitchen-verifier-shell", "~> 0.2.0"
gem "rack", "~> 1.6.4" # rack 2.x requires ruby >= 2.2.2
gem "rake", "~> 11.1.2"
gem "rspec", "~> 3.4.0"
gem "rubocop", "~> 0.47.1"
gem "serverspec", "~> 2.37.2"
gem "specinfra", ">= 2.63.2" # OpenBSD's `port` is fixed in this version
gem "test-kitchen", "~> 1.6.0"
48 changes: 24 additions & 24 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
require 'pathname'
require "pathname"

root_dir = Pathname.new(__FILE__).dirname
integration_test_dir = root_dir + 'tests' + 'integration'
integration_test_dirs = Pathname.new(integration_test_dir).children.select { |c| c.directory? }
integration_test_dir = root_dir + "tests" + "integration"
integration_test_dirs = Pathname.new(integration_test_dir)
.children.select(&:directory?)

task default: %w[ test ]
task default: %w(test)

desc 'run all tests'
desc "run all tests"
task :test do
integration_test_dirs.each do |d|
rakefile = d + 'Rakefile'
if rakefile.exist? and rakefile.file?
rakefile = d + "Rakefile"
if rakefile.exist? && rakefile.file?
Dir.chdir(d) do
puts "entering to %s" % [ d ]
puts format("entering to %s", d)
begin
puts 'running rake'
sh 'rake'
puts "running rake"
sh "rake"
ensure
sh 'rake clean'
sh "rake clean"
end
end
else
puts 'Rakefile does not exist, skipping'
puts "Rakefile does not exist, skipping"
end
end
end

task :clean do
integration_test_dirs.each do |d|
rakefile = d + 'Rakefile'
if rakefile.exist? and rakefile.file?
Dir.chdir(d) do
puts "entering to %s" % [ d ]
begin
puts 'running rake clean'
sh 'rake clean'
rescue Exception => e
puts 'rake clean clean failed:'
puts e.message
puts e.backtrace.inspect
end
rakefile = d + "Rakefile"
next unless rakefile.exist? && rakefile.file?
Dir.chdir(d) do
puts format("entering to %s", d)
begin
puts "running rake clean"
sh "rake clean"
rescue StandardError => e
puts "rake clean clean failed:"
puts e.message
puts e.backtrace.inspect
end
end
end
Expand Down
Loading

0 comments on commit 9ae538b

Please # to comment.