Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes deprecations and adds workflows #50

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Empty file removed .cane
Empty file.
16 changes: 16 additions & 0 deletions .github/workflows/please-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
on:

Check warning on line 2 in .github/workflows/please-release.yml

View workflow job for this annotation

GitHub Actions / yamllint

2:1 [truthy] truthy value should be one of [false, true]
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
17 changes: 17 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
31 changes: 31 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -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
52 changes: 0 additions & 52 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions busser.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
25 changes: 14 additions & 11 deletions spec/busser/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -30,30 +30,32 @@

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

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

Expand All @@ -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
Expand Down
59 changes: 31 additions & 28 deletions spec/busser/ui_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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 }
])
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

require 'fakefs/safe'
require 'minitest/autorun'
require 'mocha/setup'
require 'mocha/minitest'

if ENV["COVERAGE"]
require 'simplecov'
Expand Down
Loading