From f70d673b78b111d693792ca2408650b7de8a0285 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 4 Apr 2022 12:07:11 +0100 Subject: [PATCH 1/9] fix: MiniTest deprecations MiniTest 6 requires objects be wrapped _(obj) This fixes the depreaction messages Signed-off-by: Dan Webb --- spec/busser/ui_spec.rb | 53 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/spec/busser/ui_spec.rb b/spec/busser/ui_spec.rb index f5a9433..8b56744 100644 --- a/spec/busser/ui_spec.rb +++ b/spec/busser/ui_spec.rb @@ -65,35 +65,35 @@ def success? end it "#banner should display a formatted message" do - ui.invoke_banner("coffee").must_equal "-----> coffee" + _(ui.invoke_banner("coffee")).must_equal "-----> coffee" end it "#info should display a formatted message" do - ui.invoke_info("beans").must_equal " beans" + _(ui.invoke_info("beans")).must_equal " beans" end it "#warn should display a formatted message" do - ui.invoke_warn("grinder").must_equal ">>>>>> grinder" + _(ui.invoke_warn("grinder")).must_equal ">>>>>> grinder" end it "#fatal should display a formatted message on stderr" do - capture_stderr { ui.invoke_fatal("grinder") }.must_equal "!!!!!! grinder\n" + _(capture_stderr { ui.invoke_fatal("grinder") }).must_equal "!!!!!! grinder\n" end describe "#die" do it "prints a message to stderr" do - capture_stderr { ui.invoke_die("noes") }.must_equal "!!!!!! noes\n" + _(capture_stderr { ui.invoke_die("noes") }).must_equal "!!!!!! noes\n" end it "calls exit with 1 by default" do capture_stderr do - ui.invoke_die("fail").must_equal 1 + _(ui.invoke_die("fail")).must_equal 1 end end it "exits with a custom exit status" do capture_stderr do - ui.invoke_die("fail", 16).must_equal 16 + _(ui.invoke_die("fail", 16)).must_equal 16 end end end @@ -103,45 +103,45 @@ def success? it "calls #run with correct options" do ui.invoke_run!("doitpls") - ui.run_args.must_equal([ + _(ui.run_args).must_equal([ "doitpls", { :capture => false, :verbose => false} ]) end it "returns true if command succeeded" do - ui.invoke_run!("great-stuff").must_equal true + _(ui.invoke_run!("great-stuff")).must_equal true end it "re-raises any exceptions from the underlying fork/exec" do ui.stubs(:run).raises(Errno::ENOMEM) - capture_stderr { - proc { ui.invoke_run!("failwhale") }.must_raise Errno::ENOMEM - }.must_match /raised an exception/ + _(capture_stderr { + _ { ui.invoke_run!("failwhale") }.must_raise Errno::ENOMEM + }).must_match /raised an exception/ end it "terminates the program if the command failed" do ui.status = FakeStatus.new(false) capture_stderr { ui.invoke_run!("failwhale") } - ui.died?.must_equal true + _(ui.died?).must_equal true end it "terminates with the exit code of the failed command" do ui.status = FakeStatus.new(false, 24) capture_stderr do - ui.invoke_run!("failwhale").must_equal 24 + _(ui.invoke_run!("failwhale")).must_equal 24 end end it "terminates the program if status is nil" do ui.status = nil - capture_stderr { ui.invoke_run!("failwhale") }. + _(capture_stderr { ui.invoke_run!("failwhale") }). must_match /did not return a valid status/ - ui.died?.must_equal true + _(ui.died?).must_equal true end end @@ -150,7 +150,7 @@ def success? it "calls #run_ruby_script with correct default options" do ui.invoke_run_ruby_script!("theworks.rb") - ui.run_ruby_script_args.must_equal([ + _(ui.run_ruby_script_args).must_equal([ "theworks.rb", { :capture => false, :verbose => false } ]) @@ -159,45 +159,46 @@ def success? it "calls #run_ruby_script with correct default options" do ui.invoke_run_ruby_script!("theworks.rb", :verbose => true) - ui.run_ruby_script_args.must_equal([ + _(ui.run_ruby_script_args).must_equal([ "theworks.rb", { :capture => false, :verbose => true } ]) end it "returns true if command succeeded" do - ui.invoke_run_ruby_script!("thewin.rb").must_equal true + _(ui.invoke_run_ruby_script!("thewin.rb")).must_equal true end it "re-raises any exceptions from the underlying fork/exec" do ui.stubs(:run_ruby_script).raises(Errno::ENOMEM) - capture_stderr { - proc { ui.invoke_run_ruby_script!("nope.rb") }.must_raise Errno::ENOMEM - }.must_match /raised an exception/ + _(capture_stderr { + _ { ui.invoke_run_ruby_script!("nope.rb") }.must_raise Errno::ENOMEM + }).must_match /raised an exception/ end it "terminates the program if the script failed" do ui.status = FakeStatus.new(false) capture_stderr { ui.invoke_run_ruby_script!("nope.rb") } - ui.died?.must_equal true + _(ui.died?).must_equal true end it "terminates with the exit code of the failed script" do ui.status = FakeStatus.new(false, 97) capture_stderr do - ui.invoke_run_ruby_script!("nadda.rb").must_equal 97 + _(ui.invoke_run_ruby_script!("nadda.rb")).must_equal 97 end end it "terminates the program if status is nil" do ui.status = nil - capture_stderr { ui.invoke_run_ruby_script!("nope.rb") }. + + _(capture_stderr { ui.invoke_run_ruby_script!("nope.rb") }). must_match /did not return a valid status/ - ui.died?.must_equal true + _(ui.died?).must_equal true end end From eef8aa9a43739af994e765c9a3443bc5fc25b1e9 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 4 Apr 2022 12:08:38 +0100 Subject: [PATCH 2/9] BREAKING_CHANGE: require Ruby 2.7 Rubies older than 2.7 are now End of Life of in security patch only mode Signed-off-by: Dan Webb --- busser.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/busser.gemspec b/busser.gemspec index 570c3c9..4cad278 100644 --- a/busser.gemspec +++ b/busser.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 1.9.1" + spec.required_ruby_version = ">= 2.7" spec.add_dependency 'thor', '<= 0.19.0' From 22e0c6e1cf0144b137c7613a63e791d929ebb07c Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 4 Apr 2022 12:09:49 +0100 Subject: [PATCH 3/9] fix: Fix additional MiniTest deprecations in the helpers_spec Signed-off-by: Dan Webb --- spec/busser/helpers_spec.rb | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/spec/busser/helpers_spec.rb b/spec/busser/helpers_spec.rb index bdb8a99..85fbf6f 100644 --- a/spec/busser/helpers_spec.rb +++ b/spec/busser/helpers_spec.rb @@ -9,17 +9,17 @@ describe ".suite_path" do it "returns a Pathname" do - suite_path.must_be_kind_of Pathname + _(suite_path).must_be_kind_of Pathname end describe "with a default root path" do it "returns a base path if no suite name is given" do - suite_path.to_s.must_match %r{/opt/busser/suites$} + _(suite_path.to_s).must_match %r{/opt/busser/suites$} end it "returns a suite path given a suite name" do - suite_path("fuzzy").to_s.must_match %r{/opt/busser/suites/fuzzy$} + _(suite_path("fuzzy").to_s).must_match %r{/opt/busser/suites/fuzzy$} end end @@ -30,12 +30,12 @@ it "returns a base path if no suite name is given" do ENV['BUSSER_ROOT'] = "/path/to/busser" - suite_path.to_s.must_match %r{/path/to/busser/suites$} + _(suite_path.to_s).must_match %r{/path/to/busser/suites$} end it "returns a suite path given a suite name" do ENV['BUSSER_ROOT'] = "/path/to/busser" - suite_path("fuzzy").to_s.must_match %r{/path/to/busser/suites/fuzzy$} + _(suite_path("fuzzy").to_s).must_match %r{/path/to/busser/suites/fuzzy$} end end end @@ -43,17 +43,19 @@ describe ".vendor_path" do it "returns a Pathname" do - vendor_path.must_be_kind_of Pathname + _(vendor_path).must_be_kind_of Pathname end describe "with a default root path" do it "returns a base path if no product name is given" do - vendor_path.to_s.must_match %r{/opt/busser/vendor$} + _(vendor_path.to_s) + .must_match %r{/opt/busser/vendor$} end it "returns a vendor path given a product name" do - vendor_path("supreme").to_s.must_match %r{/opt/busser/vendor/supreme$} + _(vendor_path("supreme").to_s) + .must_match %r{/opt/busser/vendor/supreme$} end end @@ -64,13 +66,14 @@ it "returns a base path if no product name is given" do ENV['BUSSER_ROOT'] = "/path/to/busser" - vendor_path.to_s.must_match %r{/path/to/busser/vendor$} + _(vendor_path.to_s) + .must_match %r{/path/to/busser/vendor$} end it "returns a suite path given a product name" do ENV['BUSSER_ROOT'] = "/path/to/busser" - vendor_path("maximal").to_s.must_match \ - %r{/path/to/busser/vendor/maximal$} + _(vendor_path("maximal").to_s) + .must_match %r{/path/to/busser/vendor/maximal$} end end end From e05d2ba5a5ce3fa6cfbee5d0d6d8b8ecb4ebafb2 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 4 Apr 2022 12:11:43 +0100 Subject: [PATCH 4/9] fix: Ambiguity between and two divisions Signed-off-by: Dan Webb --- spec/busser/ui_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/busser/ui_spec.rb b/spec/busser/ui_spec.rb index 8b56744..2cca640 100644 --- a/spec/busser/ui_spec.rb +++ b/spec/busser/ui_spec.rb @@ -118,7 +118,7 @@ def success? _(capture_stderr { _ { ui.invoke_run!("failwhale") }.must_raise Errno::ENOMEM - }).must_match /raised an exception/ + }).must_match %r{raised an exception} end it "terminates the program if the command failed" do @@ -139,7 +139,7 @@ def success? it "terminates the program if status is nil" do ui.status = nil _(capture_stderr { ui.invoke_run!("failwhale") }). - must_match /did not return a valid status/ + must_match %r{did not return a valid status} _(ui.died?).must_equal true end @@ -174,7 +174,7 @@ def success? _(capture_stderr { _ { ui.invoke_run_ruby_script!("nope.rb") }.must_raise Errno::ENOMEM - }).must_match /raised an exception/ + }).must_match %r{raised an exception} end it "terminates the program if the script failed" do @@ -196,7 +196,7 @@ def success? ui.status = nil _(capture_stderr { ui.invoke_run_ruby_script!("nope.rb") }). - must_match /did not return a valid status/ + must_match %r{did not return a valid status} _(ui.died?).must_equal true end From 19ee2163c02f83c927e1495b28d4efc02c92dd6d Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 4 Apr 2022 12:13:05 +0100 Subject: [PATCH 5/9] fix: Require mocha/minitest instead of the deprecated mocha/setup Signed-off-by: Dan Webb --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4c6ae5f..db7c4c9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,7 +18,7 @@ require 'fakefs/safe' require 'minitest/autorun' -require 'mocha/setup' +require 'mocha/minitest' if ENV["COVERAGE"] require 'simplecov' From 9912461cb6986b6ac82bf72edf4304679d3aea59 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 4 Apr 2022 12:13:36 +0100 Subject: [PATCH 6/9] fix: Remove empty cane file Signed-off-by: Dan Webb --- .cane | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .cane diff --git a/.cane b/.cane deleted file mode 100644 index e69de29..0000000 From 5485a0b7f14d0342711211be256c0968fb46e967 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 4 Apr 2022 12:20:37 +0100 Subject: [PATCH 7/9] fix: style violations Signed-off-by: Dan Webb --- .travis.yml | 52 ------------------------------------------ spec/busser/ui_spec.rb | 6 +++-- 2 files changed, 4 insertions(+), 54 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 344ed58..0000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -language: ruby - -rvm: - - 2.2 - - 2.1 - - 2.0.0 - - 1.9.3 - - ruby-head - -env: - - RUBYGEMS_VERSION= - - RUBYGEMS_VERSION=2.4.5 - - RUBYGEMS_VERSION=2.2.2 - - RUBYGEMS_VERSION=2.1.11 - - RUBYGEMS_VERSION=2.0.14 - - RUBYGEMS_VERSION=1.8.29 - -before_install: - - if [ -n "$RUBYGEMS_VERSION" ]; then gem update --system $RUBYGEMS_VERSION; fi - - gem --version - -bundler_args: --without guard - -sudo: false - -matrix: - allow_failures: - - rvm: ruby-head - exclude: - - rvm: 2.2 - env: RUBYGEMS_VERSION=2.2.2 - - rvm: 2.2 - env: RUBYGEMS_VERSION=2.1.11 - - rvm: 2.2 - env: RUBYGEMS_VERSION=2.0.14 - - rvm: 2.2 - env: RUBYGEMS_VERSION=1.8.29 - - rvm: 2.1 - env: RUBYGEMS_VERSION=1.8.29 - - rvm: 2.0.0 - env: RUBYGEMS_VERSION=1.8.29 - - rvm: ruby-head - env: RUBYGEMS_VERSION=2.2.2 - - rvm: ruby-head - env: RUBYGEMS_VERSION=2.1.11 - - rvm: ruby-head - env: RUBYGEMS_VERSION=2.0.14 - - rvm: ruby-head - env: RUBYGEMS_VERSION=1.8.29 - -notifications: - irc: "chat.freenode.net#kitchenci" diff --git a/spec/busser/ui_spec.rb b/spec/busser/ui_spec.rb index 2cca640..dabab95 100644 --- a/spec/busser/ui_spec.rb +++ b/spec/busser/ui_spec.rb @@ -77,12 +77,14 @@ def success? end it "#fatal should display a formatted message on stderr" do - _(capture_stderr { ui.invoke_fatal("grinder") }).must_equal "!!!!!! grinder\n" + _(capture_stderr { ui.invoke_fatal("grinder") }) + .must_equal "!!!!!! grinder\n" end describe "#die" do it "prints a message to stderr" do - _(capture_stderr { ui.invoke_die("noes") }).must_equal "!!!!!! noes\n" + _(capture_stderr { ui.invoke_die("noes") }) + .must_equal "!!!!!! noes\n" end it "calls exit with 1 by default" do From 3c4afecd9ab741071a70d897bfc7f893d5338e10 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 4 Apr 2022 12:22:24 +0100 Subject: [PATCH 8/9] feat: Add GitHub workflows Signed-off-by: Dan Webb --- .github/workflows/please-release.yml | 16 ++++++++++++++ .github/workflows/publish.yaml | 17 +++++++++++++++ .github/workflows/unit.yml | 31 ++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 .github/workflows/please-release.yml create mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/unit.yml diff --git a/.github/workflows/please-release.yml b/.github/workflows/please-release.yml new file mode 100644 index 0000000..0962954 --- /dev/null +++ b/.github/workflows/please-release.yml @@ -0,0 +1,16 @@ +--- +on: + push: + branches: + - main + +name: release-please +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + with: + release-type: ruby + package-name: kitchen-azurerm + version-file: lib/kitchen/driver/azurerm_version.rb diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..a3d7b1b --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,17 @@ +--- +name: Publish + +'on': + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build and publish gem + uses: jstastny/publish-gem-to-github@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + owner: ${{ secrets.OWNER }} diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml new file mode 100644 index 0000000..f866402 --- /dev/null +++ b/.github/workflows/unit.yml @@ -0,0 +1,31 @@ +--- +name: Unit + +'on': + pull_request: + push: + branches: + - main + +jobs: + yamllint: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@main + - name: Run yaml Lint + uses: actionshub/yamllint@main + test: + needs: yamllint + runs-on: ubuntu-latest + strategy: + matrix: + ruby: ['2.7', '3.0', '3.1'] + name: Unit test on Ruby ${{ matrix.ruby }} + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - run: bundle exec rake test From c71963db8b75debbf6df58f043c8839c1ec0f569 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 4 Apr 2022 14:11:09 +0100 Subject: [PATCH 9/9] Update Thor dependency Signed-off-by: Dan Webb --- busser.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/busser.gemspec b/busser.gemspec index 4cad278..9f4a88b 100644 --- a/busser.gemspec +++ b/busser.gemspec @@ -20,9 +20,9 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.7" - spec.add_dependency 'thor', '<= 0.19.0' + spec.add_dependency 'thor', '~> 1.2.1' - spec.add_development_dependency 'aruba', "0.7.4" + spec.add_development_dependency 'aruba', "~> 0.7.4" spec.add_development_dependency "bundler" spec.add_development_dependency 'cane' spec.add_development_dependency 'countloc'