Skip to content

Commit

Permalink
Use chef 17 for 3.0 tests, chef 18 for 3.1 tests (#221)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
tpowell-progress authored Mar 1, 2024
1 parent 30dfdbf commit 7475a2d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ name: lint
pull_request:
push:
branches:
- master
- main

jobs:
chefstyle:
runs-on: ubuntu-latest
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
8 changes: 4 additions & 4 deletions .github/workflows/unit_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
19 changes: 15 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/chef/resource/private_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -249,7 +248,6 @@ def load_current_resource
else
resource.action :delete
end

@current_resource = resource
end
end
Expand Down

0 comments on commit 7475a2d

Please sign in to comment.