Adjust spec matrix. (#899)

* Updates GH action matrix.

* Improves Actions.

* Loosens grape versions.

- fixes run matrix
- makes rubocop happy
This commit is contained in:
peter scholz 2023-05-21 00:31:00 +02:00 committed by GitHub
parent e5090b66ac
commit 217d3ca3f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 105 additions and 47 deletions

View File

@ -1,4 +1,4 @@
name: Ruby
name: RSpec
on:
push:
@ -23,14 +23,14 @@ jobs:
- name: Run rubocop
run: bundle exec rubocop --parallel --format progress
rspec:
grape-16:
runs-on: ubuntu-latest
needs: ['rubocop']
env:
GRAPE_VERSION: '1.6.2'
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2', 'head']
grape-version: [1.6.2, 1.7.0]
model-parser: [grape-swagger-entity, grape-swagger-representable, '']
steps:
- name: Check out branch
uses: actions/checkout@v3
@ -38,8 +38,83 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
GRAPE_VERSION: ${{ matrix.grape-version }}
MODEL_PARSER: ${{ matrix.model-parser }}
bundler-cache: true
- name: Run rspec rest of the suite
run: bundle exec rspec
- name: Run rspec wo model parser
run: |
bundle update
bundle exec rspec
- name: Run rspec w entity parser
env:
MODEL_PARSER: grape-swagger-entity
run: |
bundle update
bundle exec rspec
- name: Run rspec w representable parser
env:
MODEL_PARSER: grape-swagger-representable
run: |
bundle update
bundle exec rspec
grape-17:
runs-on: ubuntu-latest
needs: ['rubocop']
env:
GRAPE_VERSION: '1.7.1'
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2', 'head']
steps:
- name: Check out branch
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Run rspec wo model parser
run: |
bundle update
bundle exec rspec
- name: Run rspec w entity parser
env:
MODEL_PARSER: grape-swagger-entity
run: |
bundle update
bundle exec rspec
- name: Run rspec w representable parser
env:
MODEL_PARSER: grape-swagger-representable
run: |
bundle update
bundle exec rspec
grape-HEAD:
runs-on: ubuntu-latest
needs: ['rubocop']
env:
GRAPE_VERSION: 'HEAD'
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2', 'head']
steps:
- name: Check out branch
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Run rspec wo model parser
run: |
bundle update
bundle exec rspec
- name: Run rspec w entity parser
env:
MODEL_PARSER: grape-swagger-entity
run: |
bundle update
bundle exec rspec
- name: Run rspec w representable parser
env:
MODEL_PARSER: grape-swagger-representable
run: |
bundle update
bundle exec rspec

View File

@ -1,38 +1,30 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-01-14 10:22:29 UTC using RuboCop version 1.24.1.
# on 2023-05-20 18:23:47 UTC using RuboCop version 1.51.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequireMFA:
Exclude:
- 'grape-swagger.gemspec'
# Offense count: 1
# Configuration parameters: Include.
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'grape-swagger.gemspec'
# Offense count: 31
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
# Offense count: 32
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 56
# Offense count: 30
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 28
# Offense count: 7
# Configuration parameters: IgnoredMethods.
# Offense count: 8
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 16
@ -41,20 +33,13 @@ Style/ClassVars:
Exclude:
- 'lib/grape-swagger/doc_methods.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CollectionCompact:
Exclude:
- 'lib/grape-swagger/endpoint.rb'
# Offense count: 23
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false
# Offense count: 43
Style/OpenStructUse:
Exclude:
- 'spec/lib/endpoint_spec.rb'
- 'spec/lib/version_spec.rb'
- 'spec/support/mock_parser.rb'
- 'spec/support/model_parsers/mock_parser.rb'
- 'spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb'
- 'spec/swagger_v2/api_swagger_v2_mounted_spec.rb'
- 'spec/swagger_v2/api_swagger_v2_spec.rb'
- 'spec/swagger_v2/errors_spec.rb'
- 'spec/swagger_v2/reference_entity_spec.rb'

View File

@ -19,13 +19,13 @@ group :development, :test do
gem 'pry', platforms: [:mri]
gem 'pry-byebug', platforms: [:mri]
gem 'rack', '~> 3.0'
gem 'rack'
gem 'rack-cors'
gem 'rack-test'
gem 'rake'
gem 'rdoc'
gem 'rspec', '~> 3.9'
gem 'rubocop', '~> 1.0', require: false
gem 'rubocop', '~> 1.50', require: false
gem 'webrick'
end

View File

@ -39,12 +39,12 @@ module GrapeSwagger
p_type = p[:type] == 'array' ? 'string' : p[:type]
p[:items] = { type: p_type, format: p[:format], enum: p[:enum], is_array: p[:is_array] }
p[:items].delete_if { |_k, v| v.nil? }
p[:items].compact!
p[:type] = 'array'
p[:is_array] = parameter[:is_array]
p.delete(:format)
p.delete(:enum)
p.delete_if { |_k, v| v.nil? }
p.compact!
end
end
end

View File

@ -18,11 +18,9 @@ describe 'API with additional options' do
end
it 'documents api' do
expect(subject).to eq(
[
{ description: 'Swagger compatible API description' },
{ description: 'Swagger compatible API description for specific API', params: {} }
]
)
expect(subject.pluck(:description)).to match_array [
'Swagger compatible API description',
'Swagger compatible API description for specific API'
]
end
end