ndr_dev_support 6.0.2 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -1
- data/code_safety.yml +8 -4
- data/lib/ndr_dev_support/daemon/stoppable.rb +5 -0
- data/lib/ndr_dev_support/tasks.rb +1 -0
- data/lib/ndr_dev_support/version.rb +1 -1
- data/lib/tasks/audit_bundle.rake +171 -0
- data/lib/tasks/ci/prometheus.rake +5 -3
- data/ndr_dev_support.gemspec +5 -4
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67a32537a9f42f905530b37c03c4e98ddd4aa8436833e1ce38e4443701f8216d
|
4
|
+
data.tar.gz: cd6489387c3d8bd0af51b26e4315dcfd57b1592a46dda39e7e2e1e5f161d519d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf21a7b0849c34190f27024df4a1e50c11bc635681cba4dc4a3e6708c37a0b81400ef5810badf125cd65044cfc69eab543d2c531a378db5e0853eeba57ed4012
|
7
|
+
data.tar.gz: 229c84f00339e8435b75d2048e8d849092f50ce79e1a0d8f1964d575e89ec74e26b1b975d768ae422811d609b84a503d7014dcef95274ab626fd6c441e1212af
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
## [Unreleased]
|
2
|
-
*
|
2
|
+
* No unreleased changes
|
3
|
+
|
4
|
+
## 6.1.0 / 2022-04-28
|
5
|
+
### Fixed
|
6
|
+
* CI: support Ruby 3.0
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
* Allow Ctrl-C to cleanly interrupt an idle daemon
|
10
|
+
* Drop support for Ruby 2.6
|
11
|
+
|
12
|
+
## 6.0.5 / unreleased
|
13
|
+
|
14
|
+
## 6.0.4 / 2022-03-14
|
15
|
+
### Fixed
|
16
|
+
* bundle:update should commit code_safety.yml changes.
|
17
|
+
|
18
|
+
## 6.0.3 / 2022-03-14
|
19
|
+
### Added
|
20
|
+
* Add `bundle:update` rake task to update bundled gem files
|
3
21
|
|
4
22
|
## 6.0.2 / 2022-01-14
|
5
23
|
### Fixed
|
data/code_safety.yml
CHANGED
@@ -27,7 +27,7 @@ file safety:
|
|
27
27
|
CHANGELOG.md:
|
28
28
|
comments:
|
29
29
|
reviewed_by: brian.shand
|
30
|
-
safe_revision:
|
30
|
+
safe_revision: 25fcab1b2df9476bfa294085a46073b218785c19
|
31
31
|
CODE_OF_CONDUCT.md:
|
32
32
|
comments:
|
33
33
|
reviewed_by: timgentry
|
@@ -226,12 +226,16 @@ file safety:
|
|
226
226
|
safe_revision: ad38e92c6e56b9d81fdab10681d8f2924eeadf5a
|
227
227
|
lib/ndr_dev_support/tasks.rb:
|
228
228
|
comments:
|
229
|
-
reviewed_by:
|
230
|
-
safe_revision:
|
229
|
+
reviewed_by: brian.shand
|
230
|
+
safe_revision: 93f9ed210c6a19eee4884ea8a906067c65ee67f6
|
231
231
|
lib/ndr_dev_support/version.rb:
|
232
232
|
comments:
|
233
233
|
reviewed_by: brian.shand
|
234
|
-
safe_revision:
|
234
|
+
safe_revision: 25fcab1b2df9476bfa294085a46073b218785c19
|
235
|
+
lib/tasks/audit_bundle.rake:
|
236
|
+
comments:
|
237
|
+
reviewed_by: brian.shand
|
238
|
+
safe_revision: 9682c3eb39a98d5a5256732af647a8bd7750826b
|
235
239
|
lib/tasks/audit_code.rake:
|
236
240
|
comments: Identical to the version reviewed by josh.pencheon when contained within
|
237
241
|
ndr_support
|
@@ -105,7 +105,12 @@ module NdrDevSupport
|
|
105
105
|
|
106
106
|
number_of_mini_sleeps.times do
|
107
107
|
return if should_stop?
|
108
|
+
|
108
109
|
sleep(LITTLE_SLEEP)
|
110
|
+
rescue Interrupt
|
111
|
+
# Ctrl-C should stop cleanly if used while the process is snoozing
|
112
|
+
@should_stop = true
|
113
|
+
return
|
109
114
|
end
|
110
115
|
end
|
111
116
|
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# A rake task to update the bundled version of a gem
|
2
|
+
|
3
|
+
# Assumes constant SAFETY_FILE and function repository_type are defined in another rake task.
|
4
|
+
|
5
|
+
namespace :bundle do
|
6
|
+
desc <<~USAGE
|
7
|
+
Update to a later version of a gem interactively.
|
8
|
+
|
9
|
+
Usage: bundle:update gem=rails [version=6.0.4.7]
|
10
|
+
|
11
|
+
Updates the bundled gem (e.g. rails) version to e.g. 6.0.4.7
|
12
|
+
and provides instructions for committing changes.
|
13
|
+
It will attempt to modify a hardcoded version in the Gemfile if necessary.
|
14
|
+
USAGE
|
15
|
+
task(:update) do
|
16
|
+
unless %w[git git-svn].include?(repository_type)
|
17
|
+
warn 'Error: Requires a git working copy. Aborting.'
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
gem = ENV['gem']
|
22
|
+
if gem.blank? || gem !~ /\A[a-zA-Z0-9_.-]+\z/
|
23
|
+
warn "Error: missing or invalid required 'gem' parameter. Aborting.\n\n"
|
24
|
+
system('rake -D bundle:update')
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
gem_list = Bundler.with_unbundled_env { `bundle exec gem list ^#{gem}$` }
|
29
|
+
# Needs to match e.g. "nokogiri (1.12.5 x86_64-darwin)"
|
30
|
+
old_gem_version = gem_list.match(/ \(([0-9.]+)( [a-z0-9_-]*)?\)$/).to_a[1]
|
31
|
+
unless old_gem_version
|
32
|
+
warn <<~MSG.chomp
|
33
|
+
Cannot determine gem version for gem=#{gem}. Aborting. Output from bundle exec gem list:
|
34
|
+
#{gem_list}
|
35
|
+
MSG
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
puts "Old #{gem} version from bundle: #{old_gem_version}"
|
39
|
+
|
40
|
+
new_gem_version = ENV['version'].presence
|
41
|
+
if new_gem_version && new_gem_version !~ /\A[0-9.a-zA-Z-]+\z/
|
42
|
+
warn "Error: invalid 'version' parameter. Aborting.\n\n"
|
43
|
+
system('rake -D bundle:update')
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
|
47
|
+
unless Bundler.with_unbundled_env { system('bundle check 2> /dev/null') }
|
48
|
+
warn('Error: bundle check fails before doing anything.')
|
49
|
+
warn('Please clean up the Gemfile before running this. Aborting.')
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
|
53
|
+
if gem == 'rails'
|
54
|
+
# If updating Rails and using activemodel-caution, prompt to put
|
55
|
+
# activemodel-caution gem in place, unless it's already installed for this rails version.
|
56
|
+
activemodel_caution = Bundler.
|
57
|
+
with_unbundled_env { `bundle exec gem list activemodel-caution` }.
|
58
|
+
match?(/^activemodel-caution \([0-9.]+\)$/)
|
59
|
+
if activemodel_caution && new_gem_version
|
60
|
+
file_pattern = "activemodel-caution-#{new_gem_version}*.gem"
|
61
|
+
unless Dir.glob("vendor/cache/#{file_pattern}").any? ||
|
62
|
+
Bundler.with_unbundled_env do
|
63
|
+
`gem list ^activemodel-caution$ -i -v #{new_gem_version}`
|
64
|
+
end.match?(/^true$/)
|
65
|
+
warn("Error: missing #{file_pattern} file in vendor/cache")
|
66
|
+
warn('Copy this file to vendor/cache, then run this command again.')
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
related_gems = if gem == 'rails'
|
73
|
+
gem_list2 = Bundler.with_unbundled_env do
|
74
|
+
`bundle exec gem list`
|
75
|
+
end
|
76
|
+
gem_list2.split("\n").
|
77
|
+
grep(/[ (]#{old_gem_version}(.0)*[,)]/).
|
78
|
+
collect { |row| row.split.first }
|
79
|
+
else
|
80
|
+
[gem]
|
81
|
+
end
|
82
|
+
puts "Gems to update: #{related_gems.join(' ')}"
|
83
|
+
|
84
|
+
if new_gem_version
|
85
|
+
puts 'Tweaking Gemfile for new gem version'
|
86
|
+
cmd = ['sed', '-i', '.bak', '-E']
|
87
|
+
related_gems.each do |rgem|
|
88
|
+
cmd += ['-e', "s/(gem '(#{rgem})', '(~> )?)#{old_gem_version}(')/\\1#{new_gem_version}\\4/"]
|
89
|
+
end
|
90
|
+
cmd += %w[Gemfile]
|
91
|
+
system(*cmd)
|
92
|
+
File.delete('Gemfile.bak')
|
93
|
+
|
94
|
+
system('git diff Gemfile')
|
95
|
+
end
|
96
|
+
|
97
|
+
cmd = "bundle update --conservative --minor #{related_gems.join(' ')}"
|
98
|
+
puts "Running: #{cmd}"
|
99
|
+
Bundler.with_unbundled_env do
|
100
|
+
system(cmd)
|
101
|
+
end
|
102
|
+
|
103
|
+
unless Bundler.with_unbundled_env { system('bundle check 2> /dev/null') }
|
104
|
+
warn <<~MSG
|
105
|
+
Error: bundle check fails after trying to update Rails version. Aborting.
|
106
|
+
You will need to check your working copy, especially Gemfile, Gemfile.lock, vendor/cache
|
107
|
+
MSG
|
108
|
+
exit 1
|
109
|
+
end
|
110
|
+
|
111
|
+
if File.exist?(SAFETY_FILE)
|
112
|
+
# Remove references to unused files in code_safety.yml
|
113
|
+
system('rake audit:tidy_code_safety_file')
|
114
|
+
end
|
115
|
+
|
116
|
+
gem_list = Bundler.with_unbundled_env { `bundle exec gem list ^#{gem}$` }
|
117
|
+
new_gem_version2 = gem_list.match(/ \(([0-9.]+)( [a-z0-9_-]*)?\)$/).to_a[1]
|
118
|
+
|
119
|
+
if new_gem_version && new_gem_version != new_gem_version2
|
120
|
+
puts <<~MSG
|
121
|
+
Error: Tried to update gem #{gem} to version #{new_gem_version} but ended up at version #{new_gem_version2}. Aborting.
|
122
|
+
You will need to check your working copy, especially Gemfile, Gemfile.lock, vendor/cache
|
123
|
+
Try running:
|
124
|
+
bundle exec rake bundle:update gem=#{gem} version=#{new_gem_version2}
|
125
|
+
MSG
|
126
|
+
exit 1
|
127
|
+
end
|
128
|
+
|
129
|
+
# At this point, we have successfully updated all the local files.
|
130
|
+
# All that remains is to set up a branch, if necessary, and inform the user what to commit.
|
131
|
+
|
132
|
+
puts "Looking for changed files using git status\n\n"
|
133
|
+
files_to_git_rm = `git status vendor/cache/|grep 'deleted: ' | \
|
134
|
+
grep -o ': .*' | sed -e 's/^: *//'`.split("\n")
|
135
|
+
files_to_git_add = `git status Gemfile Gemfile.lock code_safety.yml config/code_safety.yml| \
|
136
|
+
grep 'modified: ' | \
|
137
|
+
grep -o ': .*' | sed -e 's/^: *//'`.split("\n")
|
138
|
+
files_to_git_add += `git status vendor/cache|expand|grep '^\s*vendor/cache' | \
|
139
|
+
sed -e 's/^ *//'`.split("\n")
|
140
|
+
|
141
|
+
if files_to_git_rm.empty? && files_to_git_add.empty?
|
142
|
+
puts <<~MSG
|
143
|
+
No changes were made. Please manually update the Gemfile, run
|
144
|
+
bundle update --conservative --minor #{related_gems.join(' ')}
|
145
|
+
MSG
|
146
|
+
puts ' rake audit:tidy_code_safety_file' if File.exist?(SAFETY_FILE)
|
147
|
+
puts <<~MSG
|
148
|
+
then run tests and git rm / git add any changes
|
149
|
+
including vendor/cache Gemfile Gemfile.lock code_safety.yml
|
150
|
+
then git commit
|
151
|
+
MSG
|
152
|
+
exit
|
153
|
+
end
|
154
|
+
|
155
|
+
if repository_type == 'git'
|
156
|
+
# Check out a fresh branch, if a git working copy (but not git-svn)
|
157
|
+
branch_name = "#{gem}_#{new_gem_version2.gsub('.', '_')}"
|
158
|
+
system('git', 'checkout', '-b', branch_name) # Create a new git branch
|
159
|
+
end
|
160
|
+
|
161
|
+
puts <<~MSG
|
162
|
+
Gemfile updated. Please use "git status" and "git diff" to check the local changes,
|
163
|
+
manually add any additional platform-specific gems required (e.g. for nokogiri),
|
164
|
+
re-run tests locally, then run the following to commit the changes:
|
165
|
+
|
166
|
+
$ git rm #{files_to_git_rm.join(' ')}
|
167
|
+
$ git add #{files_to_git_add.join(' ')}
|
168
|
+
$ git commit -m '# Bump #{gem} to #{new_gem_version2}'
|
169
|
+
MSG
|
170
|
+
end
|
171
|
+
end
|
@@ -38,15 +38,17 @@ namespace :ci do
|
|
38
38
|
if prometheus.exist?(name)
|
39
39
|
prometheus.get(name)
|
40
40
|
else
|
41
|
-
|
41
|
+
labels = (label_set.keys + [:project]).uniq
|
42
|
+
prometheus.gauge(name, docstring: docstring, labels: labels,
|
43
|
+
preset_labels: { project: project })
|
42
44
|
end
|
43
|
-
gauge.set(
|
45
|
+
gauge.set(value, labels: label_set)
|
44
46
|
else
|
45
47
|
raise "Unknown metric type (#{metric.inspect})"
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
|
-
client = Prometheus::Client::Push.new("rake-ci-#{project}",
|
51
|
+
client = Prometheus::Client::Push.new(job: "rake-ci-#{project}", gateway: gateway)
|
50
52
|
|
51
53
|
begin
|
52
54
|
client.add(prometheus)
|
data/ndr_dev_support.gemspec
CHANGED
@@ -12,12 +12,13 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.homepage = 'https://github.com/PublicHealthEngland/ndr_dev_support'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
15
|
-
spec.files = `git ls-files -z`.split("\x0").
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").
|
16
|
+
reject { |f| f.match(%r{^(\.github|test|spec|features)/}) }
|
16
17
|
spec.bindir = 'exe'
|
17
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
19
|
spec.require_paths = ['lib']
|
19
20
|
|
20
|
-
spec.required_ruby_version = '>= 2.
|
21
|
+
spec.required_ruby_version = '>= 2.7'
|
21
22
|
|
22
23
|
spec.add_dependency 'pry'
|
23
24
|
|
@@ -28,8 +29,8 @@ Gem::Specification.new do |spec|
|
|
28
29
|
spec.add_dependency 'parser'
|
29
30
|
spec.add_dependency 'rainbow'
|
30
31
|
spec.add_dependency 'rubocop', '~> 1.7'
|
31
|
-
spec.add_dependency 'rubocop-rake', '~> 0.5'
|
32
32
|
spec.add_dependency 'rubocop-rails', '~> 2.9'
|
33
|
+
spec.add_dependency 'rubocop-rake', '~> 0.5'
|
33
34
|
spec.add_dependency 'unicode-display_width', '>= 1.3.3'
|
34
35
|
|
35
36
|
# Integration test dependencies:
|
@@ -46,7 +47,7 @@ Gem::Specification.new do |spec|
|
|
46
47
|
spec.add_dependency 'brakeman', '>= 4.7.1'
|
47
48
|
spec.add_dependency 'bundler-audit'
|
48
49
|
spec.add_dependency 'github-linguist'
|
49
|
-
spec.add_dependency 'prometheus-client', '~> 0.
|
50
|
+
spec.add_dependency 'prometheus-client', '~> 4.0.0'
|
50
51
|
spec.add_dependency 'rugged'
|
51
52
|
spec.add_dependency 'simplecov'
|
52
53
|
spec.add_dependency 'with_clean_rbenv'
|
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: 6.0
|
4
|
+
version: 6.1.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: 2022-
|
11
|
+
date: 2022-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -81,33 +81,33 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.7'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop-
|
84
|
+
name: rubocop-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.9'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.9'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: rubocop-
|
98
|
+
name: rubocop-rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0.5'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0.5'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: unicode-display_width
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,14 +282,14 @@ dependencies:
|
|
282
282
|
requirements:
|
283
283
|
- - "~>"
|
284
284
|
- !ruby/object:Gem::Version
|
285
|
-
version: 0.
|
285
|
+
version: 4.0.0
|
286
286
|
type: :runtime
|
287
287
|
prerelease: false
|
288
288
|
version_requirements: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
290
|
- - "~>"
|
291
291
|
- !ruby/object:Gem::Version
|
292
|
-
version: 0.
|
292
|
+
version: 4.0.0
|
293
293
|
- !ruby/object:Gem::Dependency
|
294
294
|
name: rugged
|
295
295
|
requirement: !ruby/object:Gem::Requirement
|
@@ -450,6 +450,7 @@ files:
|
|
450
450
|
- lib/ndr_dev_support/slack_message_publisher.rb
|
451
451
|
- lib/ndr_dev_support/tasks.rb
|
452
452
|
- lib/ndr_dev_support/version.rb
|
453
|
+
- lib/tasks/audit_bundle.rake
|
453
454
|
- lib/tasks/audit_code.rake
|
454
455
|
- lib/tasks/ci/brakeman.rake
|
455
456
|
- lib/tasks/ci/bundle_audit.rake
|
@@ -480,7 +481,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
480
481
|
requirements:
|
481
482
|
- - ">="
|
482
483
|
- !ruby/object:Gem::Version
|
483
|
-
version: '2.
|
484
|
+
version: '2.7'
|
484
485
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
485
486
|
requirements:
|
486
487
|
- - ">="
|