diff --git a/.cane b/.cane deleted file mode 100644 index e69de29..0000000 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 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/busser.gemspec b/busser.gemspec index 18e1a82..9f4a88b 100644 --- a/busser.gemspec +++ b/busser.gemspec @@ -18,11 +18,11 @@ 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', '<= 1.1.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' 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 diff --git a/spec/busser/ui_spec.rb b/spec/busser/ui_spec.rb index f5a9433..dabab95 100644 --- a/spec/busser/ui_spec.rb +++ b/spec/busser/ui_spec.rb @@ -65,35 +65,37 @@ 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 +105,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 %r{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") }. - must_match /did not return a valid status/ + _(capture_stderr { ui.invoke_run!("failwhale") }). + must_match %r{did not return a valid status} - ui.died?.must_equal true + _(ui.died?).must_equal true end end @@ -150,7 +152,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 +161,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 %r{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") }. - must_match /did not return a valid status/ - ui.died?.must_equal true + _(capture_stderr { ui.invoke_run_ruby_script!("nope.rb") }). + must_match %r{did not return a valid status} + + _(ui.died?).must_equal true end end 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'