diff --git a/.github/workflows/delivery.yml b/.github/workflows/delivery.yml index dd0d3cfcc..63d6d678b 100644 --- a/.github/workflows/delivery.yml +++ b/.github/workflows/delivery.yml @@ -6,7 +6,7 @@ jobs: commit-compile: name: Commit - Compile if: ${{ github.ref_type == 'branch' }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.operating-system }}-latest steps: - name: Checkout Repository uses: actions/checkout@v3 @@ -16,43 +16,50 @@ jobs: ruby-version: '${{ matrix.ruby-version }}' bundler: '2.4' bundler-cache: true + cache-version: '1-os-${{ matrix.operating-system }}-rv-${{ matrix.ruby-version }}' - name: Upload Bundler Lockfile uses: actions/upload-artifact@v3 with: - name: bundler-lockfile-ruby-${{ matrix.ruby-version }} + name: bundler-lockfile-os-${{ matrix.operating-system }}-rv-${{ matrix.ruby-version }} path: gems.locked if-no-files-found: error strategy: fail-fast: false matrix: - ruby-version: - - '2.7' - - '3.0' - - '3.1' + include: + - operating-system: ubuntu + ruby-version: '2.7' + - operating-system: ubuntu + ruby-version: '3.0' + - operating-system: ubuntu + ruby-version: '3.1' + - operating-system: windows + ruby-version: '3.1' commit-unit-test: name: Commit - Unit Test needs: - commit-compile if: ${{ github.ref_type == 'branch' }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.operating-system }}-latest steps: - name: Checkout Repository uses: actions/checkout@v3 - name: Download Bundler Lockfile uses: actions/download-artifact@v3 with: - name: bundler-lockfile-ruby-${{ matrix.ruby-version }} + name: bundler-lockfile-os-${{ matrix.operating-system }}-rv-${{ matrix.ruby-version }} - name: Setup Ruby uses: ruby/setup-ruby@v1 with: ruby-version: '${{ matrix.ruby-version }}' bundler: '2.4' bundler-cache: true + cache-version: '1-os-${{ matrix.operating-system }}-rv-${{ matrix.ruby-version }}' - name: Run RSpec Tests - if: ${{ matrix.ruby-version != '3.1' }} + if: ${{ !matrix.code-coverage }} run: bundle exec rake test:rspec - name: Run RSpec Tests with Code Coverage - if: ${{ matrix.ruby-version == '3.1' }} + if: ${{ matrix.code-coverage }} uses: paambaati/codeclimate-action@v3.2.0 env: CC_TEST_REPORTER_ID: 7574433e1beed630cb9a171c688bb9e010d5028f00f7218d6e845fe138c65168 @@ -61,10 +68,19 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: - - '2.7' - - '3.0' - - '3.1' + include: + - code-coverage: false + operating-system: ubuntu + ruby-version: '2.7' + - code-coverage: false + operating-system: ubuntu + ruby-version: '3.0' + - code-coverage: true + operating-system: ubuntu + ruby-version: '3.1' + - code-coverage: false + operating-system: windows + ruby-version: '3.1' commit-assemble: name: Commit - Assemble needs: @@ -77,13 +93,14 @@ jobs: - name: Download Bundler Lockfile uses: actions/download-artifact@v3 with: - name: bundler-lockfile-ruby-3.1 + name: bundler-lockfile-os-ubuntu-rv-3.1 - name: Setup Ruby uses: ruby/setup-ruby@v1 with: ruby-version: '3.1' bundler: '2.4' bundler-cache: true + cache-version: '1-os-ubuntu-rv-3.1' - name: Build Ruby Gem env: GEM_PRIVATE_KEY: ${{ secrets.GEM_PRIVATE_KEY }} diff --git a/spec/lib/kitchen/driver/terraform_spec.rb b/spec/lib/kitchen/driver/terraform_spec.rb index 3fdc60cd0..4f9f69e87 100644 --- a/spec/lib/kitchen/driver/terraform_spec.rb +++ b/spec/lib/kitchen/driver/terraform_spec.rb @@ -50,7 +50,6 @@ ::Kitchen::Instance.new( driver: subject, lifecycle_hooks: ::Kitchen::LifecycleHooks.new(config, state_file), - logger: ::Kitchen::Logger.new, platform: ::Kitchen::Platform.new(name: "test-platform"), provisioner: ::Kitchen::Provisioner::Base.new, state_file: state_file, diff --git a/spec/lib/kitchen/provisioner/terraform_spec.rb b/spec/lib/kitchen/provisioner/terraform_spec.rb index 6b5a35009..36df0f726 100644 --- a/spec/lib/kitchen/provisioner/terraform_spec.rb +++ b/spec/lib/kitchen/provisioner/terraform_spec.rb @@ -50,7 +50,6 @@ ::Kitchen::Instance.new( driver: driver, lifecycle_hooks: ::Kitchen::LifecycleHooks.new(config, state_file), - logger: logger, platform: ::Kitchen::Platform.new(name: "test-platform"), provisioner: subject, state_file: state_file, @@ -70,7 +69,7 @@ config: driver_config, connection: kind_of(::Kitchen::Terraform::Transport::Connection), debug_connection: kind_of(::Kitchen::Terraform::Transport::Connection), - logger: logger, + logger: ::Kitchen.logger, version_requirement: kind_of(::Gem::Requirement), workspace_name: kind_of(::String), ).and_return(converge) diff --git a/spec/lib/kitchen/terraform/driver/create_spec.rb b/spec/lib/kitchen/terraform/driver/create_spec.rb index 09b251734..47edbf1c1 100644 --- a/spec/lib/kitchen/terraform/driver/create_spec.rb +++ b/spec/lib/kitchen/terraform/driver/create_spec.rb @@ -29,7 +29,7 @@ described_class.new( config: config, connection: connection, - logger: logger, + logger: ::Kitchen.logger, workspace_name: double(::String), version_requirement: ::Gem::Requirement.new(">= 0.1.0"), ) diff --git a/spec/lib/kitchen/terraform/driver/destroy_spec.rb b/spec/lib/kitchen/terraform/driver/destroy_spec.rb index 398af18eb..036bc6b7b 100644 --- a/spec/lib/kitchen/terraform/driver/destroy_spec.rb +++ b/spec/lib/kitchen/terraform/driver/destroy_spec.rb @@ -31,7 +31,7 @@ described_class.new( config: config, connection: connection, - logger: logger, + logger: ::Kitchen.logger, workspace_name: "test-workspace", version_requirement: ::Gem::Requirement.new(">= 0.1.0"), ) diff --git a/spec/lib/kitchen/terraform/inspec_runner_spec.rb b/spec/lib/kitchen/terraform/inspec_runner_spec.rb index e295a1106..2b03e5845 100644 --- a/spec/lib/kitchen/terraform/inspec_runner_spec.rb +++ b/spec/lib/kitchen/terraform/inspec_runner_spec.rb @@ -24,15 +24,15 @@ describe ".logger=" do before do - described_class.logger = logger + described_class.logger = ::Kitchen.logger end specify "should extend the logger interface to be compatible with InSpec" do - expect(logger.logdev.filename).to be false + expect(::Kitchen.logger.logdev.filename).to be false end specify "should set the Inspec logger" do - expect(::Inspec::Log.logger).to be logger + expect(::Inspec::Log.logger).to be ::Kitchen.logger end end @@ -42,7 +42,7 @@ end let :full_options do - { key: "value", logger: logger } + { key: "value", logger: ::Kitchen.logger } end let :loader do @@ -67,7 +67,7 @@ allow(loader).to receive :exit_on_load_error allow(::Inspec::Runner).to receive(:new).with(full_options).and_return runner allow(runner).to receive(:add_target).with profile_location - described_class.logger = logger + described_class.logger = ::Kitchen.logger end context "when the InSpec runner raises an error and a host is not targeted" do @@ -84,7 +84,7 @@ context "when the InSpec runner raises an error and a host is targeted" do let :full_options do - { host: "test", key: "value", logger: logger } + { host: "test", key: "value", logger: ::Kitchen.logger } end let :options do diff --git a/spec/lib/kitchen/terraform/provisioner/converge_spec.rb b/spec/lib/kitchen/terraform/provisioner/converge_spec.rb index 80a9ea587..052a09437 100644 --- a/spec/lib/kitchen/terraform/provisioner/converge_spec.rb +++ b/spec/lib/kitchen/terraform/provisioner/converge_spec.rb @@ -35,7 +35,7 @@ config: config, connection: connection, debug_connection: debug_connection, - logger: logger, + logger: ::Kitchen.logger, workspace_name: "test-workspace", version_requirement: ::Gem::Requirement.new(">= 0.1.0"), ) diff --git a/spec/lib/kitchen/terraform/system_spec.rb b/spec/lib/kitchen/terraform/system_spec.rb index fd48c5941..ef2b2269f 100644 --- a/spec/lib/kitchen/terraform/system_spec.rb +++ b/spec/lib/kitchen/terraform/system_spec.rb @@ -23,7 +23,7 @@ ::RSpec.describe ::Kitchen::Terraform::System do subject do - described_class.new configuration_attributes: configuration_attributes, logger: logger + described_class.new configuration_attributes: configuration_attributes, logger: ::Kitchen.logger end include_context "Kitchen::Logger" diff --git a/spec/lib/kitchen/terraform/transport/connection_spec.rb b/spec/lib/kitchen/terraform/transport/connection_spec.rb index a06917753..f834ceb2b 100644 --- a/spec/lib/kitchen/terraform/transport/connection_spec.rb +++ b/spec/lib/kitchen/terraform/transport/connection_spec.rb @@ -40,11 +40,22 @@ instance_double ::String end + let :instance_name do + instance_double ::String + end + + let :kitchen_root do + # kitchen_root must support implicit string conversion + "test-kitchen-root" + end + let :options do { client: client, command_timeout: command_timeout, environment: { environment_variable_key => environment_variable_value }, + instance_name: instance_name, + kitchen_root: kitchen_root, root_module_directory: root_module_directory, } end @@ -63,10 +74,8 @@ end specify "should invoke the ShellOut superclass implementation with the client and options configured" do - allow(shell_out).to receive :run_command - allow(shell_out).to receive :execution_time - allow(shell_out).to receive :error! - allow(shell_out).to receive(:stdout).and_return :superclass + allow(subject).to receive(:run_from_file_command).with("#{client} #{command}").and_return "#{client} #{command}" + allow(subject).to receive :close allow(::Mixlib::ShellOut).to receive(:new).with( "#{client} #{command}", including({ @@ -80,7 +89,12 @@ }) ).and_return shell_out - expect(subject.execute(command)).to eq :superclass + expect(shell_out).to receive :run_command + expect(shell_out).to receive :execution_time + expect(shell_out).to receive :error! + expect(shell_out).to receive :stdout + + subject.execute command end end end diff --git a/spec/lib/kitchen/terraform/verify_version_rescue_strategy/permissive_spec.rb b/spec/lib/kitchen/terraform/verify_version_rescue_strategy/permissive_spec.rb index 22f3e45a6..3e44d273a 100644 --- a/spec/lib/kitchen/terraform/verify_version_rescue_strategy/permissive_spec.rb +++ b/spec/lib/kitchen/terraform/verify_version_rescue_strategy/permissive_spec.rb @@ -20,14 +20,14 @@ ::RSpec.describe ::Kitchen::Terraform::VerifyVersionRescueStrategy::Permissive do subject do - described_class.new logger: logger + described_class.new logger: ::Kitchen.logger end include_context "Kitchen::Logger" describe "#call" do specify "should warn the user that the Terraform client version is unsupported" do - expect(logger).to receive :warn + expect(::Kitchen.logger).to receive :warn end after do diff --git a/spec/lib/kitchen/terraform/verify_version_spec.rb b/spec/lib/kitchen/terraform/verify_version_spec.rb index bab5fe3b3..2475caee3 100644 --- a/spec/lib/kitchen/terraform/verify_version_spec.rb +++ b/spec/lib/kitchen/terraform/verify_version_spec.rb @@ -24,7 +24,7 @@ subject do described_class.new( config: config, - logger: logger, + logger: ::Kitchen.logger, version_requirement: version_requirement, ) end diff --git a/spec/lib/kitchen/transport/terraform_spec.rb b/spec/lib/kitchen/transport/terraform_spec.rb index 29b71e407..f62adbf24 100644 --- a/spec/lib/kitchen/transport/terraform_spec.rb +++ b/spec/lib/kitchen/transport/terraform_spec.rb @@ -37,7 +37,6 @@ ::Kitchen::Instance.new( driver: ::Kitchen::Driver::Base.new, lifecycle_hooks: ::Kitchen::LifecycleHooks.new(config, state_file), - logger: logger, platform: ::Kitchen::Platform.new(name: "test-platform"), provisioner: ::Kitchen::Provisioner::Base.new, state_file: state_file, diff --git a/spec/lib/kitchen/verifier/terraform_spec.rb b/spec/lib/kitchen/verifier/terraform_spec.rb index 6cfc09402..2a264e08b 100644 --- a/spec/lib/kitchen/verifier/terraform_spec.rb +++ b/spec/lib/kitchen/verifier/terraform_spec.rb @@ -89,7 +89,6 @@ ::Kitchen::Instance.new( driver: ::Kitchen::Driver::Base.new, lifecycle_hooks: ::Kitchen::LifecycleHooks.new(config, state_file), - logger: logger, platform: ::Kitchen::Platform.new(name: "test-platform"), provisioner: ::Kitchen::Provisioner::Base.new, state_file: state_file, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0427ea6e3..df8f3dd17 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,7 +26,7 @@ expect_configuration.max_formatted_output_length = nil end - configuration.fail_fast = true + configuration.fail_fast = false configuration.mock_with :rspec do |mocks| mocks.verify_doubled_constant_names = true diff --git a/spec/support/kitchen/logger_context.rb b/spec/support/kitchen/logger_context.rb index ba46dbf92..df7ac26bc 100644 --- a/spec/support/kitchen/logger_context.rb +++ b/spec/support/kitchen/logger_context.rb @@ -17,7 +17,7 @@ require "kitchen/logger" ::RSpec.shared_context "Kitchen::Logger" do - let :logger do - ::Kitchen::Logger.new stdout: ::File.open(::File::NULL, "w") + before do + ::Kitchen.logger = ::Kitchen::Logger.new stdout: ::File.open(::File::NULL, "w") end end diff --git a/spec/support/kitchen/terraform/config_attribute/client_examples.rb b/spec/support/kitchen/terraform/config_attribute/client_examples.rb index 010f26a35..613aef814 100644 --- a/spec/support/kitchen/terraform/config_attribute/client_examples.rb +++ b/spec/support/kitchen/terraform/config_attribute/client_examples.rb @@ -88,7 +88,10 @@ context "when the configured client does exist and is executable" do let :value do - $0 + file = ::Tempfile.new ["client", ".exe"] + file.chmod 0777 + + file end specify "should return false" do diff --git a/spec/support/kitchen/terraform/config_attribute/systems_examples.rb b/spec/support/kitchen/terraform/config_attribute/systems_examples.rb index f6656e1f3..d5c69601c 100644 --- a/spec/support/kitchen/terraform/config_attribute/systems_examples.rb +++ b/spec/support/kitchen/terraform/config_attribute/systems_examples.rb @@ -14,11 +14,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +require "support/kitchen/logger_context" + ::RSpec.shared_examples "Kitchen::Terraform::ConfigAttribute::Systems" do subject do described_class.new config end + include_context "Kitchen::Logger" + let :config do { kitchen_root: "kitchen_root", @@ -50,7 +54,10 @@ context "when the configured systems are not empty" do before do - config.store :systems, [::Kitchen::Terraform::System.new(configuration_attributes: {}, logger: logger)] + config.store( + :systems, + [::Kitchen::Terraform::System.new(configuration_attributes: {}, logger: ::Kitchen.logger)] + ) end specify "should return false" do