Skip to content

Commit

Permalink
Merge pull request #378 from chef/poorndm/IPACK-66-ADD-WINDOWS-3.1-TEST
Browse files Browse the repository at this point in the history
Add ruby 3.0/3.1 tests on windows
  • Loading branch information
marcparadise authored Apr 7, 2022
2 parents f7b2c14 + 6b54f24 commit b94184f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 39 deletions.
16 changes: 16 additions & 0 deletions .expeditor/run_windows_tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Stop script execution when a non-terminating error occurs
$ErrorActionPreference = "Stop"
# This will run ruby test on windows platform

Write-Output "--- Bundle install"

bundle config --local path vendor/bundle
If ($lastexitcode -ne 0) { Exit $lastexitcode }

bundle install --jobs=7 --retry=3
If ($lastexitcode -ne 0) { Exit $lastexitcode }

Write-Output "--- Bundle Execute"

bundle exec rake
If ($lastexitcode -ne 0) { Exit $lastexitcode }
22 changes: 16 additions & 6 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,24 @@ steps:
docker:
image: ruby:3.1

- label: run-specs-windows
- label: run-specs-ruby-3.0-windows
command:
- bundle config --local path vendor/bundle
- bundle config set --local without debug
- bundle install --jobs=7 --retry=3
- bundle exec rake style
- bundle exec rake unit
- .expeditor/run_windows_tests.ps1
expeditor:
executor:
docker:
host_os: windows
shell: ["powershell", "-Command"]
image: rubydistros/windows-2019:3.0
user: 'NT AUTHORITY\SYSTEM'

- label: run-specs-ruby-3.1-windows
command:
- .expeditor/run_windows_tests.ps1
expeditor:
executor:
docker:
host_os: windows
shell: ["powershell", "-Command"]
image: rubydistros/windows-2019:3.1
user: 'NT AUTHORITY\SYSTEM'
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ gem "chef-utils", "= 16.6.14" if RUBY_VERSION < "2.6.0"
group :test do
gem "rake"
gem "rspec"
gem "vcr"
gem "webrick"
gem "webmock", "~> 3.4"
gem "aruba", "~> 0.14"
gem "cucumber", "~> 1.3.20"
gem "contracts", "~> 0.16.0" # this entry can go away when ruby < 3 support is gone
if RUBY_VERSION < "2.5.0"
if RUBY_VERSION < "2.6.0"
gem "climate_control", "= 0.1.0"
gem "vcr", "= 6.0.0"
gem "mixlib-shellout", "= 3.2.5"
else
gem "climate_control", "~> 1.0"
gem "vcr"
end
end

Expand Down
49 changes: 27 additions & 22 deletions spec/functional/mixlib/install/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
require "spec_helper"
require "mixlib/install/cli"

describe "mixlib-install executable", :type => :aruba do
describe "mixlib-install executable" do
let(:args) { nil }

before(:all) do
Expand All @@ -30,14 +30,16 @@
"
end

before(:each) { run("bin/mixlib-install #{command} #{args}") }
let(:cmd) { Mixlib::ShellOut.new("mixlib-install #{command} #{args} ").run_command }
let(:last_command_output) { cmd.stdout.chomp }
let(:last_command_err) { cmd.stderr.chomp }

describe "version command" do
let(:command) { "version" }

it "prints the mixlib-install version" do
require "mixlib/install/version"
expect(last_command_started).to have_output Mixlib::Install::VERSION
expect(last_command_output).to eq Mixlib::Install::VERSION
end
end

Expand All @@ -56,16 +58,16 @@
let(:args) { "chef stable" }

it "prints the versions" do
expect(last_command_started).to have_output /12.0.3/
expect(last_command_output).to match /12.0.3/
end
end

context "with invalid args" do
let(:args) { "foo bar" }

it "returns error message" do
expect(last_command_started).to have_output /Unknown product name foo/
expect(last_command_started).to have_output /Unknown channel bar/
expect(last_command_err).to match /Unknown product name foo/
expect(last_command_err).to match /Unknown channel bar/
end
end
end
Expand All @@ -75,39 +77,42 @@

context "with no args" do
it "returns shell script to stdout" do
expect(last_command_started).to have_output /end of install_package.sh/
expect(last_command_output).to match /end of install_package.sh/
end
end

context "with ps1 type" do
let(:args) { "-t ps1" }

it "returns powershell script to stdout" do
expect(last_command_started).to have_output /export-modulemember -function 'Install-Project','Get-ProjectMetadata' -alias 'install'/
expect(last_command_output).to match /export-modulemember -function 'Install-Project','Get-ProjectMetadata' -alias 'install'/
end
end

context "with invalid type" do
let(:args) { "-t foo" }

it "errors an error" do
expect(last_command_started).to have_output "Expected '--type' to be one of ps1, sh; got foo"
expect(last_command_err).to match "Expected '--type' to be one of ps1, sh; got foo"
end
end

context "with alternate endpoint" do
let(:args) { "--endpoint https://omnitruck-custom.chef.io" }

it "contains the new endpoint" do
expect(last_command_started).to have_output /https:\/\/omnitruck-custom.chef.io/
expect(last_command_output).to match /https:\/\/omnitruck-custom.chef.io/
end
end

context "with output option" do
context "with output option", :focus do
let(:args) { "-o script.sh" }

it "writes to a file" do
expect("script.sh").to be_an_existing_file
# We're executing and not looking for stdout/err output
# so we'll directly invoke here instead of going through 'last_command_output'
Mixlib::ShellOut.new("mixlib-install #{command} #{args} ").run_command
expect(File.exist?("script.sh")).to eq true
end
end
end
Expand Down Expand Up @@ -145,31 +150,31 @@
let(:architecture) { nil }

it "exits with required args error" do
expect(last_command_started).to have_output /"mixlib-install #{command}" was called with no arguments/
expect(last_command_err).to match /"mixlib-install #{command}" was called with no arguments/
end
end

context "with chef product" do
let(:product) { "chef" }

it "downloads a chef artifact" do
expect(last_command_started).to have_output /Download saved to/
expect(last_command_output).to match /Download saved to/
end
end

context "with url flag" do
let(:additional_args) { "--url" }

it "outputs the url" do
expect(last_command_started).to have_output /https:\/\/packages.chef.io\/files\/stable\/chef/
expect(last_command_output).to match /https:\/\/packages.chef.io\/files\/stable\/chef/
end
end

context "with attributes arg" do
let(:additional_args) { "--url --attributes" }

it "outputs the attributes" do
expect(last_command_started).to have_output /"license": "Chef EULA"/
expect(last_command_output).to match /"license": "Chef EULA"/
end
end

Expand All @@ -179,7 +184,7 @@
let(:architecture) { nil }

it "fails with missing args error" do
expect(last_command_started).to have_output "Must provide platform (-p), platform version (-l) and architecture (-a) when specifying any platform details"
expect(last_command_err).to match "Must provide platform (-p), platform version (-l) and architecture (-a) when specifying any platform details"
end
end

Expand All @@ -194,7 +199,7 @@
it "has the correct artifact" do
require "digest"
sha256 = Digest::SHA256.hexdigest("./tmp/aruba/#{filename}")
expect(last_command_started).to have_output /sha256/
expect(last_command_output).to match /sha256/
end
end

Expand All @@ -205,31 +210,31 @@
let(:additional_args) { "--no-platform-version-compat" }

it "returns no results" do
expect(last_command_started).to have_output /No artifacts found matching criteria./
expect(last_command_err).to match /No artifacts found matching criteria./
end
end

context "with specified version" do
let(:additional_args) { "-v 12.0.3" }

it "returns the correct artifact" do
expect(last_command_started).to have_output /chef[-_]12.0.3-1/
expect(last_command_output).to match /chef[-_]12.0.3-1/
end
end

context "with specified channel" do
let(:additional_args) { "-c current" }

it "returns the correct artifact" do
expect(last_command_started).to have_output /files\/current\/chef/
expect(last_command_output).to match /files\/current\/chef/
end
end

context "with specified directory" do
let(:additional_args) { "-d mydir" }

it "downloads to dir" do
expect(last_command_started).to have_output /Download saved to .*mydir\/chef/
expect(last_command_output).to match /Download saved to .*mydir\/chef/
end
end
end
Expand Down
7 changes: 0 additions & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# load lib path
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)

require "aruba/rspec"
require "mixlib/install"
require "vcr"
require "webmock/rspec"
require "webrick"
require "webrick/httpproxy"
require "climate_control"

Aruba.configure do |config|
config.exit_timeout = 120
config.io_wait_timeout = 2
config.activate_announcer_on_command_failure = [:stderr, :stdout, :command]
end

# load version manifest support path
VERSION_MANIFEST_DIR = File.expand_path("../support/version_manifests", __FILE__)

Expand Down

0 comments on commit b94184f

Please sign in to comment.