From 326b5606bd2cd29209446682e26d477ec235dbd1 Mon Sep 17 00:00:00 2001 From: Sai Kumar Kotagiri Date: Mon, 13 Nov 2023 13:27:48 -0500 Subject: [PATCH] adds ruby testing matrix, upgrades gems and code to support multiple versions of ruby (#153) * testing ruby matrix * remove require pry * Adjusting versions for build matrix. * use YAML.load to support Ruby version 3.2.x * upgrades timecop to support Ruby 3.1.4 * removes old rspec github workflow file --------- Co-authored-by: Trey Evans --- .github/workflows/rspec.yml | 32 +++++++ .github/workflows/tests.yml | 35 ------- .ruby-version | 2 +- Gemfile.lock | 95 +++++++++---------- lib/resource_registry.rb | 1 - .../serializers/yaml/deserialize.rb | 2 +- resource_registry.gemspec | 30 ++---- spec/spec_helper.rb | 1 - 8 files changed, 87 insertions(+), 111 deletions(-) create mode 100644 .github/workflows/rspec.yml delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml new file mode 100644 index 00000000..278f537f --- /dev/null +++ b/.github/workflows/rspec.yml @@ -0,0 +1,32 @@ +name: RSpec +on: push + +jobs: + rspec: + strategy: + fail-fast: false + matrix: + ruby_version: ['2.6.3', '2.7.6', '3.0.5', '3.1.4', '3.2.2'] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: wbari/start-mongoDB@v0.2 + with: + mongoDBVersion: '4.2' + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + - name: Cache Gems + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-${{matrix.ruby_version}}-resource_registry-gems-${{ hashFiles('**/Gemfile.lock') }}-${{ hashFiles('**/Gemfile' ) }} + restore-keys: | + ${{ runner.os }}-${{matrix.ruby_version}}-resource_registry-gems-${{ hashFiles('**/Gemfile.lock') }}-${{ hashFiles('**/Gemfile' ) }} + - name: bundle install + run: | + bundle config path vendor/bundle + bundle install + - name: run tests + run: | + bundle exec rspec \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index ef132b26..00000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Tests - -on: push - -env: - SHA: ${{ github.sha }} - BRANCH: ${{ github.ref }} - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Set up Ruby 2.5.1 - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.5.1 - - name: Cache Gems - uses: actions/cache@v1 - with: - path: vendor/bundle - key: ${{ runner.os }}-resource_registry-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-resource_registry-${{ hashFiles('**/Gemfile.lock') }} - - name: Install Gems - run: | - gem install bundler -v '2.0.2' - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 - - name: Run RSpec - run: | - bundle exec rspec - - name: Run Rubocop - run: | - bundle exec rubocop diff --git a/.ruby-version b/.ruby-version index 73462a5a..6a81b4c8 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.1 +2.7.8 diff --git a/Gemfile.lock b/Gemfile.lock index 79623493..5d4fa7b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,19 +4,16 @@ PATH resource_registry (0.7.0) bootsnap (~> 1.0) deep_merge (>= 1.0.0) - dry-configurable (= 0.9) - dry-container (~> 0.7) + dry-configurable (~> 0.12) + dry-container (~> 0.9) dry-matcher (~> 0.7) - dry-monads (~> 1.2) + dry-monads (~> 1.3) dry-struct (~> 1.0) dry-types (~> 1.0) dry-validation (~> 1.2) i18n (>= 0.7.0) - loofah (>= 2.3.1) mime-types - nokogiri (>= 1.9.1) ox (~> 2.0) - rack (>= 1.6.13) GEM remote: https://rubygems.org/ @@ -42,8 +39,8 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) ast (2.4.0) - bootsnap (1.4.6) - msgpack (~> 1.0) + bootsnap (1.17.0) + msgpack (~> 1.2) bson (4.8.2) builder (3.2.4) byebug (11.1.3) @@ -51,57 +48,50 @@ GEM concurrent-ruby (1.1.6) crass (1.0.6) database_cleaner (1.8.4) - deep_merge (1.2.1) + deep_merge (1.2.2) diff-lcs (1.3) docile (1.3.2) - dry-configurable (0.9.0) + dry-configurable (0.13.0) concurrent-ruby (~> 1.0) - dry-core (~> 0.4, >= 0.4.7) - dry-container (0.7.2) + dry-core (~> 0.6) + dry-container (0.9.0) concurrent-ruby (~> 1.0) - dry-configurable (~> 0.1, >= 0.1.3) - dry-core (0.4.9) + dry-configurable (~> 0.13, >= 0.13.0) + dry-core (0.7.1) concurrent-ruby (~> 1.0) - dry-equalizer (0.3.0) - dry-inflector (0.2.0) - dry-initializer (3.0.3) - dry-logic (1.0.6) + dry-inflector (0.2.1) + dry-initializer (3.0.4) + dry-logic (1.2.0) concurrent-ruby (~> 1.0) - dry-core (~> 0.2) - dry-equalizer (~> 0.2) - dry-matcher (0.8.3) - dry-core (>= 0.4.8) - dry-monads (1.3.5) + dry-core (~> 0.5, >= 0.5) + dry-matcher (0.9.0) + dry-core (~> 0.4, >= 0.4.8) + dry-monads (1.4.0) concurrent-ruby (~> 1.0) - dry-core (~> 0.4, >= 0.4.4) - dry-equalizer - dry-schema (1.5.0) + dry-core (~> 0.7) + dry-schema (1.8.0) concurrent-ruby (~> 1.0) - dry-configurable (~> 0.8, >= 0.8.3) - dry-core (~> 0.4) - dry-equalizer (~> 0.2) + dry-configurable (~> 0.13, >= 0.13.0) + dry-core (~> 0.5, >= 0.5) dry-initializer (~> 3.0) dry-logic (~> 1.0) - dry-types (~> 1.4) - dry-struct (1.3.0) - dry-core (~> 0.4, >= 0.4.4) - dry-equalizer (~> 0.3) - dry-types (~> 1.3) + dry-types (~> 1.5) + dry-struct (1.4.0) + dry-core (~> 0.5, >= 0.5) + dry-types (~> 1.5) ice_nine (~> 0.11) - dry-types (1.4.0) + dry-types (1.5.1) concurrent-ruby (~> 1.0) dry-container (~> 0.3) - dry-core (~> 0.4, >= 0.4.4) - dry-equalizer (~> 0.3) + dry-core (~> 0.5, >= 0.5) dry-inflector (~> 0.1, >= 0.1.2) dry-logic (~> 1.0, >= 1.0.2) - dry-validation (1.5.0) + dry-validation (1.7.0) concurrent-ruby (~> 1.0) dry-container (~> 0.7, >= 0.7.1) - dry-core (~> 0.4) - dry-equalizer (~> 0.2) + dry-core (~> 0.5, >= 0.5) dry-initializer (~> 3.0) - dry-schema (~> 1.5) + dry-schema (~> 1.8, >= 1.8.0) erubi (1.9.0) i18n (1.8.2) concurrent-ruby (~> 1.0) @@ -111,20 +101,21 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.5.9) method_source (0.9.2) - mime-types (3.3.1) + mime-types (3.5.1) mime-types-data (~> 3.2015) - mime-types-data (3.2020.0425) - mini_portile2 (2.4.0) + mime-types-data (3.2023.1003) + mini_portile2 (2.8.5) minitest (5.14.0) mongo (2.12.1) bson (>= 4.8.2, < 5.0.0) mongoid (6.4.4) activemodel (>= 5.1, < 6.0.0) mongo (>= 2.5.1, < 3.0.0) - msgpack (1.3.3) - nokogiri (1.10.9) - mini_portile2 (~> 2.4.0) - ox (2.13.2) + msgpack (1.7.2) + nokogiri (1.13.10) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) + ox (2.14.14) parallel (1.19.1) parser (2.7.1.1) ast (~> 2.4.0) @@ -134,6 +125,7 @@ GEM pry-byebug (3.8.0) byebug (~> 11.0) pry (~> 0.10) + racc (1.7.1) rack (2.2.2) rack-test (1.1.0) rack (>= 1.0, < 3) @@ -185,7 +177,7 @@ GEM simplecov-html (0.12.2) thor (1.0.1) thread_safe (0.3.6) - timecop (0.9.1) + timecop (0.9.8) tzinfo (1.2.7) thread_safe (~> 0.1) unicode-display_width (1.6.1) @@ -195,7 +187,6 @@ PLATFORMS ruby DEPENDENCIES - actionview (>= 5.2.4.2) activesupport (~> 5.2.4) bundler (~> 2.0) database_cleaner (~> 1.7) @@ -207,8 +198,8 @@ DEPENDENCIES rspec-rails (~> 3.9) rubocop (~> 0.74.0) simplecov - timecop (~> 0.9) + timecop (~> 0.9.8) yard (~> 0.9) BUNDLED WITH - 2.0.2 + 2.4.17 diff --git a/lib/resource_registry.rb b/lib/resource_registry.rb index f262aba5..80bfa70a 100644 --- a/lib/resource_registry.rb +++ b/lib/resource_registry.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'dry/validation' -require 'dry/monads/result' require 'dry/monads' require 'dry/monads/do' diff --git a/lib/resource_registry/serializers/yaml/deserialize.rb b/lib/resource_registry/serializers/yaml/deserialize.rb index 0d3ab550..74881724 100644 --- a/lib/resource_registry/serializers/yaml/deserialize.rb +++ b/lib/resource_registry/serializers/yaml/deserialize.rb @@ -21,7 +21,7 @@ def call(params) def transform(params) # result = JSON.parse(ERB.new(JSON::dump(YAML.load(params))).result) - result = YAML.safe_load(ERB.new(params).result, [Symbol]) + result = YAML.load(ERB.new(params).result) Success(result || {}) rescue Psych::SyntaxError => e raise "YAML syntax error occurred while parsing #{params}. " \ diff --git a/resource_registry.gemspec b/resource_registry.gemspec index 9112e5ba..be74edc0 100644 --- a/resource_registry.gemspec +++ b/resource_registry.gemspec @@ -34,37 +34,27 @@ Gem::Specification.new do |spec| spec.add_dependency 'dry-validation', '~> 1.2' spec.add_dependency 'dry-struct', '~> 1.0' spec.add_dependency 'dry-types', '~> 1.0' - spec.add_dependency 'dry-configurable', '0.9' - - spec.add_dependency 'dry-container', '~> 0.7' - spec.add_dependency 'deep_merge', '>= 1.0.0' - - # Dependency gems added for security purposes - spec.add_dependency 'nokogiri', ">= 1.9.1" - spec.add_dependency "rack", ">= 1.6.13" - spec.add_dependency 'dry-monads', '~> 1.2' + spec.add_dependency 'dry-configurable', '~> 0.12' + spec.add_dependency 'dry-monads', '~> 1.3' spec.add_dependency 'dry-matcher', '~> 0.7' - - spec.add_dependency "loofah", ">= 2.3.1" - spec.add_development_dependency "actionview", ">= 5.2.4.2" - # end of dependency gem security updates - + spec.add_dependency 'dry-container', '~> 0.9' + spec.add_dependency 'deep_merge', '>= 1.0.0' spec.add_dependency 'i18n', '>= 0.7.0' spec.add_dependency 'ox', '~> 2.0' spec.add_dependency 'bootsnap', '~> 1.0' spec.add_dependency 'mime-types' - spec.add_development_dependency "bundler", "~> 2.0" + spec.add_development_dependency 'bundler', '~> 2.0' spec.add_development_dependency 'rake', '~> 12.0' spec.add_development_dependency 'rspec', '~> 3.9' spec.add_development_dependency 'rspec-rails', '~> 3.9' spec.add_development_dependency 'mongoid', '~> 6.0' spec.add_development_dependency 'activesupport', '~> 5.2.4' - spec.add_development_dependency "simplecov" #, '~> 1.0' - spec.add_development_dependency "database_cleaner", '~> 1.7' - spec.add_development_dependency "timecop", '~> 0.9' - spec.add_development_dependency "rubocop", '~> 0.74.0' - spec.add_development_dependency "yard", "~> 0.9" + spec.add_development_dependency 'simplecov' + spec.add_development_dependency 'database_cleaner', '~> 1.7' + spec.add_development_dependency 'timecop', '~> 0.9.8' + spec.add_development_dependency 'rubocop', '~> 0.74.0' + spec.add_development_dependency 'yard', '~> 0.9' spec.add_development_dependency 'pry-byebug' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index eff77b55..1dfd6079 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,6 @@ require "bundler/setup" require 'resource_registry' -require 'pry' # Custom matcher for dry-validation schema specs require "support/matchers/match_schema"