Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ expeditor:

steps:

- label: run-lint-and-specs-ruby-3.0
- label: run-lint-and-specs-ruby-3.1
command:
- .expeditor/run_linux_tests.sh rake
expeditor:
executor:
docker:
image: ruby:3.0
image: ruby:3.1

- label: run-lint-and-specs-ruby-3.1
- label: run-lint-and-specs-ruby-3.4
command:
- .expeditor/run_linux_tests.sh rake
expeditor:
executor:
docker:
image: ruby:3.1
image: ruby:3.4

- label: run-specs-ruby-3.0-windows
- label: run-specs-ruby-3.1-windows
commands:
- .expeditor/run_windows_tests.ps1

Expand All @@ -31,9 +31,9 @@ steps:
docker:
host_os: windows
shell: ["powershell"]
image: rubydistros/windows-2019:3.0
image: rubydistros/windows-2019:3.1

- label: run-specs-ruby-3.1-windows
- label: run-specs-ruby-3.4-windows
commands:
- .expeditor/run_windows_tests.ps1

Expand All @@ -42,4 +42,4 @@ steps:
docker:
host_os: windows
shell: ["powershell"]
image: rubydistros/windows-2019:3.1
image: rubydistros/windows-2019:3.4
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: lint

on:
pull_request:
push:
branches:
- main

concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: false
- uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR
- run: |
gem install cookstyle
cookstyle --chefstyle -c .rubocop.yml

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:
- master

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [windows-2019, windows-2022]
ruby: ['3.1', '3.4']
name: Unit test on ${{ matrix.os }} with Ruby ${{ matrix.ruby }}
runs-on: ${{ matrix.os }}
env:
RUBYOPT: '--disable-error_highlight'
steps:
- uses: actions/checkout@v4
- name: ruby-setup
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake spec
48 changes: 48 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
AllCops:
TargetRubyVersion: 3.1
Exclude:
- "spec/data/**/*"
- "habitat/**/*"
- "vendor/**/*"
Security/Eval:
Enabled: false
Lint/UselessAssignment:
Enabled: false
Lint/DeprecatedClassMethods:
Enabled: false
Lint/AmbiguousRegexpLiteral:
Enabled: false
Lint/AssignmentInCondition:
Enabled: false
Lint/AmbiguousBlockAssociation:
Enabled: false
Layout/EndOfLine:
Enabled: false
Lint/ShadowingOuterLocalVariable:
Enabled: false
Lint/IneffectiveAccessModifier:
Enabled: false
Lint/InterpolationCheck:
Enabled: true
Exclude:
- 'spec/unit/property_spec.rb'
- 'spec/functional/shell_spec.rb'
Lint/DeprecatedConstants:
Enabled: true
Exclude:
- lib/chef/node/attribute.rb # false alarms


# This cop shouldn't alert on the helper / specs itself
Chef/Ruby/LegacyPowershellOutMethods:
Exclude:
- 'lib/chef/mixin/powershell_out.rb'
- 'spec/functional/mixin/powershell_out_spec.rb'
- 'spec/unit/mixin/powershell_out_spec.rb'
- 'lib/chef/resource/windows_feature_powershell.rb' # https://github.com/chef/chef/issues/10927
- 'lib/chef/provider/package/powershell.rb' # https://github.com/chef/chef/issues/10926

# set additional paths
Chef/Ruby/UnlessDefinedRequire:
Include:
- 'lib/**/*'
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ group :docs do
end

group :test do
gem "chefstyle"
gem "rake"
gem "rspec", "~> 3.0"
gem "rubocop-ast"
end

group :debug do
Expand Down
17 changes: 11 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ rescue LoadError
end
end

begin
require "chefstyle"
desc "Check Linting and code style."
task :style do
require "rubocop/rake_task"
desc "Run Chefstyle tests"
RuboCop::RakeTask.new(:style) do |task|
task.options += ["--display-cop-names", "--no-color"]
require "cookstyle/chefstyle"

if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
# Windows-specific command, rubocop erroneously reports the CRLF in each file which is removed when your PR is uploaeded to GitHub.
# This is a workaround to ignore the CRLF from the files before running cookstyle.
sh "cookstyle --chefstyle -c .rubocop.yml --except Layout/EndOfLine"
else
sh "cookstyle --chefstyle -c .rubocop.yml"
end
rescue LoadError
puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed."
puts "Rubocop or Cookstyle gems are not installed. bundle install first to make sure all dependencies are installed."
end

begin
Expand Down
1 change: 0 additions & 1 deletion lib/mixlib/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def deprecated_option(name,
boolean: false,
value_mapper: nil,
keep: true)

description = if replacement
replacement_cfg = options[replacement]
display_name = CLI::Formatter.combined_option_display_name(replacement_cfg[:short], replacement_cfg[:long])
Expand Down
3 changes: 2 additions & 1 deletion mixlib-cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Gem::Specification.new do |s|
s.email = "info@chef.io"
s.homepage = "https://github.com/chef/mixlib-cli"
s.license = "Apache-2.0"
s.required_ruby_version = ">= 3.0"
s.required_ruby_version = ">= 3.1"

s.require_path = "lib"
s.files = %w{LICENSE NOTICE} + Dir.glob("lib/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
s.add_development_dependency "cookstyle", "~> 8.1"
end
4 changes: 2 additions & 2 deletions spec/mixlib/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@
context "and the replacement and deprecated are both boolean" do
before do
TestCLI.deprecated_option(:option_x, boolean: true,
long: "--[no-]option-x",
replacement: :option_a)
long: "--[no-]option-x",
replacement: :option_a)
end
it "sets original and replacement to true when the deprecated flag is used" do
cli.parse_options(%w{--option-x})
Expand Down