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
34 changes: 34 additions & 0 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ steps:
docker:
image: ruby:3.3

- label: run-specs-ruby-3.4
command:
- .expeditor/run_linux_tests.sh rspec
expeditor:
executor:
docker:
image: ruby:3.4

- label: run-specs-windows-3.1
command:
- powershell .expeditor/run_windows_tests.ps1 rspec
Expand All @@ -46,6 +54,16 @@ steps:
shell: ["powershell", "-Command"]
image: rubydistros/windows-2019:3.3

- label: run-specs-windows-ruby-3.4
command:
- powershell .expeditor/run_windows_tests.ps1 rspec
expeditor:
executor:
docker:
host_os: windows
shell: ["powershell", "-Command"]
image: rubydistros/windows-2019:3.4

- label: cookstyle-generator-cb-tests-ruby-3.1
command:
- .expeditor/run_linux_tests.sh "rake style:cookstyle"
Expand All @@ -54,10 +72,26 @@ steps:
docker:
image: ruby:3.1

- label: cookstyle-generator-cb-tests-ruby-3.4
command:
- .expeditor/run_linux_tests.sh "rake style:cookstyle"
expeditor:
executor:
docker:
image: ruby:3.4

- label: chefstyle-tests-ruby-3.1
command:
- .expeditor/run_linux_tests.sh "rake style:chefstyle"
expeditor:
executor:
docker:
image: ruby:3.1

- label: chefstyle-tests-ruby-3.4
command:
- .expeditor/run_linux_tests.sh "rake style:chefstyle"
expeditor:
executor:
docker:
image: ruby:3.4
4 changes: 2 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up ruby 3.1
- name: Set up ruby 3.4
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: 3.4
bundler-cache: true
- name: run specs
run: bundle exec rake spec --trace
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ gemspec

gem "logger", "< 1.6" # 1.6 causes errors with mixlib-log < 3.1.1
gem "chefspec"
gem "syslog"

group :test do
gem "rake"
gem "rspec", "=3.12.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def valid?
def errors
error_messages = []
if source_options_invalid?
error_messages << "Cookbook `#{name}' has invalid source options `#{source_options.inspect}'"
formatted_opts = source_options.map { |k, v| "#{k.inspect}=>#{v.inspect}" }.join(", ")
error_messages << "Cookbook `#{name}' has invalid source options `{#{formatted_opts}}'"
end
error_messages
end
Expand Down
10 changes: 6 additions & 4 deletions lib/chef-cli/policyfile/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,13 @@ def cookbook(name, *version_and_source_opts)
else
{}
end

constraint = version_and_source_opts.first || ">= 0.0.0"
spec = CookbookLocationSpecification.new(name, constraint, source_options, storage_config)

if ( existing_source = @cookbook_location_specs[name] )
err = "Cookbook '#{name}' assigned to conflicting sources\n\n"
err << "Previous source: #{existing_source.source_options.inspect}\n"
err << "Conflicts with: #{source_options.inspect}\n"
err << "Previous source: {" + existing_source.source_options.map { |k, v| "#{k.inspect}=>#{v.inspect}" }.join(", ") + "}\n"
err << "Conflicts with: {" + source_options.map { |k, v| "#{k.inspect}=>#{v.inspect}" }.join(", ") + "}\n"
@errors << err
else
@cookbook_location_specs[name] = spec
Expand Down Expand Up @@ -179,8 +178,11 @@ def eval_policyfile(policyfile_string)
error_message << " #{error_context(policyfile_string, policyfile_filename, e)}\n\n"
unless trace.empty?
error_message << " Backtrace:\n"
normalized_trace = trace.map do |line|
line.gsub(/:in ['"]?(?:.*[#.]?)?(eval_policyfile)['"]?/, ":in `\\1'")
end
# TODO: need a way to disable filtering
error_message << filtered_bt(policyfile_filename, e).inject("") { |formatted_trace, line| formatted_trace << " #{line}\n" }
error_message << normalized_trace.inject("") { |formatted_trace, line| formatted_trace << " #{line}\n" }
end
@errors << error_message
end
Expand Down
5 changes: 4 additions & 1 deletion lib/chef-cli/policyfile_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ def install
unless missing_recipes_by_cb_spec.empty?
message = "The installed cookbooks do not contain all the recipes required by your run list(s):\n"
missing_recipes_by_cb_spec.each do |spec, missing_items|
message << "#{spec}\nis missing the following required recipes:\n"
formatted_opts = "{" + spec.source_options.map { |k, v| "#{k.inspect}=>#{v.inspect}" }.join(", ") + "}"
message << "Cookbook '#{spec.name}' = #{spec.version} #{formatted_opts}\n"
message << "is missing the following required recipes:\n"

missing_items.each { |_cb, recipe| message << "* #{recipe}\n" }
end

Expand Down
2 changes: 2 additions & 0 deletions spec/unit/policyfile_demands_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@

instance_double("ChefCLI::Policyfile::CookbookLocationSpecification",
name: "remote-cb",
version: "1.1.1",
source_options: remote_cb_source_opts,
version_constraint: Semverse::Constraint.new("= 1.1.1"),
ensure_cached: nil,
to_s: s)
Expand Down
Loading