Skip to content

Commit 217d3ca

Browse files
authored
Adjust spec matrix. (#899)
* Updates GH action matrix. * Improves Actions. * Loosens grape versions. - fixes run matrix - makes rubocop happy
1 parent e5090b6 commit 217d3ca

File tree

5 files changed

+105
-47
lines changed

5 files changed

+105
-47
lines changed

.github/workflows/ci.yml

Lines changed: 84 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Ruby
1+
name: RSpec
22

33
on:
44
push:
@@ -23,23 +23,98 @@ jobs:
2323
- name: Run rubocop
2424
run: bundle exec rubocop --parallel --format progress
2525

26-
rspec:
26+
grape-16:
2727
runs-on: ubuntu-latest
2828
needs: ['rubocop']
29+
env:
30+
GRAPE_VERSION: '1.6.2'
2931
strategy:
3032
matrix:
3133
ruby-version: ['3.0', '3.1', '3.2', 'head']
32-
grape-version: [1.6.2, 1.7.0]
33-
model-parser: [grape-swagger-entity, grape-swagger-representable, '']
3434
steps:
3535
- name: Check out branch
3636
uses: actions/checkout@v3
3737
- name: Set up Ruby
3838
uses: ruby/setup-ruby@v1
3939
with:
4040
ruby-version: ${{ matrix.ruby-version }}
41-
GRAPE_VERSION: ${{ matrix.grape-version }}
42-
MODEL_PARSER: ${{ matrix.model-parser }}
43-
bundler-cache: true
44-
- name: Run rspec rest of the suite
45-
run: bundle exec rspec
41+
- name: Run rspec wo model parser
42+
run: |
43+
bundle update
44+
bundle exec rspec
45+
- name: Run rspec w entity parser
46+
env:
47+
MODEL_PARSER: grape-swagger-entity
48+
run: |
49+
bundle update
50+
bundle exec rspec
51+
- name: Run rspec w representable parser
52+
env:
53+
MODEL_PARSER: grape-swagger-representable
54+
run: |
55+
bundle update
56+
bundle exec rspec
57+
58+
grape-17:
59+
runs-on: ubuntu-latest
60+
needs: ['rubocop']
61+
env:
62+
GRAPE_VERSION: '1.7.1'
63+
strategy:
64+
matrix:
65+
ruby-version: ['3.0', '3.1', '3.2', 'head']
66+
steps:
67+
- name: Check out branch
68+
uses: actions/checkout@v3
69+
- name: Set up Ruby
70+
uses: ruby/setup-ruby@v1
71+
with:
72+
ruby-version: ${{ matrix.ruby-version }}
73+
- name: Run rspec wo model parser
74+
run: |
75+
bundle update
76+
bundle exec rspec
77+
- name: Run rspec w entity parser
78+
env:
79+
MODEL_PARSER: grape-swagger-entity
80+
run: |
81+
bundle update
82+
bundle exec rspec
83+
- name: Run rspec w representable parser
84+
env:
85+
MODEL_PARSER: grape-swagger-representable
86+
run: |
87+
bundle update
88+
bundle exec rspec
89+
90+
grape-HEAD:
91+
runs-on: ubuntu-latest
92+
needs: ['rubocop']
93+
env:
94+
GRAPE_VERSION: 'HEAD'
95+
strategy:
96+
matrix:
97+
ruby-version: ['3.0', '3.1', '3.2', 'head']
98+
steps:
99+
- name: Check out branch
100+
uses: actions/checkout@v3
101+
- name: Set up Ruby
102+
uses: ruby/setup-ruby@v1
103+
with:
104+
ruby-version: ${{ matrix.ruby-version }}
105+
- name: Run rspec wo model parser
106+
run: |
107+
bundle update
108+
bundle exec rspec
109+
- name: Run rspec w entity parser
110+
env:
111+
MODEL_PARSER: grape-swagger-entity
112+
run: |
113+
bundle update
114+
bundle exec rspec
115+
- name: Run rspec w representable parser
116+
env:
117+
MODEL_PARSER: grape-swagger-representable
118+
run: |
119+
bundle update
120+
bundle exec rspec

.rubocop_todo.yml

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2022-01-14 10:22:29 UTC using RuboCop version 1.24.1.
3+
# on 2023-05-20 18:23:47 UTC using RuboCop version 1.51.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

99
# Offense count: 1
10-
# Cop supports --auto-correct.
11-
# Configuration parameters: Include.
12-
# Include: **/*.gemspec
13-
Gemspec/RequireMFA:
14-
Exclude:
15-
- 'grape-swagger.gemspec'
16-
17-
# Offense count: 1
18-
# Configuration parameters: Include.
10+
# Configuration parameters: Severity, Include.
1911
# Include: **/*.gemspec
2012
Gemspec/RequiredRubyVersion:
2113
Exclude:
2214
- 'grape-swagger.gemspec'
2315

24-
# Offense count: 31
25-
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
16+
# Offense count: 32
17+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
2618
Metrics/AbcSize:
2719
Max: 56
2820

2921
# Offense count: 30
30-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
22+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
3123
Metrics/MethodLength:
3224
Max: 28
3325

34-
# Offense count: 7
35-
# Configuration parameters: IgnoredMethods.
26+
# Offense count: 8
27+
# Configuration parameters: AllowedMethods, AllowedPatterns.
3628
Metrics/PerceivedComplexity:
3729
Max: 16
3830

@@ -41,20 +33,13 @@ Style/ClassVars:
4133
Exclude:
4234
- 'lib/grape-swagger/doc_methods.rb'
4335

36+
# Offense count: 1
37+
# This cop supports unsafe autocorrection (--autocorrect-all).
38+
Style/CollectionCompact:
39+
Exclude:
40+
- 'lib/grape-swagger/endpoint.rb'
41+
4442
# Offense count: 23
4543
# Configuration parameters: AllowedConstants.
4644
Style/Documentation:
4745
Enabled: false
48-
49-
# Offense count: 43
50-
Style/OpenStructUse:
51-
Exclude:
52-
- 'spec/lib/endpoint_spec.rb'
53-
- 'spec/lib/version_spec.rb'
54-
- 'spec/support/mock_parser.rb'
55-
- 'spec/support/model_parsers/mock_parser.rb'
56-
- 'spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb'
57-
- 'spec/swagger_v2/api_swagger_v2_mounted_spec.rb'
58-
- 'spec/swagger_v2/api_swagger_v2_spec.rb'
59-
- 'spec/swagger_v2/errors_spec.rb'
60-
- 'spec/swagger_v2/reference_entity_spec.rb'

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ group :development, :test do
1919
gem 'pry', platforms: [:mri]
2020
gem 'pry-byebug', platforms: [:mri]
2121

22-
gem 'rack', '~> 3.0'
22+
gem 'rack'
2323
gem 'rack-cors'
2424
gem 'rack-test'
2525
gem 'rake'
2626
gem 'rdoc'
2727
gem 'rspec', '~> 3.9'
28-
gem 'rubocop', '~> 1.0', require: false
28+
gem 'rubocop', '~> 1.50', require: false
2929
gem 'webrick'
3030
end
3131

lib/grape-swagger/doc_methods/format_data.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ def add_array(parameter, related_parameters)
3939

4040
p_type = p[:type] == 'array' ? 'string' : p[:type]
4141
p[:items] = { type: p_type, format: p[:format], enum: p[:enum], is_array: p[:is_array] }
42-
p[:items].delete_if { |_k, v| v.nil? }
42+
p[:items].compact!
4343
p[:type] = 'array'
4444
p[:is_array] = parameter[:is_array]
4545
p.delete(:format)
4646
p.delete(:enum)
47-
p.delete_if { |_k, v| v.nil? }
47+
p.compact!
4848
end
4949
end
5050
end

spec/swagger_v2/api_documentation_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
end
1919

2020
it 'documents api' do
21-
expect(subject).to eq(
22-
[
23-
{ description: 'Swagger compatible API description' },
24-
{ description: 'Swagger compatible API description for specific API', params: {} }
25-
]
26-
)
21+
expect(subject.pluck(:description)).to match_array [
22+
'Swagger compatible API description',
23+
'Swagger compatible API description for specific API'
24+
]
2725
end
2826
end

0 commit comments

Comments
 (0)