From ddb1b91afaaa79c60ec80d74f406730f67305540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 23 Jan 2024 11:24:12 -1000 Subject: [PATCH 1/7] Switch to GitHub Actions --- .circleci/config.yml | 22 ---------------------- .github/dependabot.yml | 12 ++++++++++++ .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 22 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 452ab352..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: 2.1 - -orbs: - ruby: circleci/ruby@2.1.3 - -jobs: - rspec_and_rubocop: - docker: - - image: circleci/ruby:2.5-node - steps: - - checkout - - ruby/install: - version: '3.2.3' - - run: ruby --version - - run: bundle install - - run: bundle exec rake test - -workflows: - version: 2 - test: - jobs: - - rspec_and_rubocop diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..2fb5c74c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + # Open PR for GitHub Actions updates + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..f2a41941 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +--- +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: + - '2.7' + - '3.0' + - '3.1' + - '3.2' + - '3.3' + steps: + - uses: actions/checkout@v4 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: Run the test suite + run: bundle exec rake test From 168055d8040bb3f548f2c957c67912ca4d22fb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 23 Jan 2024 11:35:20 -1000 Subject: [PATCH 2/7] Remove bogus test The code that kill the tread was removed in ee1dec6fca7499a47c4611aa5588b6bc668430b2 (#186). The broken test suite did not allow to see that a matching test had to be removed. --- spec/unit/mcollective/shell_spec.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/spec/unit/mcollective/shell_spec.rb b/spec/unit/mcollective/shell_spec.rb index 7b99f3ab..6eb2390b 100755 --- a/spec/unit/mcollective/shell_spec.rb +++ b/spec/unit/mcollective/shell_spec.rb @@ -216,14 +216,6 @@ module MCollective Log.expects(:warn).with("Could not reap process '1234'.") s.runcommand end - - it "should kill the guard thread when the process returns" do - s = Shell.new("echo hello world") - Thread.stubs(:current) - s.expects(:systemu).returns(@systemu) - result = s.runcommand - expect(result).to eq(@systemu) - end end end end From b119effe54f9396eb869e6332543fd6eb38db3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 23 Jan 2024 13:34:31 -1000 Subject: [PATCH 3/7] Use the chain CA certificate to validate user certificate An imcomplete certification chain is not expected to be valid. --- spec/unit/mcollective/util/choria_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/mcollective/util/choria_spec.rb b/spec/unit/mcollective/util/choria_spec.rb index 6641e576..0cfb78fc 100644 --- a/spec/unit/mcollective/util/choria_spec.rb +++ b/spec/unit/mcollective/util/choria_spec.rb @@ -243,7 +243,7 @@ module Util end it "should pass for valid client cert w/intermediate CA/ca combos" do - choria.stubs(:ca_path).returns("spec/fixtures/intermediate/ca.pem") + choria.stubs(:ca_path).returns("spec/fixtures/intermediate/certs/ca_chain_ca.pem") expect(choria.valid_certificate?(File.read("spec/fixtures/intermediate/chain-rip.mcollective.pem"), "rip.mcollective")).to be_truthy end end From c6fc25508c4822d212020687f5da45e0329d4243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 3 Jul 2024 08:50:54 +0200 Subject: [PATCH 4/7] Remove lock file --- Gemfile.lock | 157 --------------------------------------------------- 1 file changed, 157 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index ffc3bce3..00000000 --- a/Gemfile.lock +++ /dev/null @@ -1,157 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) - ast (2.4.2) - bigdecimal (3.1.8) - choria-mcorpc-support (2.26.3) - nats-pure (~> 0.6, < 0.7.0) - systemu (~> 2.6, >= 2.6.4) - concurrent-ruby (1.3.3) - crack (1.0.0) - bigdecimal - rexml - deep_merge (1.2.2) - diff-lcs (1.5.1) - diplomat (2.6.4) - deep_merge (~> 1.2) - faraday (>= 0.9, < 3.0, != 2.0.0) - etcdv3 (0.11.6) - grpc (~> 1.17) - facter (4.7.1) - hocon (~> 1.3) - thor (>= 1.0.1, < 1.3) - faraday (2.9.2) - faraday-net_http (>= 2.0, < 3.2) - faraday-net_http (3.1.0) - net-http - fast_gettext (2.4.0) - prime - ffi (1.17.0-x86_64-linux-gnu) - forwardable (1.3.3) - google-protobuf (3.25.0-x86_64-linux) - googleapis-common-protos-types (1.15.0) - google-protobuf (>= 3.18, < 5.a) - grpc (1.64.0-x86_64-linux) - google-protobuf (~> 3.25) - googleapis-common-protos-types (~> 1.0) - hashdiff (1.1.0) - hocon (1.4.0) - jgrep (1.5.4) - json-schema (2.8.1) - addressable (>= 2.4) - json-schema-rspec (0.0.4) - json-schema (~> 2.5) - rspec - listen (3.9.0) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - locale (2.1.4) - mcollective-test (0.4.3) - metaclass (0.0.4) - mocha (0.12.10) - metaclass (~> 0.0.1) - multi_json (1.15.0) - nats-pure (0.6.2) - net-http (0.4.1) - uri - parallel (1.25.1) - parser (3.3.3.0) - ast (~> 2.4.1) - racc - prime (0.1.2) - forwardable - singleton - psych (5.1.2) - stringio - public_suffix (6.0.0) - puppet (8.7.0) - concurrent-ruby (~> 1.0) - deep_merge (~> 1.0) - facter (>= 4.3.0, < 5) - fast_gettext (>= 2.1, < 3) - locale (~> 2.1) - multi_json (~> 1.13) - puppet-resource_api (~> 1.5) - scanf (~> 1.0) - semantic_puppet (~> 1.0) - puppet-resource_api (1.9.0) - hocon (>= 1.0) - racc (1.8.0) - rainbow (3.1.1) - rake (13.2.1) - rb-fsevent (0.11.2) - rb-inotify (0.11.1) - ffi (~> 1.0) - rdoc (6.7.0) - psych (>= 4.0.0) - regexp_parser (2.9.2) - rexml (3.3.1) - strscan - rspec (3.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-core (3.9.3) - rspec-support (~> 3.9.3) - rspec-expectations (3.9.4) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.4) - rubocop (1.6.1) - parallel (~> 1.10) - parser (>= 2.7.1.5) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.2.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (1.31.3) - parser (>= 3.3.1.0) - ruby-progressbar (1.13.0) - scanf (1.0.0) - semantic_puppet (1.1.0) - singleton (0.2.0) - stringio (3.1.1) - strscan (3.1.0) - systemu (2.6.5) - thor (1.2.2) - unicode-display_width (1.8.0) - uri (0.13.0) - webmock (3.23.1) - addressable (>= 2.8.0) - crack (>= 0.3.2) - hashdiff (>= 0.4.0, < 2.0.0) - yard (0.9.36) - -PLATFORMS - x86_64-linux - -DEPENDENCIES - choria-mcorpc-support - diplomat (~> 2) - etcdv3 - google-protobuf (= 3.25) - jgrep (>= 1.5.0) - json-schema-rspec - listen (~> 3) - mcollective-test - mocha (~> 0.12.2) - nats-pure (~> 0.6, < 0.7.0) - puppet (~> 8) - rake (>= 12.3.3) - rdoc - rspec (~> 3.9.0) - rubocop (= 1.6.1) - semantic_puppet - systemu (~> 2.6.4) - webmock - yard - -BUNDLED WITH - 2.4.19 From ce5cac33a1239dcc4e62c385f2222092a3118cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 3 Jul 2024 08:52:19 +0200 Subject: [PATCH 5/7] Puppet 8 require Ruby 3.1+ --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2a41941..ea8ff3d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,8 +15,6 @@ jobs: strategy: matrix: ruby-version: - - '2.7' - - '3.0' - '3.1' - '3.2' - '3.3' From 51736eead46bfa8f1ad19e8ed230ca3634321266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 14 Aug 2024 09:26:17 +0200 Subject: [PATCH 6/7] Attempt to trick Ruby 3.1 The error message seems mangled on GitHub action with some versions of Ruby. Not sure about the real root cause, but matching unitf a Regexp seems to help here. --- spec/unit/mcollective/pluginpackager_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/mcollective/pluginpackager_spec.rb b/spec/unit/mcollective/pluginpackager_spec.rb index 719189d1..e6fa3e4a 100644 --- a/spec/unit/mcollective/pluginpackager_spec.rb +++ b/spec/unit/mcollective/pluginpackager_spec.rb @@ -21,7 +21,7 @@ module MCollective it "should do something else" do expect{ PluginPackager["Bar"] - }.to raise_error(NameError, 'uninitialized constant MCollective::PluginPackager::Bar') + }.to raise_error(NameError, /uninitialized constant MCollective::PluginPackager::Bar/) end end From 067fd175fa0be190119bc4f2352d3987bdcb07a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 14 Aug 2024 09:44:02 +0200 Subject: [PATCH 7/7] Fix dubious test The readlines method of File always return an array (can be empty) if a file could be read, or raise a Errno::ENOENT if a file does not exist, Errno::EACCES if it cannot be read, etc. It seems to never return nil, and the stubbing is not working as expected with some versions of ruby. Adjust the test to align with what would happen in the real world. --- spec/unit/mcollective/util_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/unit/mcollective/util_spec.rb b/spec/unit/mcollective/util_spec.rb index 3759b241..67234550 100755 --- a/spec/unit/mcollective/util_spec.rb +++ b/spec/unit/mcollective/util_spec.rb @@ -68,9 +68,7 @@ module MCollective end it "should report a warning when the classes file cannot be parsed" do - File.stubs(:readlines).returns(nil) - Log.expects(:warn).with("Parsing classes file '/some/file' failed: NoMethodError: undefined method `each' for nil:NilClass") - + File.stubs(:readlines).raises("error") expect(Util.has_cf_class?("test_class_test")).to eq(false) end end