From e909868adc5674042e660a9362fd7b4d95d53787 Mon Sep 17 00:00:00 2001 From: Ramon Torres Date: Fri, 12 Jul 2024 19:23:57 -0700 Subject: [PATCH] Add support for Ruby 3.3 and drop 2.7 (#23) * Test on Ruby 3.3 * Update deps * Fixes * Lock with newer bundler * Drop Ruby 2.7 * Update target version in Rubocop * Fix * Fix * Fix * Update action version --- .github/workflows/ci.yml | 22 ++++++------ .github/workflows/install-test.yml | 30 ++++++++-------- .rubocop.yml | 2 +- Gemfile | 2 +- Gemfile.lock | 57 +++++++++++++++--------------- lib/stylegen/colors/color.rb | 4 +-- stylegen.gemspec | 8 ++--- test/test_base_elevated_color.rb | 2 +- test/test_cli.rb | 2 +- test/test_color.rb | 4 +-- test/test_light_dark_color.rb | 2 +- test/test_template.rb | 2 +- 12 files changed, 69 insertions(+), 68 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aec104d..81ee029 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,19 +13,19 @@ jobs: strategy: matrix: ruby-version: - - "2.7" - "3.0" - "3.1" - "3.2" + - "3.3" steps: - - uses: actions/checkout@v3 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - name: Lint - run: bundle exec rake rubocop - - name: Run tests - run: bundle exec rake + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Lint + run: bundle exec rake rubocop + - name: Run tests + run: bundle exec rake diff --git a/.github/workflows/install-test.yml b/.github/workflows/install-test.yml index b0eb5ad..569e033 100644 --- a/.github/workflows/install-test.yml +++ b/.github/workflows/install-test.yml @@ -13,23 +13,23 @@ jobs: strategy: matrix: ruby-version: - - "2.7" - "3.0" - "3.1" - "3.2" + - "3.3" steps: - - uses: actions/checkout@v3 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - name: 'Install' - run: bundle exec rake install - - name: 'Command: Version' - run: bundle exec stylegen version - - name: 'Command: Init' - run: bundle exec stylegen init - - name: 'Command: Build' - run: bundle exec stylegen build + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: "Install" + run: bundle exec rake install + - name: "Command: Version" + run: bundle exec stylegen version + - name: "Command: Init" + run: bundle exec stylegen init + - name: "Command: Build" + run: bundle exec stylegen build diff --git a/.rubocop.yml b/.rubocop.yml index 21fb2bb..500384a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ require: - rubocop-minitest AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 NewCops: enable Metrics/MethodLength: diff --git a/Gemfile b/Gemfile index 5ef2493..7bdee41 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ source 'https://rubygems.org' gemspec gem 'bundler' -gem 'minitest', '~> 5.14' +gem 'minitest', '~> 5.24' gem 'rake' gem 'rubocop' gem 'rubocop-minitest' diff --git a/Gemfile.lock b/Gemfile.lock index 6853cc5..41b32c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,63 +3,64 @@ PATH specs: stylegen (0.7.0) dry-cli (~> 1.0.0) - dry-inflector (~> 1.0.0) - json_schemer (~> 1.0.3) + dry-inflector (~> 1.1.0) + json_schemer (~> 2.3.0) GEM remote: https://rubygems.org/ specs: ast (2.4.2) + bigdecimal (3.1.8) dry-cli (1.0.0) - dry-inflector (1.0.0) + dry-inflector (1.1.0) hana (1.3.7) - json (2.6.3) - json_schemer (1.0.3) + json (2.7.2) + json_schemer (2.3.0) + bigdecimal hana (~> 1.3) regexp_parser (~> 2.0) simpleidn (~> 0.2) language_server-protocol (3.17.0.3) - minitest (5.18.1) - parallel (1.23.0) - parser (3.2.2.3) + minitest (5.24.1) + parallel (1.25.1) + parser (3.3.4.0) ast (~> 2.4.1) racc - racc (1.7.1) + racc (1.8.0) rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.8.1) - rexml (3.2.5) - rubocop (1.54.2) + rake (13.2.1) + regexp_parser (2.9.2) + rexml (3.3.1) + strscan + rubocop (1.65.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.3) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) + regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) - parser (>= 3.2.1.0) - rubocop-minitest (0.31.0) - rubocop (>= 1.39, < 2.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-minitest (0.35.1) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) ruby-progressbar (1.13.0) - simpleidn (0.2.1) - unf (~> 0.1.4) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) - unicode-display_width (2.4.2) + simpleidn (0.2.3) + strscan (3.1.0) + unicode-display_width (2.5.0) PLATFORMS ruby DEPENDENCIES bundler - minitest (~> 5.14) + minitest (~> 5.24) rake rubocop rubocop-minitest @@ -67,4 +68,4 @@ DEPENDENCIES stylegen! BUNDLED WITH - 2.1.4 + 2.5.15 diff --git a/lib/stylegen/colors/color.rb b/lib/stylegen/colors/color.rb index 7a95c40..6440ce1 100644 --- a/lib/stylegen/colors/color.rb +++ b/lib/stylegen/colors/color.rb @@ -6,8 +6,8 @@ module Stylegen class Color attr_reader :red, :green, :blue, :alpha - SIX_DIGIT_HEX_REGEX = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/.freeze - THREE_DIGIT_HEX_REGEX = /^#?([a-f\d])([a-f\d])([a-f\d])$/.freeze + SIX_DIGIT_HEX_REGEX = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/ + THREE_DIGIT_HEX_REGEX = /^#?([a-f\d])([a-f\d])([a-f\d])$/ MAX_PRECISION = 16 def initialize(red, green, blue, alpha) diff --git a/stylegen.gemspec b/stylegen.gemspec index 29613e8..d2fb70a 100644 --- a/stylegen.gemspec +++ b/stylegen.gemspec @@ -15,10 +15,10 @@ Gem::Specification.new do |s| s.require_paths = ['lib'] s.license = 'MIT' - s.add_runtime_dependency 'dry-cli', '~> 1.0.0' - s.add_runtime_dependency 'dry-inflector', '~> 1.0.0' - s.add_runtime_dependency 'json_schemer', '~> 1.0.3' + s.add_dependency 'dry-cli', '~> 1.0.0' + s.add_dependency 'dry-inflector', '~> 1.1.0' + s.add_dependency 'json_schemer', '~> 2.3.0' - s.required_ruby_version = '>= 2.7.0' + s.required_ruby_version = '>= 3.0.0' s.metadata['rubygems_mfa_required'] = 'true' end diff --git a/test/test_base_elevated_color.rb b/test/test_base_elevated_color.rb index e7e45b7..2d1b73b 100644 --- a/test/test_base_elevated_color.rb +++ b/test/test_base_elevated_color.rb @@ -2,7 +2,7 @@ require_relative 'helper' -class TestBaseElevatedColor < MiniTest::Test +class TestBaseElevatedColor < Minitest::Test def test_to_string color = Stylegen::BaseElevatedColor.new( Stylegen::Color.from_hex('#000000'), diff --git a/test/test_cli.rb b/test/test_cli.rb index e49c026..fa96caf 100644 --- a/test/test_cli.rb +++ b/test/test_cli.rb @@ -3,7 +3,7 @@ require 'open3' require_relative 'helper' -class TestCLI < MiniTest::Test +class TestCLI < Minitest::Test def test_version stdout, _stderr, status = Open3.capture3('bin/stylegen version') diff --git a/test/test_color.rb b/test/test_color.rb index 92b479e..bd6de58 100644 --- a/test/test_color.rb +++ b/test/test_color.rb @@ -2,7 +2,7 @@ require_relative 'helper' -class TestColor < MiniTest::Test +class TestColor < Minitest::Test def test_parsing color = Stylegen::Color.from_hex('#FF8000') @@ -49,7 +49,7 @@ def test_grayscale color = Stylegen::Color.new(1, 1, 0.9, 1) - refute_predicate color, :grayscale? + refute_predicate(color, :grayscale?) # skipcq: RB-RL1045 end def test_to_string diff --git a/test/test_light_dark_color.rb b/test/test_light_dark_color.rb index a4a8145..2d7e139 100644 --- a/test/test_light_dark_color.rb +++ b/test/test_light_dark_color.rb @@ -2,7 +2,7 @@ require_relative 'helper' -class TestLightDarkColor < MiniTest::Test +class TestLightDarkColor < Minitest::Test def test_to_string color = Stylegen::LightDarkColor.new( Stylegen::Color.from_hex('#FFFFFF'), diff --git a/test/test_template.rb b/test/test_template.rb index d8c2ccb..07c102c 100644 --- a/test/test_template.rb +++ b/test/test_template.rb @@ -3,7 +3,7 @@ require 'yaml' require_relative 'helper' -class TestTemplate < MiniTest::Test +class TestTemplate < Minitest::Test def test_render_appkit yaml_path = File.join(__dir__, 'fixtures', 'appkit.yaml') swift_path = File.join(__dir__, 'fixtures', 'appkit.swift')