From 7475a2d758e6e2c5880a5365bc0df20744a7570f Mon Sep 17 00:00:00 2001 From: Thomas Powell <104777878+tpowell-progress@users.noreply.github.com> Date: Fri, 1 Mar 2024 17:01:51 -0500 Subject: [PATCH] Use chef 17 for 3.0 tests, chef 18 for 3.1 tests (#221) * bump GA checkout to @4 * switch on chef version requirement, 3.0 - Chef 17, 3.1 - Chef - 18, and unbounded for anything else --------- Signed-off-by: Thomas Powell --- .github/workflows/lint.yml | 6 +++--- .github/workflows/unit_specs.yml | 8 ++++---- Gemfile | 19 +++++++++++++++---- Rakefile | 4 ++-- lib/chef/resource/private_key.rb | 4 +--- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4950888..ea15a0e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,7 +5,7 @@ name: lint pull_request: push: branches: - - master + - main jobs: chefstyle: @@ -13,10 +13,10 @@ jobs: env: BUNDLE_WITHOUT: ruby_shadow:omnibus_package steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0' + ruby-version: '3.1' bundler-cache: true - uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR - run: bundle exec rake style diff --git a/.github/workflows/unit_specs.yml b/.github/workflows/unit_specs.yml index 632e0a3..a80d715 100644 --- a/.github/workflows/unit_specs.yml +++ b/.github/workflows/unit_specs.yml @@ -5,19 +5,19 @@ name: unit_specs pull_request: push: branches: - - master + - main jobs: unit: strategy: fail-fast: false matrix: - os: [ubuntu-18.04, windows-2016, macos-10.15] + os: [ubuntu-latest, windows-latest, macos-latest] # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: ['3.0'] + ruby: ['3.0', '3.1'] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} diff --git a/Gemfile b/Gemfile index ffe9c71..d7d1346 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" gemspec group :development do - gem "chefstyle", "2.0.8" + gem "cookstyle", "~> 7.32.8" gem "rake" gem "rspec", "~> 3.0" end @@ -14,8 +14,19 @@ if ENV["GEMFILE_MOD"] instance_eval(ENV["GEMFILE_MOD"]) else group :development do - # temporarily we only support building against master - gem "chef", github: "chef/chef", branch: "master" - gem "ohai", github: "chef/ohai", branch: "master" + # chef 17 is on 3.0 + # chef 18 is on 3.1 + case RUBY_VERSION + when /^3\.0/ + gem "chef", "~> 17.0" + gem "ohai", "~> 17.0" + when /^3\.1/ + gem "chef", "~> 18.0" + gem "ohai", "~> 18.0" + else + # go with the latest, unbounded + gem "chef" + gem "ohai" + end end end diff --git a/Rakefile b/Rakefile index db1b7d3..55372a4 100644 --- a/Rakefile +++ b/Rakefile @@ -14,14 +14,14 @@ rescue LoadError end begin - require "chefstyle" + require "cookstyle/chefstyle" require "rubocop/rake_task" desc "Run Chefstyle tests" RuboCop::RakeTask.new(:style) do |task| task.options += ["--display-cop-names", "--no-color"] end rescue LoadError - puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed." + puts "cookstyle gem is not installed. bundle install first to make sure all dependencies are installed." end begin diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 1c03e09..04981b1 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -93,7 +93,6 @@ def create_key(regenerate, action) (!current_private_key || current_resource.size != new_resource.size || current_resource.type != new_resource.type)) - case new_resource.type when :rsa if new_resource.exponent @@ -137,7 +136,7 @@ def create_key(regenerate, action) converge_by "change format of #{new_resource.type} private key #{new_path} from #{current_resource.format} to #{new_resource.format}" do write_private_key(current_private_key) end - elsif RUBY_PLATFORM !~ /mswin|mingw32|windows/ && (@current_file_mode & 0077) != 0 + elsif RUBY_PLATFORM !~ /mswin|mingw|windows/ && (@current_file_mode & 0077) != 0 new_mode = @current_file_mode & 07700 converge_by "change mode of private key #{new_path} to #{new_mode.to_s(8)}" do ::File.chmod(new_mode, new_path) @@ -249,7 +248,6 @@ def load_current_resource else resource.action :delete end - @current_resource = resource end end