ndr_dev_support 5.4.8 → 5.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -138
- data/CHANGELOG.md +27 -0
- data/README.md +33 -6
- data/code_safety.yml +29 -17
- data/config/rubocop/ndr.yml +138 -0
- data/lib/minitest/rake_ci_plugin.rb +47 -7
- data/lib/ndr_dev_support.rb +4 -1
- data/lib/ndr_dev_support/capistrano/svn_cache.rb +6 -0
- data/lib/ndr_dev_support/daemon/ci_server.rb +6 -2
- data/lib/ndr_dev_support/integration_testing.rb +3 -0
- data/lib/ndr_dev_support/integration_testing/flakey_tests.rb +55 -0
- data/lib/ndr_dev_support/rake_ci/brakeman_helper.rb +87 -2
- data/lib/ndr_dev_support/rake_ci/redmine/ticket_resolver.rb +11 -7
- data/lib/ndr_dev_support/rubocop/inject.rb +26 -0
- data/lib/ndr_dev_support/version.rb +1 -1
- data/lib/tasks/ci/brakeman.rake +23 -36
- data/lib/tasks/ci/minitest.rake +3 -4
- data/lib/tasks/ci/redmine.rake +5 -4
- data/ndr_dev_support.gemspec +2 -2
- metadata +27 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b95a59b9d5d9469727dbebdc0d1290b5bb773cce213af0443ae14394edda5ac5
|
4
|
+
data.tar.gz: 9f3321c3f6485db01c6ba902c490dfd991ee169b872b3bd2601853953dbdcbab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86c5b1bfafd993367dc9637289d7ac2980538d725a70456f197e3f77fcf9dcdf1416b78fb80fde71ad1e7b3427c6cc4d6e9ae0f0909b5a32151a263023fde0eb
|
7
|
+
data.tar.gz: 199e4168c7b198ac38a3b1a651d9cd34d63b366061e42ef168ef4cd91ed8cee19592b5b6c6a13e3e85e9bddd181ace49c8f4a9b58215b183b81472d2e7d8d1ba
|
data/.rubocop.yml
CHANGED
@@ -1,138 +1 @@
|
|
1
|
-
|
2
|
-
# Style Guide, the configuration for which can be found here:
|
3
|
-
# https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
4
|
-
#
|
5
|
-
# See the README for instructions on using in a project.
|
6
|
-
|
7
|
-
require:
|
8
|
-
- rubocop-rails
|
9
|
-
|
10
|
-
AllCops:
|
11
|
-
# All cops should ignore files in the following locations:
|
12
|
-
Exclude:
|
13
|
-
- 'bin/*'
|
14
|
-
- 'db/schema.rb'
|
15
|
-
- 'lib/generators/**/templates/*'
|
16
|
-
- 'tmp/**/*'
|
17
|
-
- 'vendor/**/*'
|
18
|
-
|
19
|
-
# Once supported by RuboCop, this will prevent cop-specific Excludes from
|
20
|
-
# overwriting the AllCops defaults above:
|
21
|
-
#
|
22
|
-
# inherit_mode:
|
23
|
-
# merge:
|
24
|
-
# - Exclude
|
25
|
-
|
26
|
-
# Run the Rails cops by default (-R/--rails not required):
|
27
|
-
Rails:
|
28
|
-
Enabled: true
|
29
|
-
|
30
|
-
##################### Layout #################################
|
31
|
-
|
32
|
-
Layout/DotPosition:
|
33
|
-
# Multi-line method chaining should be done with trailing dots.
|
34
|
-
EnforcedStyle: trailing
|
35
|
-
|
36
|
-
Layout/HashAlignment:
|
37
|
-
EnforcedColonStyle:
|
38
|
-
- key
|
39
|
-
- table
|
40
|
-
EnforcedHashRocketStyle:
|
41
|
-
- key
|
42
|
-
- table
|
43
|
-
|
44
|
-
##################### Style ##################################
|
45
|
-
|
46
|
-
# We make use of block comments, e.g. for validation documentation.
|
47
|
-
Style/BlockComments:
|
48
|
-
Enabled: false
|
49
|
-
|
50
|
-
Style/Documentation:
|
51
|
-
Exclude:
|
52
|
-
- 'test/**/*.rb'
|
53
|
-
|
54
|
-
Style/FrozenStringLiteralComment:
|
55
|
-
# We're not confident enough to make this recommendation everywhere
|
56
|
-
Enabled: false
|
57
|
-
|
58
|
-
Style/ModuleFunction:
|
59
|
-
# `extend self` has fewer side effects than `module_function`.
|
60
|
-
EnforcedStyle: extend_self
|
61
|
-
|
62
|
-
Style/NumericLiterals:
|
63
|
-
Exclude:
|
64
|
-
- 'db/migrate/*.rb'
|
65
|
-
- 'test/**/*.rb'
|
66
|
-
|
67
|
-
Style/YodaCondition:
|
68
|
-
# Disagree; literals as first argument can guard against accidental assignment.
|
69
|
-
Enabled: false
|
70
|
-
|
71
|
-
Style/SingleLineBlockParams:
|
72
|
-
# Prefer readability of contextually-named variables.
|
73
|
-
Enabled: false
|
74
|
-
|
75
|
-
##################### Metrics ##################################
|
76
|
-
# NOTE: we bump some metrics by 50%, in recognition of Rubocop's
|
77
|
-
# desire to split that which we would consider atomic.
|
78
|
-
|
79
|
-
Metrics/AbcSize:
|
80
|
-
Max: 23
|
81
|
-
Exclude:
|
82
|
-
- 'db/migrate/*.rb'
|
83
|
-
- 'test/**/*.rb'
|
84
|
-
|
85
|
-
Metrics/BlockLength:
|
86
|
-
# We're already limiting method size, blocks outside of methods
|
87
|
-
# can legitimately be long (RuboCop defaults to max: 25 lines).
|
88
|
-
Enabled: false
|
89
|
-
|
90
|
-
Metrics/ClassLength:
|
91
|
-
Max: 150
|
92
|
-
Exclude:
|
93
|
-
- 'db/migrate/*.rb'
|
94
|
-
- 'test/**/*.rb'
|
95
|
-
|
96
|
-
Metrics/ModuleLength:
|
97
|
-
Max: 150
|
98
|
-
Exclude:
|
99
|
-
- 'test/**/*.rb'
|
100
|
-
|
101
|
-
Metrics/CyclomaticComplexity:
|
102
|
-
Max: 9
|
103
|
-
|
104
|
-
Layout/LineLength:
|
105
|
-
Max: 100
|
106
|
-
Exclude:
|
107
|
-
- 'db/migrate/*.rb'
|
108
|
-
- 'test/**/*.rb'
|
109
|
-
|
110
|
-
Metrics/MethodLength:
|
111
|
-
Max: 15
|
112
|
-
Exclude:
|
113
|
-
- 'db/migrate/*.rb'
|
114
|
-
- 'test/**/*.rb'
|
115
|
-
|
116
|
-
Metrics/PerceivedComplexity:
|
117
|
-
Max: 12
|
118
|
-
|
119
|
-
##################### Rails ##################################
|
120
|
-
|
121
|
-
Rails/ActionFilter:
|
122
|
-
# 'action' is the default already; we explicitly list here as Rails 3.x
|
123
|
-
# projects will want to override this configuration to use 'filter' instead.
|
124
|
-
EnforcedStyle: action
|
125
|
-
|
126
|
-
Rails/DynamicFindBy:
|
127
|
-
Exclude:
|
128
|
-
- 'test/integration/**/*.rb'
|
129
|
-
|
130
|
-
Rails/RefuteMethods:
|
131
|
-
Enabled: false
|
132
|
-
|
133
|
-
Rails/SkipsModelValidations:
|
134
|
-
# Methods like 'update_column' exist for a reason, and it is the developer's
|
135
|
-
# responsibilty to understand the behaviour of the code they write; blanket
|
136
|
-
# avoiding them is not helpful/practical.
|
137
|
-
Enabled: false
|
138
|
-
|
1
|
+
require: ndr_dev_support
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,33 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
*no unreleased changes*
|
3
3
|
|
4
|
+
## 5.8.0 / 2020-04-07
|
5
|
+
### Added
|
6
|
+
* Ability to select git CI branch by exporting `RAKE_CI_BRANCH_NAME`
|
7
|
+
|
8
|
+
## 5.7.1 / 2020-04-07
|
9
|
+
### Fixed
|
10
|
+
* Address issue updating redmine using commit message tags
|
11
|
+
|
12
|
+
## 5.7.0 / 2020-03-26
|
13
|
+
### Added
|
14
|
+
* Add `ci:brakeman:strict` alternative CI task. (#77)
|
15
|
+
* Send `brakeman_filtered_warnings` metrics. (#78)
|
16
|
+
* Allow redmine tickets to be updated (but not resolved) when the build fails (#73)
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
* Stop including asset compilation caches in the deployment archive.
|
20
|
+
* Ensure brakeman alerts aren't sent to Slack if they've been reviewed and filtered out
|
21
|
+
|
22
|
+
## 5.6.0 / 2020-02-14
|
23
|
+
### Added
|
24
|
+
* Add `flakey_test` to the minitest DSL, to allow sporadic failures to be retried
|
25
|
+
* CI: include minitest seed in slack output
|
26
|
+
|
27
|
+
## 5.5.0 / 2020-01-27
|
28
|
+
### Added
|
29
|
+
* bundle master RuboCop config, and allow it to be `required`
|
30
|
+
|
4
31
|
## 5.4.8 / 2020-01-24
|
5
32
|
### Fixed
|
6
33
|
* deploy: insert temporary DB config to allow asset precompilation
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
## NdrDevSupport [![Build Status](https://travis-ci.org/PublicHealthEngland/ndr_dev_support.svg?branch=master)](https://travis-ci.org/PublicHealthEngland/ndr_dev_support) [![Gem Version](https://badge.fury.io/rb/ndr_dev_support.svg)](https://badge.fury.io/rb/ndr_dev_support)
|
1
|
+
## NdrDevSupport [![Maintainability](https://api.codeclimate.com/v1/badges/2b2a644964f2aa930f81/maintainability)](https://codeclimate.com/github/PublicHealthEngland/ndr_dev_support/maintainability) [![Build Status](https://travis-ci.org/PublicHealthEngland/ndr_dev_support.svg?branch=master)](https://travis-ci.org/PublicHealthEngland/ndr_dev_support) [![Gem Version](https://badge.fury.io/rb/ndr_dev_support.svg)](https://badge.fury.io/rb/ndr_dev_support)
|
2
2
|
|
3
3
|
This is the Public Health England (PHE) National Disease Registers (NDR) Developer Support ruby gem,
|
4
4
|
providing:
|
@@ -49,16 +49,22 @@ For more details of the audit tasks available, execute:
|
|
49
49
|
|
50
50
|
### RuboCop configuration
|
51
51
|
|
52
|
-
ndr_dev_support includes tweaks to the default Ruby Style
|
53
|
-
To use
|
52
|
+
`ndr_dev_support` includes tweaks to the default Ruby and Ruby on Rails Style Guides, to better suit NDR.
|
53
|
+
To use these updated style guides from within a project, add the following to top of the project's `.rubocop.yml` file:
|
54
54
|
|
55
55
|
```yaml
|
56
|
-
|
56
|
+
require: ndr_dev_support
|
57
57
|
```
|
58
58
|
|
59
|
-
|
59
|
+
Or, if using other extensions too:
|
60
60
|
|
61
|
-
|
61
|
+
```yaml
|
62
|
+
require:
|
63
|
+
- ndr_dev_support
|
64
|
+
- some_other_extension
|
65
|
+
```
|
66
|
+
|
67
|
+
In order for these configurations to apply, you will need to invoke RuboCop using Bundler:
|
62
68
|
|
63
69
|
```
|
64
70
|
$ bundle exec rubocop .
|
@@ -129,6 +135,27 @@ Beyond standard Capybara testing DSL, ndr_dev_support bundles some additional fu
|
|
129
135
|
|
130
136
|
When using a headless browser for integration tests, the test database must be consistent between the test runner and the application being tested. With transactional tests in operation, this means that both must share a connection. It is up to the individual project to provide this facility; as of Rails 5.1, it is built in to the framework directly.
|
131
137
|
|
138
|
+
#### Flakey Tests
|
139
|
+
|
140
|
+
It is an unfortunate reality that sometimes tests are written that will fail sporadically. Whilst in such cases the test methodology should be addressed, investigations can be time-consuming.
|
141
|
+
Therefore, `ndr_dev_support` grudgingly provides "flakey test" support, to minimise disruption to CI pipelines whilst root causes are investigated.
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
test 'thing that always passes' do
|
145
|
+
# reliable test
|
146
|
+
end
|
147
|
+
|
148
|
+
flakey_test 'thing that occassionally needs a second or third attempt' do
|
149
|
+
# less reliable test
|
150
|
+
end
|
151
|
+
|
152
|
+
flakey_test 'thing that often needs multiple attempts', attempts: 10 do
|
153
|
+
# really unreliable test (gulp...)
|
154
|
+
end
|
155
|
+
```
|
156
|
+
|
157
|
+
If tests still fail, they'll fail as normal. If tests pass after flakey failure, they'll be flagged to the RakeCI server, and rendered in purple on Slack.
|
158
|
+
|
132
159
|
### Deployment support
|
133
160
|
|
134
161
|
There are various capistrano plugins in the `ndr_dev_support/capistrano` directory - see each one for details.
|
data/code_safety.yml
CHANGED
@@ -11,7 +11,7 @@ file safety:
|
|
11
11
|
".rubocop.yml":
|
12
12
|
comments:
|
13
13
|
reviewed_by: josh.pencheon
|
14
|
-
safe_revision:
|
14
|
+
safe_revision: 6211cff0ce44645ed3752723b5b0ee65f24c66aa
|
15
15
|
".travis.yml":
|
16
16
|
comments:
|
17
17
|
reviewed_by: josh.pencheon
|
@@ -19,7 +19,7 @@ file safety:
|
|
19
19
|
CHANGELOG.md:
|
20
20
|
comments:
|
21
21
|
reviewed_by: josh.pencheon
|
22
|
-
safe_revision:
|
22
|
+
safe_revision: 20ccc70d14864abef58103171d169220dacfb65f
|
23
23
|
CODE_OF_CONDUCT.md:
|
24
24
|
comments:
|
25
25
|
reviewed_by: timgentry
|
@@ -35,7 +35,7 @@ file safety:
|
|
35
35
|
README.md:
|
36
36
|
comments:
|
37
37
|
reviewed_by: josh.pencheon
|
38
|
-
safe_revision:
|
38
|
+
safe_revision: b405f60e921805378ba1f3beaeb10cf1a8503182
|
39
39
|
Rakefile:
|
40
40
|
comments:
|
41
41
|
reviewed_by: josh.pencheon
|
@@ -48,6 +48,10 @@ file safety:
|
|
48
48
|
comments:
|
49
49
|
reviewed_by: timgentry
|
50
50
|
safe_revision: c59a45986f8b6d087c8c21b1e889f31f7346da17
|
51
|
+
config/rubocop/ndr.yml:
|
52
|
+
comments:
|
53
|
+
reviewed_by: josh.pencheon
|
54
|
+
safe_revision: 6211cff0ce44645ed3752723b5b0ee65f24c66aa
|
51
55
|
gemfiles/Gemfile.rails52:
|
52
56
|
comments:
|
53
57
|
reviewed_by: josh.pencheon
|
@@ -63,11 +67,11 @@ file safety:
|
|
63
67
|
lib/minitest/rake_ci_plugin.rb:
|
64
68
|
comments:
|
65
69
|
reviewed_by: josh.pencheon
|
66
|
-
safe_revision:
|
70
|
+
safe_revision: 958ef09c5cf50bb50348e6bff949e3e5989254f9
|
67
71
|
lib/ndr_dev_support.rb:
|
68
72
|
comments:
|
69
|
-
reviewed_by:
|
70
|
-
safe_revision:
|
73
|
+
reviewed_by: josh.pencheon
|
74
|
+
safe_revision: 6211cff0ce44645ed3752723b5b0ee65f24c66aa
|
71
75
|
lib/ndr_dev_support/capistrano/assets.rb:
|
72
76
|
comments:
|
73
77
|
reviewed_by: josh.pencheon
|
@@ -95,7 +99,7 @@ file safety:
|
|
95
99
|
lib/ndr_dev_support/capistrano/svn_cache.rb:
|
96
100
|
comments:
|
97
101
|
reviewed_by: josh.pencheon
|
98
|
-
safe_revision:
|
102
|
+
safe_revision: 2baa360b06290775a961a7573fe08edd18f8312e
|
99
103
|
lib/ndr_dev_support/capistrano/sysadmin_scripts.rb:
|
100
104
|
comments:
|
101
105
|
reviewed_by: josh.pencheon
|
@@ -103,7 +107,7 @@ file safety:
|
|
103
107
|
lib/ndr_dev_support/daemon/ci_server.rb:
|
104
108
|
comments:
|
105
109
|
reviewed_by: josh.pencheon
|
106
|
-
safe_revision:
|
110
|
+
safe_revision: 4a1047ed1b7dfa1958d39f8d94d466f376c74620
|
107
111
|
lib/ndr_dev_support/daemon/stoppable.rb:
|
108
112
|
comments:
|
109
113
|
reviewed_by: josh.pencheon
|
@@ -111,7 +115,7 @@ file safety:
|
|
111
115
|
lib/ndr_dev_support/integration_testing.rb:
|
112
116
|
comments:
|
113
117
|
reviewed_by: josh.pencheon
|
114
|
-
safe_revision:
|
118
|
+
safe_revision: a2f178853da640112cf3063ca1d640157c9edb9f
|
115
119
|
lib/ndr_dev_support/integration_testing/drivers/chrome.rb:
|
116
120
|
comments:
|
117
121
|
reviewed_by: josh.pencheon
|
@@ -136,10 +140,14 @@ file safety:
|
|
136
140
|
comments:
|
137
141
|
reviewed_by: josh.pencheon
|
138
142
|
safe_revision: f1a32b1f2d1851b87a883dbf8620aa0e921e436c
|
143
|
+
lib/ndr_dev_support/integration_testing/flakey_tests.rb:
|
144
|
+
comments:
|
145
|
+
reviewed_by: josh.pencheon
|
146
|
+
safe_revision: a2f178853da640112cf3063ca1d640157c9edb9f
|
139
147
|
lib/ndr_dev_support/rake_ci/brakeman_helper.rb:
|
140
148
|
comments:
|
141
149
|
reviewed_by: josh.pencheon
|
142
|
-
safe_revision:
|
150
|
+
safe_revision: 053c9834ca5d402a1f8dc8d09257dc7075a5ec06
|
143
151
|
lib/ndr_dev_support/rake_ci/commit_cop.rb:
|
144
152
|
comments:
|
145
153
|
reviewed_by: josh.pencheon
|
@@ -171,7 +179,7 @@ file safety:
|
|
171
179
|
lib/ndr_dev_support/rake_ci/redmine/ticket_resolver.rb:
|
172
180
|
comments:
|
173
181
|
reviewed_by: josh.pencheon
|
174
|
-
safe_revision:
|
182
|
+
safe_revision: 788b8fc31952a6fb640101df96a370b21d269249
|
175
183
|
lib/ndr_dev_support/rake_ci/simple_cov_helper.rb:
|
176
184
|
comments:
|
177
185
|
reviewed_by: timgentry
|
@@ -180,6 +188,10 @@ file safety:
|
|
180
188
|
comments:
|
181
189
|
reviewed_by: josh.pencheon
|
182
190
|
safe_revision: e56876f46536ba006a9b68029306f41a188bf9c6
|
191
|
+
lib/ndr_dev_support/rubocop/inject.rb:
|
192
|
+
comments:
|
193
|
+
reviewed_by: josh.pencheon
|
194
|
+
safe_revision: 6211cff0ce44645ed3752723b5b0ee65f24c66aa
|
183
195
|
lib/ndr_dev_support/rubocop/range_augmenter.rb:
|
184
196
|
comments:
|
185
197
|
reviewed_by: joshpencheon
|
@@ -203,7 +215,7 @@ file safety:
|
|
203
215
|
lib/ndr_dev_support/version.rb:
|
204
216
|
comments:
|
205
217
|
reviewed_by: josh.pencheon
|
206
|
-
safe_revision:
|
218
|
+
safe_revision: 20ccc70d14864abef58103171d169220dacfb65f
|
207
219
|
lib/tasks/audit_code.rake:
|
208
220
|
comments: Identical to the version reviewed by josh.pencheon when contained within
|
209
221
|
ndr_support
|
@@ -212,7 +224,7 @@ file safety:
|
|
212
224
|
lib/tasks/ci/brakeman.rake:
|
213
225
|
comments:
|
214
226
|
reviewed_by: josh.pencheon
|
215
|
-
safe_revision:
|
227
|
+
safe_revision: 053c9834ca5d402a1f8dc8d09257dc7075a5ec06
|
216
228
|
lib/tasks/ci/bundle_audit.rake:
|
217
229
|
comments:
|
218
230
|
reviewed_by: josh.pencheon
|
@@ -236,7 +248,7 @@ file safety:
|
|
236
248
|
lib/tasks/ci/minitest.rake:
|
237
249
|
comments:
|
238
250
|
reviewed_by: josh.pencheon
|
239
|
-
safe_revision:
|
251
|
+
safe_revision: 12aad1254186ee9ce0fde263bf8dccf46cdfebe2
|
240
252
|
lib/tasks/ci/notes.rake:
|
241
253
|
comments:
|
242
254
|
reviewed_by: timgentry
|
@@ -248,7 +260,7 @@ file safety:
|
|
248
260
|
lib/tasks/ci/redmine.rake:
|
249
261
|
comments:
|
250
262
|
reviewed_by: josh.pencheon
|
251
|
-
safe_revision:
|
263
|
+
safe_revision: 12aad1254186ee9ce0fde263bf8dccf46cdfebe2
|
252
264
|
lib/tasks/ci/rugged.rake:
|
253
265
|
comments:
|
254
266
|
reviewed_by: josh.pencheon
|
@@ -276,7 +288,7 @@ file safety:
|
|
276
288
|
ndr_dev_support.gemspec:
|
277
289
|
comments:
|
278
290
|
reviewed_by: josh.pencheon
|
279
|
-
safe_revision:
|
291
|
+
safe_revision: f4c1ea57d3eb817783fdc47a16169d215f9788a6
|
280
292
|
test/daemon/ci_server_test.rb:
|
281
293
|
comments:
|
282
294
|
reviewed_by: josh.pencheon
|
@@ -304,7 +316,7 @@ file safety:
|
|
304
316
|
test/rake_ci/redmine/ticket_resolver_test.rb:
|
305
317
|
comments:
|
306
318
|
reviewed_by: josh.pencheon
|
307
|
-
safe_revision:
|
319
|
+
safe_revision: 12aad1254186ee9ce0fde263bf8dccf46cdfebe2
|
308
320
|
test/test_helper.rb:
|
309
321
|
comments:
|
310
322
|
reviewed_by: josh.pencheon
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# This file contains NDR's agreed deviations from the standard Ruby
|
2
|
+
# Style Guide, the configuration for which can be found here:
|
3
|
+
# https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
4
|
+
#
|
5
|
+
# See the README for instructions on using in a project.
|
6
|
+
|
7
|
+
require:
|
8
|
+
- rubocop-rails
|
9
|
+
|
10
|
+
AllCops:
|
11
|
+
# All cops should ignore files in the following locations:
|
12
|
+
Exclude:
|
13
|
+
- 'bin/*'
|
14
|
+
- 'db/schema.rb'
|
15
|
+
- 'lib/generators/**/templates/*'
|
16
|
+
- 'tmp/**/*'
|
17
|
+
- 'vendor/**/*'
|
18
|
+
|
19
|
+
# Once supported by RuboCop, this will prevent cop-specific Excludes from
|
20
|
+
# overwriting the AllCops defaults above:
|
21
|
+
#
|
22
|
+
# inherit_mode:
|
23
|
+
# merge:
|
24
|
+
# - Exclude
|
25
|
+
|
26
|
+
# Run the Rails cops by default (-R/--rails not required):
|
27
|
+
Rails:
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
##################### Layout #################################
|
31
|
+
|
32
|
+
Layout/DotPosition:
|
33
|
+
# Multi-line method chaining should be done with trailing dots.
|
34
|
+
EnforcedStyle: trailing
|
35
|
+
|
36
|
+
Layout/HashAlignment:
|
37
|
+
EnforcedColonStyle:
|
38
|
+
- key
|
39
|
+
- table
|
40
|
+
EnforcedHashRocketStyle:
|
41
|
+
- key
|
42
|
+
- table
|
43
|
+
|
44
|
+
##################### Style ##################################
|
45
|
+
|
46
|
+
# We make use of block comments, e.g. for validation documentation.
|
47
|
+
Style/BlockComments:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Style/Documentation:
|
51
|
+
Exclude:
|
52
|
+
- 'test/**/*.rb'
|
53
|
+
|
54
|
+
Style/FrozenStringLiteralComment:
|
55
|
+
# We're not confident enough to make this recommendation everywhere
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
Style/ModuleFunction:
|
59
|
+
# `extend self` has fewer side effects than `module_function`.
|
60
|
+
EnforcedStyle: extend_self
|
61
|
+
|
62
|
+
Style/NumericLiterals:
|
63
|
+
Exclude:
|
64
|
+
- 'db/migrate/*.rb'
|
65
|
+
- 'test/**/*.rb'
|
66
|
+
|
67
|
+
Style/YodaCondition:
|
68
|
+
# Disagree; literals as first argument can guard against accidental assignment.
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
Style/SingleLineBlockParams:
|
72
|
+
# Prefer readability of contextually-named variables.
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
##################### Metrics ##################################
|
76
|
+
# NOTE: we bump some metrics by 50%, in recognition of Rubocop's
|
77
|
+
# desire to split that which we would consider atomic.
|
78
|
+
|
79
|
+
Metrics/AbcSize:
|
80
|
+
Max: 23
|
81
|
+
Exclude:
|
82
|
+
- 'db/migrate/*.rb'
|
83
|
+
- 'test/**/*.rb'
|
84
|
+
|
85
|
+
Metrics/BlockLength:
|
86
|
+
# We're already limiting method size, blocks outside of methods
|
87
|
+
# can legitimately be long (RuboCop defaults to max: 25 lines).
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
Metrics/ClassLength:
|
91
|
+
Max: 150
|
92
|
+
Exclude:
|
93
|
+
- 'db/migrate/*.rb'
|
94
|
+
- 'test/**/*.rb'
|
95
|
+
|
96
|
+
Metrics/ModuleLength:
|
97
|
+
Max: 150
|
98
|
+
Exclude:
|
99
|
+
- 'test/**/*.rb'
|
100
|
+
|
101
|
+
Metrics/CyclomaticComplexity:
|
102
|
+
Max: 9
|
103
|
+
|
104
|
+
Layout/LineLength:
|
105
|
+
Max: 100
|
106
|
+
Exclude:
|
107
|
+
- 'db/migrate/*.rb'
|
108
|
+
- 'test/**/*.rb'
|
109
|
+
|
110
|
+
Metrics/MethodLength:
|
111
|
+
Max: 15
|
112
|
+
Exclude:
|
113
|
+
- 'db/migrate/*.rb'
|
114
|
+
- 'test/**/*.rb'
|
115
|
+
|
116
|
+
Metrics/PerceivedComplexity:
|
117
|
+
Max: 12
|
118
|
+
|
119
|
+
##################### Rails ##################################
|
120
|
+
|
121
|
+
Rails/ActionFilter:
|
122
|
+
# 'action' is the default already; we explicitly list here as Rails 3.x
|
123
|
+
# projects will want to override this configuration to use 'filter' instead.
|
124
|
+
EnforcedStyle: action
|
125
|
+
|
126
|
+
Rails/DynamicFindBy:
|
127
|
+
Exclude:
|
128
|
+
- 'test/integration/**/*.rb'
|
129
|
+
|
130
|
+
Rails/RefuteMethods:
|
131
|
+
Enabled: false
|
132
|
+
|
133
|
+
Rails/SkipsModelValidations:
|
134
|
+
# Methods like 'update_column' exist for a reason, and it is the developer's
|
135
|
+
# responsibilty to understand the behaviour of the code they write; blanket
|
136
|
+
# avoiding them is not helpful/practical.
|
137
|
+
Enabled: false
|
138
|
+
|
@@ -5,12 +5,35 @@ require 'ndr_dev_support/rake_ci/concerns/commit_metadata_persistable'
|
|
5
5
|
|
6
6
|
# The plugin needs to extend Minitest
|
7
7
|
module Minitest
|
8
|
-
def self.plugin_rake_ci_init(
|
9
|
-
reporter << RakeCIReporter.new if RakeCIReporter.enabled?
|
8
|
+
def self.plugin_rake_ci_init(options)
|
9
|
+
reporter << RakeCIReporter.new(options[:io], options) if RakeCIReporter.enabled?
|
10
|
+
end
|
11
|
+
|
12
|
+
# Intermediate Reporter than can also track flakey failures
|
13
|
+
class FlakeyStatisticsReporter < StatisticsReporter
|
14
|
+
attr_accessor :flakey_results
|
15
|
+
|
16
|
+
def initialize(*)
|
17
|
+
super
|
18
|
+
|
19
|
+
self.flakey_results = []
|
20
|
+
end
|
21
|
+
|
22
|
+
def record(result)
|
23
|
+
super
|
24
|
+
|
25
|
+
return unless result.respond_to?(:flakes)
|
26
|
+
|
27
|
+
flakey_results << result if result.flakes.any?
|
28
|
+
end
|
29
|
+
|
30
|
+
def flakes
|
31
|
+
flakey_results.sum { |result| result.flakes.length }
|
32
|
+
end
|
10
33
|
end
|
11
34
|
|
12
35
|
# RakeCI Minitest Reporter
|
13
|
-
class RakeCIReporter <
|
36
|
+
class RakeCIReporter < FlakeyStatisticsReporter
|
14
37
|
def self.enable!
|
15
38
|
@enabled = true
|
16
39
|
end
|
@@ -55,6 +78,10 @@ module Minitest
|
|
55
78
|
snippets_for results.reject(&:skipped?).reject(&:error?)
|
56
79
|
end
|
57
80
|
|
81
|
+
def flake_snippets
|
82
|
+
snippets_for flakey_results
|
83
|
+
end
|
84
|
+
|
58
85
|
# Adapted from Rails' TestUnit reporter
|
59
86
|
def snippets_for(results, limit = 5)
|
60
87
|
executable = defined?(Rails) ? 'bin/rails test ' : 'bundle exec rake test TEST='
|
@@ -78,7 +105,7 @@ module Minitest
|
|
78
105
|
def current_statistics
|
79
106
|
@current_statistics ||= {
|
80
107
|
total_time: total_time, runs: count, assertions: assertions, failures: failures,
|
81
|
-
errors: errors, skips: skips
|
108
|
+
errors: errors, skips: skips, flakes: flakes
|
82
109
|
}
|
83
110
|
end
|
84
111
|
|
@@ -106,6 +133,7 @@ module Minitest
|
|
106
133
|
@current_attachments << failures_attachment if failures.positive?
|
107
134
|
@current_attachments << errors_attachment if errors.positive?
|
108
135
|
@current_attachments << pass_attachment if passing?
|
136
|
+
@current_attachments << flakes_attachment if flakes.positive?
|
109
137
|
@current_attachments
|
110
138
|
end
|
111
139
|
|
@@ -113,7 +141,15 @@ module Minitest
|
|
113
141
|
{
|
114
142
|
color: 'danger',
|
115
143
|
text: 'test failure'.pluralize(failures) + failure_snippets,
|
116
|
-
footer:
|
144
|
+
footer: footer
|
145
|
+
}
|
146
|
+
end
|
147
|
+
|
148
|
+
def flakes_attachment
|
149
|
+
{
|
150
|
+
color: '#bb44ff',
|
151
|
+
text: 'flakey test'.pluralize(flakes) + flake_snippets,
|
152
|
+
footer: footer
|
117
153
|
}
|
118
154
|
end
|
119
155
|
|
@@ -121,7 +157,7 @@ module Minitest
|
|
121
157
|
{
|
122
158
|
color: 'warning',
|
123
159
|
text: 'test error'.pluralize(errors) + error_snippets,
|
124
|
-
footer:
|
160
|
+
footer: footer
|
125
161
|
}
|
126
162
|
end
|
127
163
|
|
@@ -129,7 +165,7 @@ module Minitest
|
|
129
165
|
{
|
130
166
|
color: 'good',
|
131
167
|
text: newly_passing? ? 'Tests now pass! :tada:' : 'Tests passed',
|
132
|
-
footer:
|
168
|
+
footer: footer
|
133
169
|
}
|
134
170
|
end
|
135
171
|
|
@@ -150,5 +186,9 @@ module Minitest
|
|
150
186
|
def name
|
151
187
|
'minitest'
|
152
188
|
end
|
189
|
+
|
190
|
+
def footer
|
191
|
+
"bundle exec rake ci:minitest --seed #{options[:seed]}"
|
192
|
+
end
|
153
193
|
end
|
154
194
|
end
|
data/lib/ndr_dev_support.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
require 'ndr_dev_support/rubocop/inject'
|
1
2
|
require 'ndr_dev_support/version'
|
2
3
|
|
3
4
|
module NdrDevSupport
|
4
|
-
#
|
5
|
+
# Bootstrap our RuboCop config in to any project
|
6
|
+
# when ndr_dev_support is required in .rubocop.yml.
|
7
|
+
Rubocop::Inject.defaults!
|
5
8
|
end
|
@@ -17,7 +17,13 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
17
17
|
system("rm -rf #{cache}")
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
desc 'Ensures compilation artefacts are removed from the compressed archive sent to the server'
|
22
|
+
task :augment_copy_exclude do
|
23
|
+
set :copy_exclude, (fetch(:copy_exclude) || []) + %w[node_modules tmp/*]
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
27
|
+
before 'deploy:update_code', 'ndr_dev_support:augment_copy_exclude'
|
22
28
|
before 'deploy:update_code', 'ndr_dev_support:remove_svn_cache_if_needed'
|
23
29
|
end
|
@@ -48,7 +48,7 @@ module NdrDevSupport
|
|
48
48
|
|
49
49
|
git_fetch
|
50
50
|
git_discard_changes
|
51
|
-
git_checkout(
|
51
|
+
git_checkout(git_branch_name)
|
52
52
|
|
53
53
|
objectids_between_master_and_remote.each do |oid|
|
54
54
|
log("testing #{oid}...")
|
@@ -72,6 +72,10 @@ module NdrDevSupport
|
|
72
72
|
raise exception
|
73
73
|
end
|
74
74
|
|
75
|
+
def git_branch_name
|
76
|
+
ENV.fetch('RAKE_CI_BRANCH_NAME', MASTER_BRANCH_NAME)
|
77
|
+
end
|
78
|
+
|
75
79
|
def git_fetch
|
76
80
|
system(svn_remote? ? 'git svn fetch' : 'git fetch')
|
77
81
|
end
|
@@ -117,7 +121,7 @@ module NdrDevSupport
|
|
117
121
|
def objectids_between_master_and_remote
|
118
122
|
walker = Rugged::Walker.new(@repo)
|
119
123
|
walker.push(repo.branches[remote_branch].target_id)
|
120
|
-
current_target_id = repo.branches[
|
124
|
+
current_target_id = repo.branches[git_branch_name].target_id
|
121
125
|
|
122
126
|
revisions = []
|
123
127
|
# walk backwards from the most recent commit, breaking at the current one
|
@@ -18,6 +18,9 @@ end
|
|
18
18
|
# Include our custom DSL extensions, that also cover screenshotting:
|
19
19
|
require 'ndr_dev_support/integration_testing/dsl'
|
20
20
|
|
21
|
+
# Include support for retrying tests that sporadically fail:
|
22
|
+
require 'ndr_dev_support/integration_testing/flakey_tests'
|
23
|
+
|
21
24
|
# Keeps the selenium webdrivers automatically updated:
|
22
25
|
require 'webdrivers'
|
23
26
|
Webdrivers.cache_time = 24.hours
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module NdrDevSupport
|
2
|
+
module IntegrationTesting
|
3
|
+
# Grudging handling of flakey integration tests. Allows tests to be declared
|
4
|
+
# with `flakey_test`. Our CI reporter gathers information on flakey failures.
|
5
|
+
module FlakeyTests
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
class_attribute :attempts_per_test, default: {}
|
10
|
+
end
|
11
|
+
|
12
|
+
class_methods do
|
13
|
+
def flakey_test(description, attempts: 3, &block)
|
14
|
+
test(description, &block).tap do |test_name|
|
15
|
+
self.attempts_per_test = attempts_per_test.merge(test_name.to_s => attempts)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def flakes
|
21
|
+
@flakes ||= []
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
attempts_remaining = attempts_per_test[name]
|
26
|
+
return super unless attempts_remaining
|
27
|
+
|
28
|
+
previous_failure = failures.last
|
29
|
+
failed_attempts = []
|
30
|
+
|
31
|
+
loop do
|
32
|
+
break if attempts_remaining < 1
|
33
|
+
|
34
|
+
super
|
35
|
+
|
36
|
+
# No failure was added; we passed!
|
37
|
+
break if failures.last == previous_failure
|
38
|
+
|
39
|
+
# Ran out of attempts:
|
40
|
+
break if (attempts_remaining -= 1) < 1
|
41
|
+
|
42
|
+
# Loop round and have another go:
|
43
|
+
failed_attempts << failures.pop
|
44
|
+
end
|
45
|
+
|
46
|
+
# Attempts were only flakey if we eventually passed:
|
47
|
+
flakes.concat(failed_attempts) if failures.last == previous_failure
|
48
|
+
|
49
|
+
self
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
ActionDispatch::IntegrationTest.include(NdrDevSupport::IntegrationTesting::FlakeyTests)
|
@@ -10,7 +10,9 @@ module NdrDevSupport
|
|
10
10
|
|
11
11
|
attr_reader :new_fingerprints, :old_fingerprints, :tracker
|
12
12
|
|
13
|
-
def run
|
13
|
+
def run(strict:)
|
14
|
+
@strict = strict
|
15
|
+
|
14
16
|
@tracker = ::Brakeman.run(app_path: '.')
|
15
17
|
|
16
18
|
last_commit_fingerprints = load_last_commit_data
|
@@ -22,10 +24,16 @@ module NdrDevSupport
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
27
|
+
# All warnings (including those we've flagged as false positives)
|
25
28
|
def warnings
|
26
29
|
@tracker.warnings
|
27
30
|
end
|
28
31
|
|
32
|
+
# Only the warnings we haven't flagged as false positives (i.e. the outstanding ones)
|
33
|
+
def filtered_warnings
|
34
|
+
@tracker.filtered_warnings
|
35
|
+
end
|
36
|
+
|
29
37
|
def warning_counts_by_confidence
|
30
38
|
return @warning_counts_by_confidence if @warning_counts_by_confidence
|
31
39
|
|
@@ -36,13 +44,90 @@ module NdrDevSupport
|
|
36
44
|
@warning_counts_by_confidence
|
37
45
|
end
|
38
46
|
|
47
|
+
def filtered_warning_counts_by_confidence
|
48
|
+
return @filtered_warning_counts_by_confidence if @filtered_warning_counts_by_confidence
|
49
|
+
|
50
|
+
@filtered_warning_counts_by_confidence = {}
|
51
|
+
filtered_warnings.group_by(&:confidence).each do |confidence, grouped_warnings|
|
52
|
+
@filtered_warning_counts_by_confidence[confidence] = grouped_warnings.count
|
53
|
+
end
|
54
|
+
@filtered_warning_counts_by_confidence
|
55
|
+
end
|
56
|
+
|
39
57
|
def current_fingerprints
|
40
|
-
@current_fingerprints ||=
|
58
|
+
@current_fingerprints ||= filtered_warnings.map(&:fingerprint).to_set
|
41
59
|
end
|
42
60
|
|
43
61
|
def save_current_fingerprints
|
44
62
|
save_current_commit_data(current_fingerprints)
|
45
63
|
end
|
64
|
+
|
65
|
+
def metrics
|
66
|
+
metrics = []
|
67
|
+
|
68
|
+
::Brakeman::Warning::TEXT_CONFIDENCE.each do |confidence, text|
|
69
|
+
overall_metric = {
|
70
|
+
name: 'brakeman_warnings',
|
71
|
+
type: :gauge,
|
72
|
+
label_set: { confidence: text },
|
73
|
+
value: warning_counts_by_confidence[confidence] || 0
|
74
|
+
}
|
75
|
+
filtered_metric = {
|
76
|
+
name: 'brakeman_filtered_warnings',
|
77
|
+
type: :gauge,
|
78
|
+
label_set: { confidence: text },
|
79
|
+
value: filtered_warning_counts_by_confidence[confidence] || 0
|
80
|
+
}
|
81
|
+
metrics << overall_metric << filtered_metric
|
82
|
+
puts overall_metric.inspect
|
83
|
+
puts filtered_metric.inspect
|
84
|
+
end
|
85
|
+
|
86
|
+
metrics
|
87
|
+
end
|
88
|
+
|
89
|
+
def attachments
|
90
|
+
attachments = []
|
91
|
+
|
92
|
+
if @strict && current_fingerprints.any?
|
93
|
+
# all warnings found
|
94
|
+
attachment = {
|
95
|
+
color: 'danger',
|
96
|
+
title: "#{current_fingerprints.size} Brakeman warning(s) :rotating_light:",
|
97
|
+
text: '_Brakeman_ warning fingerprint(s):' \
|
98
|
+
"```#{current_fingerprints.to_a.join("\n")}```",
|
99
|
+
footer: 'bundle exec rake ci:brakeman:fingerprint_details FINGERPRINTS=...',
|
100
|
+
mrkdwn_in: ['text']
|
101
|
+
}
|
102
|
+
attachments << attachment
|
103
|
+
puts attachment.inspect
|
104
|
+
elsif new_fingerprints.any?
|
105
|
+
# new warnings found
|
106
|
+
attachment = {
|
107
|
+
color: 'danger',
|
108
|
+
title: "#{new_fingerprints.size} new Brakeman warning(s) :rotating_light:",
|
109
|
+
text: '_Brakeman_ warning fingerprint(s):' \
|
110
|
+
"```#{new_fingerprints.to_a.join("\n")}```",
|
111
|
+
footer: 'bundle exec rake ci:brakeman:fingerprint_details FINGERPRINTS=...',
|
112
|
+
mrkdwn_in: ['text']
|
113
|
+
}
|
114
|
+
attachments << attachment
|
115
|
+
puts attachment.inspect
|
116
|
+
end
|
117
|
+
|
118
|
+
unless old_fingerprints.empty?
|
119
|
+
# old warnings missing
|
120
|
+
attachment = {
|
121
|
+
color: 'good',
|
122
|
+
title: "#{old_fingerprints.size} Brakeman warning(s) resolved :+1:",
|
123
|
+
footer: 'bundle exec rake ci:brakeman'
|
124
|
+
}
|
125
|
+
attachments << attachment
|
126
|
+
puts attachment.inspect
|
127
|
+
end
|
128
|
+
|
129
|
+
attachments
|
130
|
+
end
|
46
131
|
end
|
47
132
|
end
|
48
133
|
end
|
@@ -36,13 +36,13 @@ module NdrDevSupport
|
|
36
36
|
@hostname = hostname
|
37
37
|
end
|
38
38
|
|
39
|
-
def process_commit(user, revision, message)
|
39
|
+
def process_commit(user, revision, message, tests_passed)
|
40
40
|
resolved_tickets = []
|
41
41
|
|
42
42
|
each_ticket_from(message) do |ticket, resolved|
|
43
|
-
update_ticket(message, user, revision, ticket, resolved)
|
43
|
+
update_ticket(message, user, revision, ticket, resolved, tests_passed)
|
44
44
|
|
45
|
-
resolved_tickets << ticket if resolved
|
45
|
+
resolved_tickets << ticket if resolved && tests_passed
|
46
46
|
end
|
47
47
|
|
48
48
|
resolved_tickets
|
@@ -62,13 +62,17 @@ module NdrDevSupport
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
def update_payload(message, user, revision, ticket_closed, resolved)
|
65
|
+
def update_payload(message, user, revision, ticket_closed, resolved, tests_passed)
|
66
|
+
if resolved && !ticket_closed && !tests_passed
|
67
|
+
message += "\n\n*Automated tests did not pass successfully, so ticket status left unchanged.*"
|
68
|
+
end
|
69
|
+
|
66
70
|
payload = {
|
67
71
|
notes: "_#{resolved ? 'Resolved' : 'Referenced'} by #{user} in #{revision}_:" \
|
68
72
|
"#{resolved ? message.gsub(CLOSE_REGEX, '+\1+') : message}"
|
69
73
|
}
|
70
74
|
|
71
|
-
payload[:status_id] = 3 if resolved && !ticket_closed
|
75
|
+
payload[:status_id] = 3 if resolved && !ticket_closed && tests_passed
|
72
76
|
payload
|
73
77
|
end
|
74
78
|
|
@@ -82,8 +86,8 @@ module NdrDevSupport
|
|
82
86
|
@http
|
83
87
|
end
|
84
88
|
|
85
|
-
def update_ticket(message, user, revision, ticket, resolved)
|
86
|
-
payload = update_payload(message, user, revision, ticket_closed?(ticket), resolved)
|
89
|
+
def update_ticket(message, user, revision, ticket, resolved, tests_passed)
|
90
|
+
payload = update_payload(message, user, revision, ticket_closed?(ticket), resolved, tests_passed)
|
87
91
|
|
88
92
|
http.send_request('PUT',
|
89
93
|
"/issues/#{ticket.to_i}.json",
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubocop'
|
2
|
+
|
3
|
+
module NdrDevSupport
|
4
|
+
module Rubocop
|
5
|
+
# Following approach of rubocop-hq/rubocop-extension-generator,
|
6
|
+
# monkey-patch in default configuration.
|
7
|
+
module Inject
|
8
|
+
def self.defaults!
|
9
|
+
root = Pathname.new(__dir__).parent.parent.parent.expand_path
|
10
|
+
path = root.join('config', 'rubocop', 'ndr.yml').to_s
|
11
|
+
|
12
|
+
# Whereas by default, the raw YAML would be processed, we pass
|
13
|
+
# through the ConfigLoader fully - this ensures `require` and
|
14
|
+
# `inherit_from` statements are properly evaluated.
|
15
|
+
#
|
16
|
+
# PR at rubocop-hq/rubocop-extension-generator/pull/9
|
17
|
+
#
|
18
|
+
config = ::RuboCop::ConfigLoader.load_file(path)
|
19
|
+
puts "configuration from \#{path}" if ::RuboCop::ConfigLoader.debug?
|
20
|
+
|
21
|
+
config = ::RuboCop::ConfigLoader.merge_with_default(config, path)
|
22
|
+
::RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/tasks/ci/brakeman.rake
CHANGED
@@ -11,48 +11,35 @@ namespace :ci do
|
|
11
11
|
|
12
12
|
brakeman = NdrDevSupport::RakeCI::BrakemanHelper.new
|
13
13
|
brakeman.commit = @commit
|
14
|
-
brakeman.run
|
15
|
-
|
16
|
-
Brakeman::Warning::TEXT_CONFIDENCE.each do |confidence, text|
|
17
|
-
metric = {
|
18
|
-
name: 'brakeman_warnings',
|
19
|
-
type: :gauge,
|
20
|
-
label_set: { confidence: text },
|
21
|
-
value: brakeman.warning_counts_by_confidence[confidence] || 0
|
22
|
-
}
|
23
|
-
@metrics << metric
|
24
|
-
puts metric.inspect
|
25
|
-
end
|
26
|
-
|
27
|
-
unless brakeman.new_fingerprints.empty?
|
28
|
-
# new warnings found
|
29
|
-
attachment = {
|
30
|
-
color: 'danger',
|
31
|
-
title: "#{brakeman.new_fingerprints.size} new Brakeman warning(s) :rotating_light:",
|
32
|
-
text: '_Brakeman_ warning fingerprint(s):' \
|
33
|
-
"```#{brakeman.new_fingerprints.to_a.join("\n")}```",
|
34
|
-
footer: 'bundle exec rake ci:brakeman:fingerprint_details FINGERPRINTS=...',
|
35
|
-
mrkdwn_in: ['text']
|
36
|
-
}
|
37
|
-
@attachments << attachment
|
38
|
-
puts attachment.inspect
|
39
|
-
end
|
14
|
+
brakeman.run(strict: false)
|
40
15
|
|
41
|
-
|
42
|
-
|
43
|
-
attachment = {
|
44
|
-
color: 'good',
|
45
|
-
title: "#{brakeman.old_fingerprints.size} Brakeman warning(s) resolved :+1:",
|
46
|
-
footer: 'bundle exec rake ci:brakeman'
|
47
|
-
}
|
48
|
-
@attachments << attachment
|
49
|
-
puts attachment.inspect
|
50
|
-
end
|
16
|
+
@metrics.concat(brakeman.metrics)
|
17
|
+
@attachments.concat(brakeman.attachments)
|
51
18
|
|
52
19
|
brakeman.save_current_fingerprints
|
53
20
|
end
|
54
21
|
|
55
22
|
namespace :brakeman do
|
23
|
+
desc "Brakeman (strict mode - all issues must be reviewed by Brakeman's interactive mode)"
|
24
|
+
task strict: 'ci:rugged:setup' do
|
25
|
+
next unless defined?(Rails)
|
26
|
+
|
27
|
+
require 'ndr_dev_support/rake_ci/brakeman_helper'
|
28
|
+
# Usage: bundle exec rake ci:brakeman:strict
|
29
|
+
|
30
|
+
@metrics ||= []
|
31
|
+
@attachments ||= []
|
32
|
+
|
33
|
+
brakeman = NdrDevSupport::RakeCI::BrakemanHelper.new
|
34
|
+
brakeman.commit = @commit
|
35
|
+
brakeman.run(strict: true)
|
36
|
+
|
37
|
+
@metrics.concat(brakeman.metrics)
|
38
|
+
@attachments.concat(brakeman.attachments)
|
39
|
+
|
40
|
+
brakeman.save_current_fingerprints
|
41
|
+
end
|
42
|
+
|
56
43
|
desc 'Brakeman fingerprint details'
|
57
44
|
task fingerprint_details: 'ci:rugged:setup' do
|
58
45
|
# Usage: bundle exec rake ci:brakeman:fingerprint_details FINGERPRINTS=fp1,fp2,...
|
data/lib/tasks/ci/minitest.rake
CHANGED
@@ -47,10 +47,9 @@ namespace :ci do
|
|
47
47
|
# Test(s) ran
|
48
48
|
Rake::Task['ci:simplecov:process'].invoke
|
49
49
|
|
50
|
-
if
|
51
|
-
|
52
|
-
|
53
|
-
Rake::Task['ci:redmine:update_tickets'].invoke
|
50
|
+
if Rake::Task.task_defined?('ci:redmine:update_tickets')
|
51
|
+
tests_passed = hash[:statistics][:failures].zero? && hash[:statistics][:errors].zero?
|
52
|
+
Rake::Task['ci:redmine:update_tickets'].invoke(tests_passed)
|
54
53
|
end
|
55
54
|
|
56
55
|
@attachments.concat(hash[:attachments])
|
data/lib/tasks/ci/redmine.rake
CHANGED
@@ -12,7 +12,7 @@ namespace :ci do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
desc 'Update Redmine tickets'
|
15
|
-
task update_tickets: ['ci:rugged:setup', 'ci:redmine:setup'] do
|
15
|
+
task :update_tickets, [:tests_passed] => ['ci:rugged:setup', 'ci:redmine:setup'] do |task, args|
|
16
16
|
api_key = ENV['REDMINE_API_KEY']
|
17
17
|
hostname = ENV['REDMINE_HOSTNAME']
|
18
18
|
next if api_key.nil? || hostname.nil?
|
@@ -27,7 +27,7 @@ namespace :ci do
|
|
27
27
|
ticket_resolver = NdrDevSupport::RakeCI::Redmine::TicketResolver.new(api_key, hostname)
|
28
28
|
resolved_tickets = ticket_resolver.process_commit(@commit.author[:name],
|
29
29
|
@friendly_revision_name,
|
30
|
-
@commit.message)
|
30
|
+
@commit.message, args.tests_passed)
|
31
31
|
rescue
|
32
32
|
@attachments << {
|
33
33
|
color: 'danger',
|
@@ -41,7 +41,8 @@ namespace :ci do
|
|
41
41
|
resolved_tickets.map! { |ticket_id| "https://#{hostname}/issues/#{ticket_id}" }
|
42
42
|
|
43
43
|
old_attachment = @attachments.detect { |att| att[:text] =~ /Tests( now)? pass/ }
|
44
|
-
basic_text
|
44
|
+
basic_text = old_attachment.try(:[], :text) || 'Tests passed'
|
45
|
+
footer = old_attachment.try(:[], :footer) || 'bundle exec rake ci:minitest'
|
45
46
|
|
46
47
|
@attachments.delete(old_attachment) if old_attachment
|
47
48
|
|
@@ -51,7 +52,7 @@ namespace :ci do
|
|
51
52
|
title: "#{issue_s.capitalize} Resolved",
|
52
53
|
text: "#{basic_text}, so #{issue_s} #{resolved_tickets.join(', ')}" \
|
53
54
|
" #{resolved_tickets.count == 1 ? 'has' : 'have'} been resolved",
|
54
|
-
footer:
|
55
|
+
footer: footer,
|
55
56
|
mrkdwn_in: ['text']
|
56
57
|
}
|
57
58
|
@attachments << attachment
|
data/ndr_dev_support.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
# Integration test dependencies:
|
37
37
|
spec.add_dependency 'capybara', '>= 3.20'
|
38
38
|
spec.add_dependency 'capybara-screenshot'
|
39
|
+
spec.add_dependency 'minitest', '~> 5.0'
|
39
40
|
spec.add_dependency 'poltergeist', '>= 1.8.0'
|
40
41
|
spec.add_dependency 'selenium-webdriver'
|
41
42
|
spec.add_dependency 'show_me_the_cookies'
|
@@ -55,7 +56,6 @@ Gem::Specification.new do |spec|
|
|
55
56
|
spec.add_dependency 'capistrano', '~> 2.15'
|
56
57
|
|
57
58
|
spec.add_development_dependency 'bundler'
|
58
|
-
spec.add_development_dependency 'minitest', '~> 5.0'
|
59
59
|
spec.add_development_dependency 'mocha'
|
60
|
-
spec.add_development_dependency 'rake', '~>
|
60
|
+
spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
|
61
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ndr_dev_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NCRS Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: minitest
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '5.0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '5.0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: poltergeist
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,20 +346,6 @@ dependencies:
|
|
332
346
|
- - ">="
|
333
347
|
- !ruby/object:Gem::Version
|
334
348
|
version: '0'
|
335
|
-
- !ruby/object:Gem::Dependency
|
336
|
-
name: minitest
|
337
|
-
requirement: !ruby/object:Gem::Requirement
|
338
|
-
requirements:
|
339
|
-
- - "~>"
|
340
|
-
- !ruby/object:Gem::Version
|
341
|
-
version: '5.0'
|
342
|
-
type: :development
|
343
|
-
prerelease: false
|
344
|
-
version_requirements: !ruby/object:Gem::Requirement
|
345
|
-
requirements:
|
346
|
-
- - "~>"
|
347
|
-
- !ruby/object:Gem::Version
|
348
|
-
version: '5.0'
|
349
349
|
- !ruby/object:Gem::Dependency
|
350
350
|
name: mocha
|
351
351
|
requirement: !ruby/object:Gem::Requirement
|
@@ -366,14 +366,20 @@ dependencies:
|
|
366
366
|
requirements:
|
367
367
|
- - "~>"
|
368
368
|
- !ruby/object:Gem::Version
|
369
|
-
version: '
|
369
|
+
version: '12.3'
|
370
|
+
- - ">="
|
371
|
+
- !ruby/object:Gem::Version
|
372
|
+
version: 12.3.3
|
370
373
|
type: :development
|
371
374
|
prerelease: false
|
372
375
|
version_requirements: !ruby/object:Gem::Requirement
|
373
376
|
requirements:
|
374
377
|
- - "~>"
|
375
378
|
- !ruby/object:Gem::Version
|
376
|
-
version: '
|
379
|
+
version: '12.3'
|
380
|
+
- - ">="
|
381
|
+
- !ruby/object:Gem::Version
|
382
|
+
version: 12.3.3
|
377
383
|
description: Provides support to developers of NDR projects
|
378
384
|
email: []
|
379
385
|
executables: []
|
@@ -392,6 +398,7 @@ files:
|
|
392
398
|
- bin/console
|
393
399
|
- bin/setup
|
394
400
|
- code_safety.yml
|
401
|
+
- config/rubocop/ndr.yml
|
395
402
|
- gemfiles/Gemfile.rails52
|
396
403
|
- gemfiles/Gemfile.rails60
|
397
404
|
- lib/minitest/rake_ci.rb
|
@@ -414,6 +421,7 @@ files:
|
|
414
421
|
- lib/ndr_dev_support/integration_testing/drivers/poltergeist.rb
|
415
422
|
- lib/ndr_dev_support/integration_testing/drivers/switchable.rb
|
416
423
|
- lib/ndr_dev_support/integration_testing/dsl.rb
|
424
|
+
- lib/ndr_dev_support/integration_testing/flakey_tests.rb
|
417
425
|
- lib/ndr_dev_support/rake_ci/brakeman_helper.rb
|
418
426
|
- lib/ndr_dev_support/rake_ci/commit_cop.rb
|
419
427
|
- lib/ndr_dev_support/rake_ci/commit_cop/concerns/deputisable.rb
|
@@ -425,6 +433,7 @@ files:
|
|
425
433
|
- lib/ndr_dev_support/rake_ci/redmine/ticket_resolver.rb
|
426
434
|
- lib/ndr_dev_support/rake_ci/simple_cov_helper.rb
|
427
435
|
- lib/ndr_dev_support/rubocop/executor.rb
|
436
|
+
- lib/ndr_dev_support/rubocop/inject.rb
|
428
437
|
- lib/ndr_dev_support/rubocop/range_augmenter.rb
|
429
438
|
- lib/ndr_dev_support/rubocop/range_finder.rb
|
430
439
|
- lib/ndr_dev_support/rubocop/reporter.rb
|