diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 994925a2..7b2d8a21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ permissions: jobs: rubocop: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # no ubuntu-26.04 builds of Ruby 3.0/3.1 yet; revisit when ubuntu-latest moves steps: - uses: actions/checkout@v7 - uses: ruby/setup-ruby@v1 @@ -24,11 +24,11 @@ jobs: run: bundle exec rubocop --parallel --format progress rspec: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # no ubuntu-26.04 builds of Ruby 3.0/3.1 yet; revisit when ubuntu-latest moves needs: ['rubocop'] strategy: matrix: - ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4'] + ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4', '4.0'] steps: - name: Check out branch uses: actions/checkout@v7 diff --git a/.github/workflows/danger-comment.yml b/.github/workflows/danger-comment.yml index 8e15cb6c..02a589d2 100644 --- a/.github/workflows/danger-comment.yml +++ b/.github/workflows/danger-comment.yml @@ -7,5 +7,5 @@ on: jobs: comment: - uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0 + uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.1 secrets: inherit diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index bd89a888..c510cdac 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -6,7 +6,7 @@ on: jobs: danger: - uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.0 + uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.1 secrets: inherit with: ruby-version: '3.4' diff --git a/CHANGELOG.md b/CHANGELOG.md index d997acc4..8442405c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -### Next release +### 1.1.1 (Next) #### Fixes +* [#411](https://github.com/ruby-grape/grape-entity/pull/411): Fix CI on Ruby 3.0 (pin `json` below 3.0, `git` below 6, newer RuboCop directives), add Ruby 4.0 to the test matrix - [@numbata](https://github.com/numbata). * Your contribution here. #### Features diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6023a84e..77750c1c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,7 +52,7 @@ Document any external behavior in the [README](README.md). #### Update Changelog -Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account. +Add a line to [CHANGELOG](CHANGELOG.md) under the unreleased `(Next)` section. Make it look like every other line, including your name and link to your Github account. #### Commit Changes diff --git a/Gemfile b/Gemfile index c3a69c50..79caf54f 100644 --- a/Gemfile +++ b/Gemfile @@ -6,13 +6,16 @@ gemspec group :development, :test do gem 'bundler' + # activesupport 7.1 (the newest on Ruby 3.0) passes `quirks_mode:` to JSON.generate, which json 3.0 removed + gem 'json', '< 3.0' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1') gem 'maruku' + gem 'ostruct' # no longer a default gem in Ruby 4.0 gem 'pry' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx') gem 'pry-byebug' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx') gem 'rack-test' gem 'rake' gem 'rspec', '~> 3.9' - gem 'rubocop', '~> 1.0' + gem 'rubocop', '~> 1.90' # the disable-next directive needs 1.90 gem 'yard' end @@ -21,6 +24,8 @@ group :test do gem 'danger', require: false gem 'danger-changelog', require: false gem 'danger-pr-comment', require: false + # danger 9.6 references Git::Base, which git 6 no longer loads eagerly; drop once danger supports git 6 + gem 'git', '< 6' gem 'growl' gem 'guard' gem 'guard-bundler' diff --git a/RELEASING.md b/RELEASING.md index 85d736da..3a0f3fa1 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -19,7 +19,7 @@ Increment the version, modify [lib/grape-entity/version.rb](lib/grape-entity/ver * Increment the third number if the release has bug fixes and/or very minor features, only (eg. change `0.5.1` to `0.5.2`). * Increment the second number if the release contains major features or breaking API changes (eg. change `0.5.1` to `0.4.0`). -Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version. +Change the "(Next)" heading in [CHANGELOG.md](CHANGELOG.md) to the new version and release date. ``` 0.4.0 (2014-01-27) @@ -52,8 +52,13 @@ Pushed grape-entity 0.4.0 to rubygems.org. Add the next release to [CHANGELOG.md](CHANGELOG.md). ``` -Next Release -============ +### X.Y.Z (Next) + +#### Fixes + +* Your contribution here. + +#### Features * Your contribution here. ``` diff --git a/lib/grape_entity/entity.rb b/lib/grape_entity/entity.rb index 4b409c13..93c87c08 100644 --- a/lib/grape_entity/entity.rb +++ b/lib/grape_entity/entity.rb @@ -190,7 +190,7 @@ def self.inherited(subclass) # field, typically the value is a hash with two fields, type and desc. # @option options :merge This option allows you to merge an exposed field to the root # - # rubocop:disable Layout/LineLength + # rubocop:disable-next Layout/LineLength def self.expose(*args, &block) options = merge_options(args.last.is_a?(Hash) ? args.pop : {}) @@ -217,7 +217,6 @@ def self.expose(*args, &block) @nesting_stack ||= [] args.each { |attribute| build_exposure_for_attribute(attribute, @nesting_stack, options, block) } end - # rubocop:enable Layout/LineLength def self.build_exposure_for_attribute(attribute, nesting_stack, options, block) exposure_list = nesting_stack.empty? ? root_exposures : nesting_stack.last.nested_exposures diff --git a/lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb b/lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb index 80076ed8..72752377 100644 --- a/lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb +++ b/lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb @@ -36,7 +36,7 @@ def clear @exposures.clear end - # rubocop:disable Style/DocumentDynamicEvalDefinition + # rubocop:disable-next Style/DocumentDynamicEvalDefinition %i[ each to_ary to_a @@ -56,7 +56,6 @@ def #{name}(*args, &block) end RUBY end - # rubocop:enable Style/DocumentDynamicEvalDefinition # Determine if we have any nesting exposures with the same name. def deep_complex_nesting?(entity) diff --git a/spec/grape_entity/entity_spec.rb b/spec/grape_entity/entity_spec.rb index aa497857..446b30e3 100644 --- a/spec/grape_entity/entity_spec.rb +++ b/spec/grape_entity/entity_spec.rb @@ -33,13 +33,12 @@ end it 'makes sure that :format_with as a proc cannot be used with a block' do - # rubocop:disable Style/BlockDelimiters + # rubocop:disable-next Style/BlockDelimiters expect { subject.expose :name, format_with: proc {} do p 'hi' end }.to raise_error ArgumentError - # rubocop:enable Style/BlockDelimiters end it 'makes sure unknown options are not silently ignored' do @@ -2294,12 +2293,11 @@ class FriendEntity < Grape::Entity end end - # rubocop:disable Lint/EmptyBlock + # rubocop:disable-next Lint/EmptyBlock fresh_class.class_eval do expose :first_friend, using: EntitySpec::FriendEntity do |_user, _opts| end end - # rubocop:enable Lint/EmptyBlock rep = subject.value_for(:first_friend) expect(rep).to be_kind_of EntitySpec::FriendEntity