rufo 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87b9e11a2d83bf366134074b750fca515da61d65c626ad4a85cb029b3246f314
4
- data.tar.gz: 5f2caf3f22b5b7e8411e7a35f9e73c27bfd7a92f7f8246f3099ed98ecacef359
3
+ metadata.gz: '050197c783154878217024914afe1fc208e624521b5c3c1c4cd182c29ce70795'
4
+ data.tar.gz: 8ec88b8b3bc5fa60afbfa7eb7bcf395a2dd906c2b51e2c256d9f11876540279f
5
5
  SHA512:
6
- metadata.gz: 00742ceee28433e130ccceffd31ee41a8a827135d3f986f552d42821e62acc6b5a7c795771c5bdea5ec46069374a1ca014f964ca21fcd425240ffeedc101b72f
7
- data.tar.gz: ade0daa5611c2cbe51f9bf59de4df7750aaac6ecec829eaad97b9f478cba2d5f5a4671ac054c9d2850f5b1758b07881b51474e94a1cbe754f02a6348ccaa1607
6
+ metadata.gz: 7cce9d7529456084473d761247402c659950460bb75155d3689d8c89bc89993793d9638fc0bc47d45a40d97eaf2d06d13c175f1db0aeef1356ad12a8124f5bfe
7
+ data.tar.gz: f4e46d300e1a94fc05c1d2aaa99ea6f24fa244faba984e8841f9874e5326ef324cc38b915008948156ec5825c572024dc0e57a0600f6b235fe06f7b7f3695e60
@@ -0,0 +1,60 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ schedule:
9
+ - cron: '0 0 * * 0'
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby_version: ['3.2', '3.1', '3.0', '2.7']
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+
21
+ - name: Setup Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby_version }}
25
+ bundler-cache: true
26
+
27
+ - name: Bundle update
28
+ run: |
29
+ bundle update
30
+
31
+ - name: Run test
32
+ run: |
33
+ bundle exec rspec --profile 10 \
34
+ --format RspecJunitFormatter \
35
+ --out test_results/rspec.xml \
36
+ --format progress
37
+
38
+ - name: Upload code coverage
39
+ uses: codecov/codecov-action@v3
40
+ with:
41
+ files: ./coverage/coverage.xml
42
+
43
+ - name: Run rubocop
44
+ run: |
45
+ bundle exec rake rubocop
46
+
47
+ - name: Run rufo
48
+ run: |
49
+ bundle exec rake rufo:run
50
+
51
+ - name: Verify rufo works against sample codebases
52
+ run: |
53
+ bin/verify-sample-code
54
+
55
+ - name: Save test results
56
+ uses: actions/upload-artifact@v3
57
+ if: always()
58
+ with:
59
+ name: coverage-ruby-${{ matrix.ruby_version }}
60
+ path: coverage
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /*.gem
11
+ /.ruby-version
11
12
 
12
13
  # rspec failure tracking
13
14
  .rspec_status
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ AllCops:
2
2
  Exclude:
3
3
  - "spec/**/*"
4
4
  - "vendor/**/*"
5
- TargetRubyVersion: 2.4
5
+ TargetRubyVersion: 2.7
6
6
 
7
7
  Layout:
8
8
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -12,9 +12,41 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
12
12
 
13
13
  ### Added
14
14
 
15
+ ## [0.14.0] - 2023-01-25
16
+
17
+ ### Fixed
18
+
19
+ - Correctly interpret erb scriptlets with more than one control-flow/block statement
20
+
21
+ ### Changed
22
+
23
+ - Dropped support for Ruby 2.6 as it is end of life.
24
+
25
+ ### Added
26
+
27
+ - Support for partial argument forwarding. (issue [268](https://github.com/ruby-formatter/rufo/issues/268))
28
+ - Support for endless method. (issue [271](https://github.com/ruby-formatter/rufo/issues/271))
29
+ - Add Ruby 3.2.0 to test runs on CI.
30
+
31
+ ## [0.13.0] - 2021-05-07
32
+
33
+ ### Fixed
34
+
35
+ - Properly format comma when a heredoc is passed as a call argument
36
+ - Correctly interpret case statements with multiple when clauses in ERB files
37
+
38
+ ### Changed
39
+
40
+ - Dropped support for Ruby 2.4 and 2.5 as they are end of life.
41
+
42
+ ### Added
43
+
44
+ - Add Ruby 3.0.1 to test runs on CI.
45
+
15
46
  ## [0.12.0] - 2020-03-08
16
47
 
17
48
  ### Fixed
49
+
18
50
  - File.read default encode UTF-8
19
51
  - Handle case where the code is invalid but ripper does not raise an error.
20
52
  - Removed implicit dependency on `rake`.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rufo
2
2
 
3
- [![CircleCI](https://circleci.com/gh/ruby-formatter/rufo.svg?style=svg)](https://circleci.com/gh/ruby-formatter/rufo)
3
+ [![GitHub Actions](https://github.com/ruby-formatter/rufo/workflows/CI/badge.svg)](https://github.com/ruby-formatter/rufo/actions/workflows/ci.yml)
4
4
  [![Gem](https://img.shields.io/gem/v/rufo.svg)](https://rubygems.org/gems/rufo)
5
5
 
6
6
  **Ru**by **fo**rmatter
@@ -12,7 +12,7 @@ Unlike the best known Ruby formatter [RuboCop](https://github.com/bbatsov/ruboco
12
12
 
13
13
  RuboCop does much more than just format code though, so feel free to run them both!
14
14
 
15
- Rufo supports all Ruby versions >= 2.4.**5**, due to a bug in Ruby's Ripper parser.
15
+ Rufo supports all Ruby versions >= 2.7.0.
16
16
 
17
17
  ## Installation
18
18
 
@@ -35,7 +35,7 @@ Or install it system wide with:
35
35
  Once the gem is installed, enable format on save integration in your editor of choice with the following libraries:
36
36
 
37
37
  - Atom: [rufo-atom](https://github.com/bmulvihill/rufo-atom) :construction:
38
- - Emacs [emacs-rufo](https://github.com/aleandros/emacs-rufo) :construction: or [rufo.el](https://github.com/danielma/rufo.el)
38
+ - Emacs [emacs-rufo](https://github.com/aleandros/emacs-rufo) :construction: or [rufo.el](https://github.com/danielma/rufo.el) or [run rufo with reformatter](https://gist.github.com/kzkn/5c80c24d39e5e7b7881d55ad04605c5b)
39
39
  - Sublime Text: [sublime-rufo](https://github.com/ruby-formatter/sublime-rufo)
40
40
  - Vim: [rufo-vim](https://github.com/splattael/rufo-vim)
41
41
  - Visual Studio Code: [vscode-rufo](https://marketplace.visualstudio.com/items?itemName=mbessey.vscode-rufo) or [rufo-vscode](https://marketplace.visualstudio.com/items?itemName=siliconsenthil.rufo-vscode)
@@ -8,6 +8,9 @@ repos = {
8
8
  "spec/rspec/core/formatters/snippet_extractor_spec.rb",
9
9
  "spec/rspec/core/metadata_spec.rb",
10
10
  "spec/rspec/core/formatters/html_formatter_spec.rb",
11
+ "spec/rspec/core/formatters_spec.rb",
12
+ "spec/rspec/core/formatters/documentation_formatter_spec.rb",
13
+ "spec/rspec/core/formatters/progress_formatter_spec.rb"
11
14
  ].join(","),
12
15
  },
13
16
  }
data/docs/settings.md CHANGED
@@ -23,7 +23,7 @@ See https://github.com/ruby-formatter/rufo/issues/2 for more context!
23
23
  - [parens_in_def](#parens_in_def)
24
24
  - [trailing_commas](#trailing_commas)
25
25
  - [quote_style](#quote_style)
26
- - [includes and excludes](#includes%20and%20excludes)
26
+ - [includes and excludes](#includes-and-excludes)
27
27
 
28
28
  ### align_case_when
29
29
 
@@ -284,5 +284,5 @@ Files can be excluded or included in formatting with rufo by specifying glob pat
284
284
  For example:
285
285
  ```
286
286
  includes [*.txt,*.text]
287
- excludes [*.rb]
287
+ excludes [**/*.erb]
288
288
  ```
@@ -104,13 +104,51 @@ class Rufo::ErbFormatter
104
104
  result.strip
105
105
  end
106
106
 
107
+ def format_affix(affix, levels, type)
108
+ string = ""
109
+ case type
110
+ when :prefix
111
+ count = 0
112
+ while count < levels
113
+ count += 1
114
+ string += (" " * Rufo::Formatter::INDENT_SIZE * (count > 0 ? count - 1 : 0)) + affix
115
+ string += "\n" if count < levels
116
+ end
117
+ when :suffix
118
+ count = levels
119
+ while count > 0
120
+ count -= 1
121
+ string += "\n"
122
+ string += (" " * Rufo::Formatter::INDENT_SIZE * (count > 0 ? count - 1 : 0)) + affix
123
+ end
124
+ end
125
+ string
126
+ end
127
+
107
128
  def determine_code_wrappers(code_str)
108
- return nil, "\nend" if Ripper.sexp("#{code_str}\nend")
129
+ keywords = Ripper.lex("#{code_str}").filter { |lex_token| lex_token[1] == :on_kw }
130
+ lexical_tokens = keywords.filter { |lex_token| lex_token[2] != "when" }.map { |lex_token| lex_token[3].to_s }
131
+ state_tally = lexical_tokens.group_by(&:itself).transform_values(&:count)
132
+ beg_token = state_tally["BEG"] || state_tally["EXPR_BEG"] || 0
133
+ end_token = state_tally["END"] || state_tally["EXPR_END"] || 0
134
+ depth = beg_token - end_token
135
+
136
+ if depth > 0
137
+ affix = format_affix("end", depth.abs, :suffix)
138
+ return nil, affix if Ripper.sexp("#{code_str}#{affix}")
139
+ end
140
+
109
141
  return nil, "}" if Ripper.sexp("#{code_str} }")
110
142
  return "{", nil if Ripper.sexp("{ #{code_str}")
111
- return "begin", nil if Ripper.sexp("begin #{code_str}")
143
+
144
+ if depth < 0
145
+ affix = format_affix("begin", depth.abs, :prefix)
146
+ return affix, nil if Ripper.sexp("#{affix}#{code_str}")
147
+ end
148
+
112
149
  return "begin\n", "\nend" if Ripper.sexp("begin\n#{code_str}\nend")
113
150
  return "if a\n", "\nend" if Ripper.sexp("if a\n#{code_str}\nend")
151
+ return "case a\n", "\nend" if Ripper.sexp("case a\n#{code_str}\nend")
114
152
  raise_syntax_error!(code_str)
115
153
  end
116
154
 
@@ -212,7 +212,7 @@ class Rufo::Formatter
212
212
  when :@float
213
213
  # Float literal
214
214
  #
215
- # [:@int, "123.45", [1, 0]]
215
+ # [:@float, "123.45", [1, 0]]
216
216
  consume_token :on_float
217
217
  when :@rational
218
218
  # Rational literal
@@ -1126,11 +1126,14 @@ class Rufo::Formatter
1126
1126
 
1127
1127
  found_comma = comma?
1128
1128
 
1129
+ heredoc_needs_newline = true
1130
+
1129
1131
  if found_comma
1130
1132
  if needs_trailing_newline
1131
1133
  write "," if trailing_commas && !block_arg
1132
1134
 
1133
1135
  next_token
1136
+ heredoc_needs_newline = !newline?
1134
1137
  indent(next_indent) do
1135
1138
  consume_end_of_line
1136
1139
  end
@@ -1142,7 +1145,7 @@ class Rufo::Formatter
1142
1145
  end
1143
1146
 
1144
1147
  if newline? || comment?
1145
- if needs_trailing_newline
1148
+ if needs_trailing_newline && !@last_was_heredoc
1146
1149
  write "," if trailing_commas && want_trailing_comma
1147
1150
 
1148
1151
  indent(next_indent) do
@@ -1154,7 +1157,7 @@ class Rufo::Formatter
1154
1157
  end
1155
1158
  else
1156
1159
  if needs_trailing_newline && !found_comma
1157
- write "," if trailing_commas && want_trailing_comma
1160
+ write "," if trailing_commas && want_trailing_comma && !@last_was_heredoc
1158
1161
  consume_end_of_line
1159
1162
  write_indent
1160
1163
  end
@@ -1169,8 +1172,9 @@ class Rufo::Formatter
1169
1172
  call_info << @line
1170
1173
  end
1171
1174
 
1172
- if @last_was_heredoc
1175
+ if @last_was_heredoc && heredoc_needs_newline
1173
1176
  write_line
1177
+ write_indent
1174
1178
  end
1175
1179
  consume_token :on_rparen
1176
1180
  end
@@ -1452,14 +1456,10 @@ class Rufo::Formatter
1452
1456
  # check for ||
1453
1457
  if empty_params && !local_params
1454
1458
  # Don't write || as it's meaningless
1455
- if current_token_value == "|"
1456
- next_token
1457
- skip_space_or_newline
1458
- check :on_op
1459
- next_token
1460
- else
1461
- next_token
1462
- end
1459
+ next_token
1460
+ skip_space_or_newline
1461
+ check :on_op
1462
+ next_token
1463
1463
  return
1464
1464
  end
1465
1465
 
@@ -1571,7 +1571,12 @@ class Rufo::Formatter
1571
1571
 
1572
1572
  line = @line
1573
1573
 
1574
- indent_body body
1574
+ endless = body[0].is_a?(Symbol)
1575
+ if endless
1576
+ visit body
1577
+ else
1578
+ indent_body body
1579
+ end
1575
1580
 
1576
1581
  while rescue_body
1577
1582
  # [:rescue, type, name, body, more_rescue]
@@ -1616,7 +1621,7 @@ class Rufo::Formatter
1616
1621
  end
1617
1622
 
1618
1623
  write_indent if @line != line
1619
- consume_keyword "end"
1624
+ consume_keyword "end" unless endless
1620
1625
  end
1621
1626
 
1622
1627
  def visit_rescue_types(node)
@@ -1992,6 +1997,19 @@ class Rufo::Formatter
1992
1997
  # [:@ident, "foo", [1, 6]],
1993
1998
  # [:params, nil, nil, nil, nil, nil, nil, nil],
1994
1999
  # [:bodystmt, [[:void_stmt]], nil, nil, nil]]
2000
+ #
2001
+ # OR For endless methods (in 3.0)
2002
+ # [:def,
2003
+ # [:@ident, "foo", [1, 6]],
2004
+ # nil,
2005
+ # [:string_literal, [:string_content, [:@tstring_content, "bar", [1, 11]
2006
+ # OR For endless methods (in 3.1)
2007
+ # [:def,
2008
+ # [:@ident, "foo", [1, 6]],
2009
+ # nil,
2010
+ # [:bodystmt,
2011
+ # [:string_literal, [:string_content, [:@tstring_content, "bar", [1, 11]
2012
+
1995
2013
  _, name, params, body = node
1996
2014
 
1997
2015
  consume_keyword "def"
@@ -2028,6 +2046,7 @@ class Rufo::Formatter
2028
2046
  def visit_def_from_name(name, params, body)
2029
2047
  visit name
2030
2048
 
2049
+ params = [] if params.nil?
2031
2050
  params = params[1] if params[0] == :paren
2032
2051
 
2033
2052
  skip_space
@@ -2068,6 +2087,7 @@ class Rufo::Formatter
2068
2087
  end
2069
2088
  write ")"
2070
2089
  next_token
2090
+ skip_space
2071
2091
  end
2072
2092
  elsif !empty_params?(params)
2073
2093
  if parens_in_def == :yes
@@ -2081,9 +2101,18 @@ class Rufo::Formatter
2081
2101
  skip_space
2082
2102
  end
2083
2103
 
2104
+ format_endless_method if current_token_kind == :on_op
2105
+
2084
2106
  visit body
2085
2107
  end
2086
2108
 
2109
+ def format_endless_method
2110
+ consume_space
2111
+ consume_op "="
2112
+ consume_space
2113
+ skip_space
2114
+ end
2115
+
2087
2116
  def empty_params?(node)
2088
2117
  _, a, b, c, d, e, f, g = node
2089
2118
  !a && !b && !c && !d && !e && !f && !g
@@ -2139,6 +2168,7 @@ class Rufo::Formatter
2139
2168
  when 0, [:excessed_comma]
2140
2169
  write_params_comma
2141
2170
  when [:args_forward]
2171
+ write_params_comma if needs_comma
2142
2172
  consume_op "..."
2143
2173
  else
2144
2174
  # [:rest_param, [:@ident, "x", [1, 15]]]
@@ -2175,16 +2205,22 @@ class Rufo::Formatter
2175
2205
 
2176
2206
  if double_star_param
2177
2207
  write_params_comma if needs_comma
2178
- consume_op "**"
2179
- skip_space_or_newline
2208
+ case double_star_param
2209
+ when [:args_forward] # may be [:args_forward] in 3.1.0
2210
+ consume_op "..."
2211
+ else
2212
+ consume_op "**" # here
2213
+ skip_space_or_newline
2180
2214
 
2181
- # A nameless double star comes as an... Integer? :-S
2182
- visit double_star_param if double_star_param.is_a?(Array)
2183
- skip_space_or_newline
2184
- needs_comma = true
2215
+ # A nameless double star comes as an... Integer? :-S
2216
+ visit double_star_param if double_star_param.is_a?(Array)
2217
+ skip_space_or_newline
2218
+ needs_comma = true
2219
+ end
2185
2220
  end
2186
2221
 
2187
- if blockarg
2222
+ # In 3.1.0 blockarg may be just a symbol `:&`
2223
+ if blockarg && blockarg.is_a?(Array)
2188
2224
  # [:blockarg, [:@ident, "block", [1, 16]]]
2189
2225
  write_params_comma if needs_comma
2190
2226
  skip_space_or_newline
@@ -3184,13 +3220,6 @@ class Rufo::Formatter
3184
3220
  last_space = current_token
3185
3221
  next_token
3186
3222
  when :on_nl, :on_ignored_nl
3187
- # I don't know why but sometimes a on_ignored_nl
3188
- # can appear with nil as the "text", and that's wrong
3189
- if current_token[2].nil?
3190
- next_token
3191
- next
3192
- end
3193
-
3194
3223
  if last == :newline
3195
3224
  # If we pass through consecutive newlines, don't print them
3196
3225
  # yet, but remember this fact
@@ -3884,11 +3913,7 @@ class Rufo::Formatter
3884
3913
  when :assoclist_from_args
3885
3914
  node_line(beginning ? node[1][0] : node[1].last, beginning: beginning)
3886
3915
  when :dyna_symbol
3887
- if node[1][0].is_a?(Symbol)
3888
- node_line(node[1], beginning: beginning)
3889
- else
3890
- node_line(node[1][0], beginning: beginning)
3891
- end
3916
+ node_line(node[1], beginning: beginning)
3892
3917
  when :@label, :@int, :@ident, :@tstring_content, :@kw
3893
3918
  node[2][0]
3894
3919
  end
data/lib/rufo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rufo
4
- VERSION = "0.12.0"
4
+ VERSION = "0.14.0"
5
5
  end
data/rufo.gemspec CHANGED
@@ -20,12 +20,13 @@ Gem::Specification.new do |spec|
20
20
  spec.bindir = "exe"
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
- spec.required_ruby_version = ">= 2.4.5"
23
+ spec.required_ruby_version = ">= 2.7.0"
24
24
 
25
25
  spec.add_development_dependency "bundler", ">= 1.15"
26
26
  spec.add_development_dependency "byebug", "~> 11.0.1"
27
27
  spec.add_development_dependency "guard-rspec", "~> 4.0"
28
28
  spec.add_development_dependency "rake", "~> 13.0"
29
+ spec.add_development_dependency "rexml", "~> 3.2.5"
29
30
  spec.add_development_dependency "rspec", "~> 3.0"
30
31
  spec.add_development_dependency "rspec_junit_formatter", "~> 0.4.1"
31
32
  spec.add_development_dependency "rubocop", "~> 0.79.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ary Borenszweig
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-08 00:00:00.000000000 Z
11
+ date: 2023-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '13.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rexml
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.2.5
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.2.5
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -144,8 +158,8 @@ executables:
144
158
  extensions: []
145
159
  extra_rdoc_files: []
146
160
  files:
147
- - ".circleci/config.yml"
148
161
  - ".github/PULL_REQUEST_TEMPLATE.md"
162
+ - ".github/workflows/ci.yml"
149
163
  - ".gitignore"
150
164
  - ".rspec"
151
165
  - ".rubocop.yml"
@@ -180,7 +194,7 @@ homepage: https://github.com/ruby-formatter/rufo
180
194
  licenses:
181
195
  - MIT
182
196
  metadata: {}
183
- post_install_message:
197
+ post_install_message:
184
198
  rdoc_options: []
185
199
  require_paths:
186
200
  - lib
@@ -188,15 +202,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
202
  requirements:
189
203
  - - ">="
190
204
  - !ruby/object:Gem::Version
191
- version: 2.4.5
205
+ version: 2.7.0
192
206
  required_rubygems_version: !ruby/object:Gem::Requirement
193
207
  requirements:
194
208
  - - ">="
195
209
  - !ruby/object:Gem::Version
196
210
  version: '0'
197
211
  requirements: []
198
- rubygems_version: 3.1.2
199
- signing_key:
212
+ rubygems_version: 3.3.7
213
+ signing_key:
200
214
  specification_version: 4
201
215
  summary: Ruby code formatter
202
216
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,110 +0,0 @@
1
- "-": &dockerbuild
2
- steps:
3
- - checkout
4
-
5
- # Which version of ruby?
6
- - run:
7
- name: Which ruby?
8
- command: ruby --version | tee ruby-version-for-ci.txt
9
-
10
- # Which version of bundler?
11
- - run:
12
- name: Which bundler?
13
- command: bundle -v
14
-
15
- # Restore bundle cache
16
- - restore_cache:
17
- keys:
18
- - bundler-packages-v2-{{ checksum "ruby-version-for-ci.txt" }}-{{ checksum "rufo.gemspec" }}-{{ checksum "bin/verify-sample-code" }}
19
-
20
- - run:
21
- name: Bundle Install
22
- command: bundle check || bundle install
23
-
24
- - run:
25
- name: Run rspec
26
- command: |
27
- bundle exec rspec --profile 10 \
28
- --format RspecJunitFormatter \
29
- --out test_results/rspec.xml \
30
- --format progress
31
- - run:
32
- name: Upload code coverage
33
- command: bash <(curl -s https://codecov.io/bash) -f 'coverage/coverage.xml'
34
- - run:
35
- name: Run RuboCop
36
- command: |
37
- bundle exec rake rubocop
38
- - run:
39
- name: Run Rufo
40
- command: |
41
- bundle exec rake rufo:run
42
-
43
- - run:
44
- name: Verify rufo works against sample codebases
45
- command: |
46
- bin/verify-sample-code
47
-
48
- # Store bundle cache
49
- - save_cache:
50
- key: bundler-packages-v2-{{ checksum "ruby-version-for-ci.txt" }}-{{ checksum "rufo.gemspec" }}-{{ checksum "bin/verify-sample-code" }}
51
- paths:
52
- - vendor/bundle
53
- - Gemfile.lock
54
-
55
- # Save test results for timing analysis
56
- - store_test_results:
57
- path: test_results
58
-
59
- version: 2
60
- jobs:
61
- build-2-7-0:
62
- <<: *dockerbuild
63
- docker:
64
- - image: circleci/ruby:2.7.0
65
- environment:
66
- BUNDLE_JOBS: "3"
67
- BUNDLE_RETRY: "3"
68
- BUNDLE_PATH: /home/circleci/project/vendor/bundle
69
- build-2-6-3:
70
- <<: *dockerbuild
71
- docker:
72
- - image: circleci/ruby:2.6.3
73
- environment:
74
- BUNDLE_JOBS: "3"
75
- BUNDLE_RETRY: "3"
76
- BUNDLE_PATH: /home/circleci/project/vendor/bundle
77
- build-2-6-1:
78
- <<: *dockerbuild
79
- docker:
80
- - image: circleci/ruby:2.6.1
81
- environment:
82
- BUNDLE_JOBS: "3"
83
- BUNDLE_RETRY: "3"
84
- BUNDLE_PATH: vendor/bundle
85
- build-2-5-3:
86
- <<: *dockerbuild
87
- docker:
88
- - image: circleci/ruby:2.5.3
89
- environment:
90
- BUNDLE_JOBS: "3"
91
- BUNDLE_RETRY: "3"
92
- BUNDLE_PATH: vendor/bundle
93
- build-2-4-5:
94
- <<: *dockerbuild
95
- docker:
96
- - image: circleci/ruby:2.4.5
97
- environment:
98
- BUNDLE_JOBS: "3"
99
- BUNDLE_RETRY: "3"
100
- BUNDLE_PATH: vendor/bundle
101
-
102
- workflows:
103
- version: 2
104
- test:
105
- jobs:
106
- - build-2-7-0
107
- - build-2-6-3
108
- - build-2-6-1
109
- - build-2-5-3
110
- - build-2-4-5