From b0f946a54ec0365a76ef8b5fe8f54ef5258aa44f Mon Sep 17 00:00:00 2001 From: Corey Hemminger Date: Tue, 25 Apr 2023 02:42:30 -0500 Subject: [PATCH] Fix yaml load error for ruby 3.1 (#220) * Fix yaml load error for ruby 3.1 * update ruby versions * fix rspec mocks for hash with keywords in ruby 3.0+ * add simplecov to ignore word list --------- Signed-off-by: Corey Hemminger Signed-off-by: Vikram Karve Co-authored-by: Vikram Karve <85881329+vkarve-chef@users.noreply.github.com> --- .github/workflows/lint.yaml | 23 ++++++++++------------- VERSION | 2 +- cspell.json | 16 +++++++++++----- lib/chef_apply/text.rb | 2 +- spec/unit/cli_spec.rb | 6 +++--- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 65057f692..7e5b422cc 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -13,10 +13,10 @@ jobs: env: BUNDLE_WITHOUT: ruby_shadow:omnibus_package steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.1 bundler-cache: true - uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR - run: bundle exec chefstyle @@ -24,26 +24,23 @@ jobs: spellcheck: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: carlosperate/download-file-action@v1.0.3 + - uses: actions/checkout@v3 + - uses: carlosperate/download-file-action@v2.0.0 id: download-custom-dictionary with: file-url: 'https://raw.githubusercontent.com/chef/chef_dictionary/main/chef.txt' file-name: 'chef_dictionary.txt' - - uses: zwaldowski/cspell-action@v1 - with: - config: cspell.json - paths: "**/*" + - uses: streetsidesoftware/cspell-action@v2.12.0 coverage-test: name: Coverage - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up ruby 2.7 + - uses: actions/checkout@v3 + - name: Set up ruby 3.1 uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.1 bundler-cache: true - name: run specs run: bundle exec rake spec --trace @@ -52,4 +49,4 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} failedThreshold: 90 - resultPath: coverage/.last_run.json + resultPath: coverage/.last_run.json diff --git a/VERSION b/VERSION index 03834411d..b0bb87854 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.5 \ No newline at end of file +0.9.5 diff --git a/cspell.json b/cspell.json index 973c32ddc..cce9a2e46 100644 --- a/cspell.json +++ b/cspell.json @@ -1,14 +1,14 @@ // cSpell Settings { // Version of the setting file. Always 0.1 - "version": "0.1", + "version": "0.2", // language - current active spelling language "language": "en", "dictionaryDefinitions": [ { - "name": "chef", - "file": "./chef_dictionary.txt", - "description": "Custom Chef Dictionary" + "name": "chef", + "path": "https://raw.githubusercontent.com/chef/chef_dictionary/main/chef.txt", + "description": "Custom Chef Dictionary" } ], "dictionaries": ["chef"], @@ -54,7 +54,13 @@ "Alnum", "succ", "proto", - "installp" + "installp", + "Qube", + "objc", + "kamura", + "carlosperate", + "Simplecov", + "simplecov" ], // flagWords - list of words to be always considered incorrect // This is useful for offensive words and common spelling errors. diff --git a/lib/chef_apply/text.rb b/lib/chef_apply/text.rb index 850eb2dad..7c4ccdc80 100644 --- a/lib/chef_apply/text.rb +++ b/lib/chef_apply/text.rb @@ -28,7 +28,7 @@ def self._error_table # error metadata. path = File.join(_translation_path, "errors", "en.yml") raw_yaml = File.read(path) - @error_table ||= YAML.load(raw_yaml, _translation_path, symbolize_names: true)[:errors] + @error_table ||= YAML.load(raw_yaml, filename: _translation_path, symbolize_names: true)[:errors] end def self._translation_path diff --git a/spec/unit/cli_spec.rb b/spec/unit/cli_spec.rb index 74ebcfb56..843c4cd79 100644 --- a/spec/unit/cli_spec.rb +++ b/spec/unit/cli_spec.rb @@ -224,8 +224,8 @@ it "gets an action via GenerateTempCookbook.from_options and executes it " do expect(ChefApply::Action::GenerateTempCookbook) .to receive(:from_options) - .with(resource_type: "user", - resource_name: "test", resource_properties: {}) + .with({ resource_type: "user", + resource_name: "test", resource_properties: {} }) .and_return(action) expect(action).to receive(:run) expect(subject.generate_temp_cookbook(%w{user test}, nil)).to eq temp_cookbook @@ -237,7 +237,7 @@ it "gets an action via GenerateTempCookbook.from_options and executes it" do expect(ChefApply::Action::GenerateTempCookbook) .to receive(:from_options) - .with(recipe_spec: "mycookbook::default", cookbook_repo_paths: "/tmp") + .with({ recipe_spec: "mycookbook::default", cookbook_repo_paths: "/tmp" }) .and_return(action) expect(action).to receive(:run) subject.generate_temp_cookbook(["mycookbook::default"], nil)