Skip to content

Commit

Permalink
Merge 40bdf16 into 2b8423b
Browse files Browse the repository at this point in the history
  • Loading branch information
miah committed May 29, 2019
2 parents 2b8423b + 40bdf16 commit 660ac81
Show file tree
Hide file tree
Showing 137 changed files with 3,308 additions and 3,418 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ Gemfile.local
TAGS
terraform.tfstate.backup
.terraform
.bundle
.gems
73 changes: 0 additions & 73 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,4 @@
---
AllCops:
Exclude:
- Gemfile
- Rakefile
- 'test/**/*'
- 'examples/plugins/train-*/test/**/*'
- 'vendor/**/*'
Documentation:
Enabled: false
AlignParameters:
Enabled: true
Encoding:
Enabled: false
HashSyntax:
Enabled: true
LineLength:
Enabled: false
EmptyLinesAroundBlockBody:
Enabled: false
MethodLength:
Max: 40
NumericLiterals:
MinDigits: 10
Metrics/CyclomaticComplexity:
Max: 10
Metrics/PerceivedComplexity:
Max: 10
Metrics/AbcSize:
Max: 33
Metrics/ModuleLength:
Enabled: false
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': '{}'
'%i': ()
'%q': '{}'
'%Q': ()
'%r': '{}'
'%s': ()
'%w': '{}'
'%W': ()
'%x': ()
Style/AlignHash:
Enabled: false
Style/PredicateName:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Style/ConditionalAssignment:
Enabled: false
Style/BracesAroundHashParameters:
Enabled: false
Style/AndOr:
Enabled: false
Style/Not:
Enabled: false
Style/FileName:
Enabled: false
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma
Style/NegatedIf:
Enabled: false
Style/UnlessElse:
Enabled: false
BlockDelimiters:
Enabled: false
Style/SpaceAroundOperators:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
SignalException:
Enabled: false
38 changes: 19 additions & 19 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# encoding: utf-8
source 'https://rubygems.org'
gemspec name: 'train'
source "https://rubygems.org"
gemspec name: "train"

group :test do
gem 'coveralls', require: false
gem 'minitest', '~> 5.8'
gem 'rake', '~> 10' # @todo bump this when we bump rubocop
gem 'rubocop', '~> 0.36.0'
gem 'simplecov', '~> 0.10'
gem 'concurrent-ruby', '~> 1.0'
gem 'pry-byebug'
gem 'm'
gem "coveralls", require: false
gem "minitest", "~> 5.8"
gem "rake", "~> 10"
gem "chefstyle"
gem "simplecov", "~> 0.10"
gem "concurrent-ruby", "~> 1.0"
gem "pry-byebug"
gem "m"
# This is not a true gem installation
# (Gem::Specification.find_by_path('train-gem-fixture') will return nil)
# but it's close enough to show the gempath handler can find a plugin
# See test/unit/
gem 'train-test-fixture', path: 'test/fixtures/plugins/train-test-fixture'
gem "train-test-fixture", path: "test/fixtures/plugins/train-test-fixture"
end

group :integration do
gem 'berkshelf', '>= 6.3.4'
gem 'test-kitchen', '>= 1.2.4'
gem 'kitchen-vagrant'
gem 'ed25519' # ed25519 ssh key support
gem 'bcrypt_pbkdf' # ed25519 ssh key support
gem "berkshelf", ">= 6.3.4"
gem "test-kitchen", ">= 1.2.4"
gem "kitchen-vagrant"
gem "ed25519" # ed25519 ssh key support
gem "bcrypt_pbkdf" # ed25519 ssh key support
end

group :tools do
gem 'pry', '~> 0.10'
gem 'rb-readline'
gem 'license_finder'
gem "pry", "~> 0.10"
gem "rb-readline"
gem "license_finder"
end

# add these additional dependencies into Gemfile.local
Expand Down
59 changes: 27 additions & 32 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,45 @@
#!/usr/bin/env rake
# encoding: utf-8

require 'bundler'
require 'bundler/gem_helper'
require 'rake/testtask'
require 'rubocop/rake_task'
require "bundler"
require "bundler/gem_helper"
require "rake/testtask"
require "chefstyle"
require "rubocop/rake_task"

Bundler::GemHelper.install_tasks name: 'train'
Bundler::GemHelper.install_tasks name: "train"

# Rubocop
desc 'Run Rubocop lint checks'
task :rubocop do
RuboCop::RakeTask.new
RuboCop::RakeTask.new(:lint) do |task|
task.options << "--display-cop-names"
end

# lint the project
desc 'Run robocop linter'
task lint: [:rubocop]

#
# run tests
task default: [:test, :lint]

Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/unit/**/*_test.rb'
t.libs << "test"
t.pattern = "test/unit/**/*_test.rb"
t.warning = false
t.verbose = true
t.ruby_opts = ['--dev'] if defined?(JRUBY_VERSION)
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
end

namespace :test do
task :docker do
path = File.join(File.dirname(__FILE__), 'test', 'integration')
sh('sh', '-c', "cd #{path} && ruby -I ../../lib docker_test.rb tests/*")
path = File.join(File.dirname(__FILE__), "test", "integration")
sh("sh", "-c", "cd #{path} && ruby -I ../../lib docker_test.rb tests/*")
end

task :windows do
Dir.glob('test/windows/*_test.rb').all? do |file|
sh(Gem.ruby, '-w', '-I .\test\windows', file)
end or fail 'Failures'
Dir.glob("test/windows/*_test.rb").all? do |file|
sh(Gem.ruby, "-w", '-I .\test\windows', file)
end || raise("Failures")
end

task :vm do
concurrency = ENV['CONCURRENCY'] || 4
path = File.join(File.dirname(__FILE__), 'test', 'integration')
sh('sh', '-c', "cd #{path} && kitchen test -c #{concurrency}")
concurrency = ENV["CONCURRENCY"] || 4
path = File.join(File.dirname(__FILE__), "test", "integration")
sh("sh", "-c", "cd #{path} && kitchen test -c #{concurrency}")
end

# Target required:
Expand All @@ -59,15 +54,15 @@ namespace :test do
# Run with a specific test:
# test=path_block_device_test.rb rake "test:ssh[user@server]"
task :ssh, [:target] do |t, args|
path = File.join(File.dirname(__FILE__), 'test', 'integration')
key_files = ENV['key_files'] || File.join(ENV['HOME'], '.ssh', 'id_rsa')
path = File.join(File.dirname(__FILE__), "test", "integration")
key_files = ENV["key_files"] || File.join(ENV["HOME"], ".ssh", "id_rsa")

sh_cmd = "cd #{path} && target=#{args[:target]} key_files=#{key_files}"
sh_cmd = "cd #{path} && target=#{args[:target]} key_files=#{key_files}"

sh_cmd += " debug=#{ENV['debug']}" if ENV['debug']
sh_cmd += ' ruby -I ../../lib test_ssh.rb tests/'
sh_cmd += ENV['test'] || '*'
sh_cmd += " debug=#{ENV['debug']}" if ENV["debug"]
sh_cmd += " ruby -I ../../lib test_ssh.rb tests/"
sh_cmd += ENV["test"] || "*"

sh('sh', '-c', sh_cmd)
sh("sh", "-c", sh_cmd)
end
end
6 changes: 3 additions & 3 deletions contrib/fixup_requiretty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
# (unless you set TRAIN_SUDO_VERY_MUCH=yes)

# FIXME
user = ENV['TRAIN_SUDO_USER'] || 'todo-some-clever-default-maybe-current-user'
user = ENV["TRAIN_SUDO_USER"] || "todo-some-clever-default-maybe-current-user"
sudoer = "/etc/sudoers.d/#{user}"

log "Warning: a sudoers configuration for user #{user} already exists, "\
'doing nothing (override with TRAIN_SUDO_VERY_MUCH=yes)' do
"doing nothing (override with TRAIN_SUDO_VERY_MUCH=yes)" do
only_if "test -f #{sudoer} || grep #{user} /etc/sudoers"
end

file sudoer do
content "#{user} ALL=(root) NOPASSWD:ALL\n"\
"Defaults:#{user} !requiretty\n"
mode 0600
action ENV['TRAIN_SUDO_VERY_MUCH'] == 'yes' ? :create : :create_if_missing
action ENV["TRAIN_SUDO_VERY_MUCH"] == "yes" ? :create : :create_if_missing

# Do not add something here if the user is mentioned explicitly in /etc/sudoers
not_if "grep #{user} /etc/sudoers"
Expand Down
14 changes: 7 additions & 7 deletions examples/plugins/train-local-rot13/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8

source 'https://rubygems.org'
source "https://rubygems.org"

# This is Gemfile, which is used by bundler
# to ensure a coherent set of gems is installed.
Expand All @@ -12,10 +12,10 @@ gemspec

# Remaining group is only used for development.
group :development do
gem 'bundler'
gem 'byebug'
gem 'inspec', '>= 2.2.112' # We need InSpec for the test harness while developing.
gem 'minitest'
gem 'rake'
gem 'rubocop', '= 0.49.1' # Need to keep in sync with main InSpec project, so config files will work
gem "bundler"
gem "byebug"
gem "inspec", ">= 2.2.112" # We need InSpec for the test harness while developing.
gem "minitest"
gem "rake"
gem "rubocop", "= 0.49.1" # Need to keep in sync with main InSpec project, so config files will work
end
18 changes: 9 additions & 9 deletions examples/plugins/train-local-rot13/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

# This task template will make a task named 'test', and run
# the tests that it finds.
require 'rake/testtask'
require "rake/testtask"

Rake::TestTask.new do |t|
t.libs.push 'lib'
t.libs.push "lib"
t.test_files = FileList[
'test/unit/*_test.rb',
'test/integration/*_test.rb',
'test/functional/*_test.rb',
"test/unit/*_test.rb",
"test/integration/*_test.rb",
"test/functional/*_test.rb",
]
t.verbose = true
# Ideally, we'd run tests with warnings enabled,
Expand All @@ -27,15 +27,15 @@ end
#------------------------------------------------------------------#
# Code Style Tasks
#------------------------------------------------------------------#
require 'rubocop/rake_task'
require "rubocop/rake_task"

RuboCop::RakeTask.new(:lint) do |t|
# Choices of rubocop rules to enforce are deeply personal.
# Here, we set things up so that your plugin will use the Bundler-installed
# train gem's copy of the Train project's rubocop.yml file (which
# is indeed packaged with the train gem).
require 'train/globals'
train_rubocop_yml = File.join(Train.src_root, '.rubocop.yml')
require "train/globals"
train_rubocop_yml = File.join(Train.src_root, ".rubocop.yml")

t.options = ['--display-cop-names', '--config', train_rubocop_yml]
t.options = ["--display-cop-names", "--config", train_rubocop_yml]
end
8 changes: 4 additions & 4 deletions examples/plugins/train-local-rot13/lib/train-local-rot13.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)

# It's traditional to keep your gem version in a separate file, so CI can find it easier.
require 'train-local-rot13/version'
require "train-local-rot13/version"

# A train plugin has three components: Transport, Connection, and Platform.
# Transport acts as the glue.
require 'train-local-rot13/transport'
require 'train-local-rot13/platform'
require 'train-local-rot13/connection'
require "train-local-rot13/transport"
require "train-local-rot13/platform"
require "train-local-rot13/connection"
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
# You don't have to worry about most of this.

# This allow us to inherit from Train::Plugins::Transport::BaseConnection
require 'train'
require "train"

# Push platform detection out to a mixin, as it tends
# to develop at a different cadence than the rest
require 'train-local-rot13/platform'
require "train-local-rot13/platform"

# This is a support library for our file content meddling
require 'train-local-rot13/file_content_rotator'
require "train-local-rot13/file_content_rotator"

# This is a support library for our command meddling
require 'mixlib/shellout'
require 'ostruct'
require "mixlib/shellout"
require "ostruct"

module TrainPlugins
module LocalRot13
Expand Down Expand Up @@ -74,7 +74,7 @@ def run_command_via_connection(cmd)
# And meddle with the stdout along the way.
stdout: Rot13.rotate(run_result.stdout),
stderr: run_result.stderr,
exit_status: run_result.exitstatus,
exit_status: run_result.exitstatus
)
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Here's our helper class for the file object. This is just some
# silliness specific to the task of applying rot13 to the file content.

require 'rot13'
require "rot13"

module TrainPlugins
module LocalRot13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def platform
# This plugin makes up a new platform. Train (or rather InSpec) only
# know how to read files on Windows and Un*x (MacOS is a kind of Un*x),
# so we'll say we're part of those families.
Train::Platforms.name('local-rot13').in_family('unix')
Train::Platforms.name('local-rot13').in_family('windows')
Train::Platforms.name("local-rot13").in_family("unix")
Train::Platforms.name("local-rot13").in_family("windows")

# When you know you will only ever run on your dedicated platform
# (for example, a plugin named train-aws would only run on the AWS
Expand All @@ -32,7 +32,7 @@ def platform
# Use release to report a version number. You might use the version
# of the plugin, or a version of an important underlying SDK, or a
# version of a remote API.
force_platform!('local-rot13', release: TrainPlugins::LocalRot13::VERSION)
force_platform!("local-rot13", release: TrainPlugins::LocalRot13::VERSION)
end
end
end
Loading

0 comments on commit 660ac81

Please sign in to comment.