Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Add support for Ruby 3.0 and Kitchen 3.0 (#458)
Browse files Browse the repository at this point in the history
* Simplify gems.rb

* Refresh Guardfile with plugin template suggestions

* Drop guard-bundler

This plugin doesn't support gems.rb :(

* Update RSpec to ~> 3.10

* Add implicit yard dependency on webrick

* Update dry-validation to ~> 1.6

* Add Ruby 3.0 to supported versions

* Add Ruby 3.0 to tested versions

* Use Ruby 3.0 as development version

* Use positional standard_output yield param

RSpec 3.10 has an incompatibility with Ruby 3.0 for mocks that yield keyword arguments

* Update config attributes for dry-validation ~> 1.6

* Use Ruby 3.0 in kitchen-tests

* Drop obsolete Ruby directories from CC

* Increase file-lines threshold to 300

* Clarify HashOfSymbolsAndStrings errors

* Apply rufo

* Move code coverage to Ruby 3.0

* Add support for test-kitchen 3.0

* Fix line lengths in CHANGELOG

* Update CI testing information

* Fix release info line length

* Add support for delegate 2.0

* Add Ruby 3.0 to CHANGELOG

* Add Kitchen 3.0 to CHANGELOG

* Add path filters to GHA workflows
  • Loading branch information
aaron-lane authored Jul 8, 2021
1 parent e87e502 commit 0871af5
Show file tree
Hide file tree
Showing 64 changed files with 1,157 additions and 1,030 deletions.
7 changes: 4 additions & 3 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# https://codeclimate.com/github/newcontext-oss/kitchen-terraform
version: "2"
checks:
file-lines:
config:
threshold: 300
plugins:
bundler-audit:
enabled: false
Expand All @@ -26,9 +30,6 @@ exclude_patterns:
- "doc/"
- "docs/"
- "examples/"
- "ruby-2.4/"
- "ruby-2.5/"
- "ruby-2.6/"
- "rubygems/"
- "source/"
- "tmp/"
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/kitchen-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Kitchen Tests

on: pull_request
on:
pull_request:
paths:
- 'kitchen-terraform.gemspec'
- 'kitchen.yml'
- 'lib/**'
- 'Rakefile'
- 'test/**'

defaults:
run:
Expand Down Expand Up @@ -29,7 +36,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
ruby-version: '3.0'
# bundler 2.2 fails to install the gems
bundler: '2.1.4'
bundler-cache: true
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/rspec-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: RSpec Tests

on: pull_request
on:
pull_request:
paths:
- '.rspec'
- 'gems.rb'
- 'kitchen-terraform.gemspec'
- 'lib/**'
- 'Rakefile'
- 'spec/**'

jobs:
rspec-tests:
Expand All @@ -10,6 +18,7 @@ jobs:
ruby-version:
- '2.6'
- '2.7'
- '3.0'
runs-on: ubuntu-latest
env:
CC_TEST_REPORTER_ID: 7574433e1beed630cb9a171c688bb9e010d5028f00f7218d6e845fe138c65168
Expand All @@ -24,10 +33,10 @@ jobs:
bundler: '2.1.4'
bundler-cache: true
- name: Run RSpec Tests
if: ${{ matrix.ruby-version != '2.7' }}
if: ${{ matrix.ruby-version != '3.0' }}
run: bundle exec rake test:rspec
- name: Run RSpec Tests with Code Coverage
if: ${{ matrix.ruby-version == '2.7' }}
if: ${{ matrix.ruby-version == '3.0' }}
uses: paambaati/[email protected]
with:
coverageCommand: bundle exec rake test:rspec
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased][unreleased]

### Added

- Support for Ruby 3.0.
- Support for Kitchen 3.0.

### Changed

- Dropped support for Ruby 2.4, 2.5.
Expand Down Expand Up @@ -57,7 +62,8 @@ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

### Security

- Updated all gem versions to remediate ActiveSupport vulnerability, a dependency of the train gem.
- Updated all gem versions to remediate ActiveSupport vulnerability, a
dependency of the train gem.

## [5.4.0] - 2020-05-31

Expand All @@ -67,7 +73,8 @@ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

### Changed

- Gem deployment to RubyGems now takes place with GitHub Actions. Unit and Integration tests remain in Travis CI and Appveyor.
- Gem deployment to RubyGems now takes place with GitHub Actions. Unit
and Integration tests remain in Travis CI and Appveyor.

## [5.3.0] - 2020-03-08

Expand Down
15 changes: 12 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,18 @@ analysis locally.
[GitHub Actions][github-actions] are used to provide continuous integration and
continuous deployment functionality for the Ruby gem.

[tests.yml](.github/workflows/tests.yml) define unit and integration tests that will be executed for each commit to the master branch and each commit to a branch with an open pull request.

[release.yml](.github/workflows/release.yml) contains the job configuration to deploy the Ruby gem. If a [tag][git-tag] starting with v is pushed to the master branch, then the job will attempt to build the Ruby gem and deploy it to [RubyGems][ruby-gems].
[rspec-tests.yml](.github/workflows/rspec-tests.yml) defines unit tests
that will be executed for each commit to the master branch and each
commit to a branch with an open pull request.

[kitchen-tests.yml](.github/workflows/kitchen-tests.yml) defines
integration tests that will be executed for each commit to the master
branch and each commit to a branch with an open pull request.

[release.yml](.github/workflows/release.yml) contains the job
configuration to deploy the Ruby gem. If a [tag][git-tag] starting with
v is pushed to the master branch, then the job will attempt to build
the Ruby gem and deploy it to [RubyGems][ruby-gems].

#### Releasing

Expand Down
49 changes: 25 additions & 24 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
# frozen_string_literal: true

require "guard/rspec/dsl"

directories ["lib", "spec"]

group :red_green_refactor, halt_on_fail: true do
::Guard::RSpec::Dsl.new(self).tap do |dsl|
guard :bundler do
watch "kitchen-terraform.gemspec"
end
guard :yard, cli: "--reload" do
watch /lib\/.+\.rb/
end

guard :yard, cli: "--reload" do
watch /lib\/.+\.rb/
guard(
:rspec,
all_after_pass: true,
all_on_start: true,
bundler_env: :inherit,
cmd: "bundle exec rspec",
failure_mode: :focus,
) do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new self

# RSpec files
rspec = dsl.rspec
watch rspec.spec_helper do
rspec.spec_dir
end

guard(
:rspec,
all_after_pass: true,
all_on_start: true,
bundler_env: :inherit,
cmd: "bundle exec rspec",
failure_mode: :focus,
) do
watch dsl.rspec.spec_files

watch dsl.rspec.spec_helper do dsl.rspec.spec_dir end

watch dsl.rspec.spec_support do dsl.rspec.spec_dir end

dsl.watch_spec_files_for dsl.ruby.lib_files
watch rspec.spec_support do
rspec.spec_dir
end
watch rspec.spec_files

# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for ruby.lib_files
end
end
3 changes: 1 addition & 2 deletions bin/update-gems-locked.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e
source /usr/local/share/chruby/chruby.sh
set +x
chruby ruby-2.7
chruby ruby-3.0
ruby --version
set -x
gem install bundler
Expand All @@ -13,6 +13,5 @@ then
else
bundle install
fi
bundle clean
bundle binstubs --force bundler guard middleman-cli pry rake reek rspec-core rufo test-kitchen travis yard
set +x
8 changes: 4 additions & 4 deletions gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ruby "~> 2.6"
source "https://rubygems.org/"

source "https://rubygems.org/" do
gemspec path: "."
end
ruby ">= 2.6"

gemspec
13 changes: 7 additions & 6 deletions kitchen-terraform.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require "rubygems"
specification.email = "[email protected]"
specification.homepage = "https://newcontext-oss.github.io/kitchen-terraform/"
specification.license = "Apache-2.0"
specification.add_development_dependency "guard-bundler", "~> 2.1"
specification.add_development_dependency "guard-rspec", "~> 4.7"
specification.add_development_dependency "guard-yard", "~> 2.2"
specification.add_development_dependency "guard", "~> 2.14"
Expand All @@ -30,21 +29,23 @@ require "rubygems"
specification.add_development_dependency "middleman-syntax", "~> 3.0"
specification.add_development_dependency "middleman", "~> 4.2"
specification.add_development_dependency "rake", "~> 13.0"
specification.add_development_dependency "rspec", "~> 3.4"
specification.add_development_dependency "rspec", "~> 3.10"
specification.add_development_dependency "rufo", "~> 0.7"
specification.add_development_dependency "simplecov", "~> 0.16.1"
specification.add_development_dependency "travis", "~> 1.8"
specification.add_development_dependency "yard", "~> 0.9"
specification.add_development_dependency "reek", "~> 6.0.2"
specification.add_runtime_dependency "delegate", "~> 0.1.0"
specification.add_runtime_dependency "dry-validation", "~> 0.13"
# webrick is implicitly required by yard
specification.add_development_dependency "webrick", "~> 1.7"
specification.add_runtime_dependency "delegate", ">= 0.1.0", "< 0.3.0"
specification.add_runtime_dependency "dry-validation", "~> 1.6"
specification.add_runtime_dependency "mixlib-shellout", "~> 3.0"
specification.add_runtime_dependency "inspec", ">= 3", "< 5", "!= 4.24.26", "!= 4.24.28", "!= 4.24.32"
specification.add_runtime_dependency "json", "~> 2.3"
specification.add_runtime_dependency "test-kitchen", "~> 2.1"
specification.add_runtime_dependency "test-kitchen", ">= 2.1", "< 4.0"
specification.add_runtime_dependency "tty-which", "~> 0.4.0"
specification.cert_chain = ["certs/gem-public_cert.pem"]
specification.required_ruby_version = [">= 2.6", "< 3.0"]
specification.required_ruby_version = [">= 2.6", "< 4.0"]
specification.requirements = ["Terraform >= v0.11.4, < v1.1.0"]
specification.signing_key = "certs/gem-private_key.pem" if $PROGRAM_NAME =~ /gem\z/
end
6 changes: 2 additions & 4 deletions lib/kitchen/terraform/command_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ def initialize(client:, logger:)
# @yieldparam standard_output [String] the standard output of the command.
# @raise [Kitchen::TransientFailure] if running the command results in failure.
# @return [self]
def run(command:, options:)
def run(command:, options:, &block)
::Kitchen::Terraform::ShellOut.new(
command: "#{client} #{command}",
logger: logger,
options: options,
).run do |standard_output:|
yield standard_output: standard_output
end
).run(&block)

self
end
Expand Down
4 changes: 2 additions & 2 deletions lib/kitchen/terraform/config_attribute/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

require "kitchen/terraform/config_attribute_cacher"
require "kitchen/terraform/config_schemas/string"
require "kitchen/terraform/config_attribute_contract/string"
require "kitchen/terraform/config_attribute_definer"
require "tty/which"

Expand Down Expand Up @@ -47,7 +47,7 @@ class << self
def included(plugin_class)
::Kitchen::Terraform::ConfigAttributeDefiner.new(
attribute: self,
schema: ::Kitchen::Terraform::ConfigSchemas::String,
schema: ::Kitchen::Terraform::ConfigAttributeContract::String.new,
).define plugin_class: plugin_class
plugin_class.expand_path_for to_sym do |plugin|
!::TTY::Which.exist? plugin[to_sym]
Expand Down
4 changes: 2 additions & 2 deletions lib/kitchen/terraform/config_attribute/color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

require "kitchen"
require "kitchen/terraform/config_attribute"
require "kitchen/terraform/config_schemas/boolean"
require "kitchen/terraform/config_attribute_contract/boolean"

module Kitchen
module Terraform
Expand All @@ -37,7 +37,7 @@ module Color
default_value: lambda do
::Kitchen.tty?
end,
schema: ::Kitchen::Terraform::ConfigSchemas::Boolean,
schema: ::Kitchen::Terraform::ConfigAttributeContract::Boolean.new,
).apply config_attribute: self
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/kitchen/terraform/config_attribute/fail_fast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

require "kitchen"
require "kitchen/terraform/config_attribute"
require "kitchen/terraform/config_schemas/boolean"
require "kitchen/terraform/config_attribute_contract/boolean"

module Kitchen
module Terraform
Expand All @@ -36,7 +36,7 @@ module FailFast
default_value: lambda do
true
end,
schema: ::Kitchen::Terraform::ConfigSchemas::Boolean,
schema: ::Kitchen::Terraform::ConfigAttributeContract::Boolean.new,
).apply config_attribute: self
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/kitchen/terraform/config_attribute/lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

require "kitchen"
require "kitchen/terraform/config_attribute"
require "kitchen/terraform/config_schemas/boolean"
require "kitchen/terraform/config_attribute_contract/boolean"

module Kitchen
module Terraform
Expand All @@ -33,7 +33,7 @@ module Lock
default_value: lambda do
true
end,
schema: ::Kitchen::Terraform::ConfigSchemas::Boolean,
schema: ::Kitchen::Terraform::ConfigAttributeContract::Boolean.new,
).apply config_attribute: self
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/kitchen/terraform/config_attribute/plugin_directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

require "kitchen/terraform/config_attribute"
require "kitchen/terraform/config_attribute_cacher"
require "kitchen/terraform/config_schemas/optional_string"
require "kitchen/terraform/config_attribute_contract/optional_string"
require "kitchen/terraform/file_path_config_attribute_definer"

module Kitchen
Expand All @@ -41,7 +41,7 @@ class << self
def included(plugin_class)
::Kitchen::Terraform::FilePathConfigAttributeDefiner.new(
attribute: self,
schema: ::Kitchen::Terraform::ConfigSchemas::OptionalString,
schema: ::Kitchen::Terraform::ConfigAttributeContract::OptionalString.new,
).define plugin_class: plugin_class
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

require "kitchen/terraform/config_attribute"
require "kitchen/terraform/config_attribute_cacher"
require "kitchen/terraform/config_schemas/string"
require "kitchen/terraform/config_attribute_contract/string"
require "kitchen/terraform/file_path_config_attribute_definer"

module Kitchen
Expand All @@ -38,7 +38,7 @@ class << self
def included(plugin_class)
::Kitchen::Terraform::FilePathConfigAttributeDefiner.new(
attribute: self,
schema: ::Kitchen::Terraform::ConfigSchemas::String,
schema: ::Kitchen::Terraform::ConfigAttributeContract::String.new,
).define plugin_class: plugin_class
end

Expand Down
Loading

0 comments on commit 0871af5

Please sign in to comment.