groundskeeper-bitcore 0.16.0 → 0.21.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: 1448cba896d4d2a4dd501ba945c66fb33ea2d61b039a931e3b2e281efbd2f8e6
4
- data.tar.gz: 224187c49d02f02eadbbb85421579ece568c270307b3eff50dd044684f26b949
3
+ metadata.gz: 1eac58f6bfc760b50d34890dd5a828d289a6e04670b7fa8b373038a6ba7464e7
4
+ data.tar.gz: bfe6d170c239314941b713d84411853e810f9d78675fc5c5137f3f0833bdb852
5
5
  SHA512:
6
- metadata.gz: a34d5b2fa7fc5ec78c14d7e2a7b56deedf02da8433d163993925cc31594ae07f570c2682ab2273424358afb5358a16bebeb070673dd1393c97877b3708e84b65
7
- data.tar.gz: d8ca482356226b3786c69afab64e5a7e47f2233b29c2c39442111e705243c018ff6c84f64bba7ef1a5e26246afceb21ae0282328a351d7be3d20817636b7612d
6
+ metadata.gz: 5be5c57f082ebcd53a599b9bd261454c9353425fb84bf2d38a4f73fc52e53b371db2454489a095c3a7141654a7968d997bbfc726d47e8cc76861e406b8da2ba5
7
+ data.tar.gz: 9e238b3b3deaa46383a6440b23f5ba8c25f3a327776307c08ddeac62b62f4153cdfb460fcf68639980bbfffaca0a144db09b9401f7f0234f8de4ad0d711df621
@@ -39,3 +39,6 @@ Style/SingleLineMethods:
39
39
 
40
40
  Style/StringLiterals:
41
41
  EnforcedStyle: double_quotes
42
+
43
+ Style/IfUnlessModifier:
44
+ Enabled: false
@@ -2,7 +2,10 @@
2
2
 
3
3
  require "yaml"
4
4
  require "json"
5
- require "groundskeeper"
5
+ require "groundskeeper/project"
6
+ require "groundskeeper/document"
7
+ require "groundskeeper/git"
8
+ require "groundskeeper/executable"
6
9
 
7
10
  desc "Sets up project details."
8
11
  # rubocop:disable Metrics/BlockLength
@@ -25,6 +28,7 @@ task :before_run do
25
28
  set :deploy_to, project.deploy_to
26
29
  set :forward_agent, true
27
30
  set :bundle_path, "bundle"
31
+ set :smtp_domain, project.smtp_domain
28
32
 
29
33
  set :rvm_ruby_version, project.rvm_ruby_version
30
34
  set :rvm_type, :system
@@ -64,7 +64,7 @@ Rails.application.configure do
64
64
  authentication: :plain,
65
65
  address: 'smtp.mailgun.org',
66
66
  port: 587,
67
- domain: 'cbits.northwestern.edu',
67
+ domain: '<%= fetch :smtp_domain %>',
68
68
  user_name: ENV['mailgun_db_username'],
69
69
  password: ENV['mailgun_db_password']
70
70
  }
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = "ground"
32
32
  spec.require_paths = %w[lib config]
33
33
 
34
+ spec.required_ruby_version = ">= 2.4"
34
35
  spec.add_dependency "jira-ruby", "~> 2.0"
35
36
  spec.add_dependency "mina", "~> 1.2"
36
37
  spec.add_dependency "mina-whenever", "~> 1.0.1"
@@ -5,6 +5,7 @@ require "thor"
5
5
  module Groundskeeper
6
6
  # Bootstrap this as a Thor application.
7
7
  class Application < Thor
8
+ include Thor::Actions
8
9
  attr_reader :commands
9
10
 
10
11
  class_option :simulate, desc: "Simulate mina"
@@ -5,6 +5,8 @@ require "mina"
5
5
  require "pp"
6
6
  require "open3"
7
7
 
8
+ class VersionError < StandardError; end
9
+
8
10
  module Groundskeeper
9
11
  # Formulas for managing releases and deployments.
10
12
  # rubocop:disable Metrics/ClassLength
@@ -93,7 +95,7 @@ module Groundskeeper
93
95
  # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
94
96
  def info(options = {})
95
97
  return unrecognized_version unless version_file.exists?
96
- return unless check_groundskeeper_version
98
+ return groundskeeper_outdated unless check_groundskeeper_version
97
99
 
98
100
  Executable.verbose = options[:verbose]
99
101
  pull_project_details
@@ -112,13 +114,12 @@ module Groundskeeper
112
114
  # rubocop:enable Metrics/AbcSize
113
115
 
114
116
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,
115
- # rubocop:disable Metrics/PerceivedComplexity
116
117
  def release(options = {})
117
118
  is_initial_release = !version_file.exists?
118
119
 
119
120
  return missing_jira_credentials unless jira.credentials?
120
121
  return missing_bitbucket_credentials unless bitbucket.credentials?
121
- return unless check_groundskeeper_version
122
+ return groundskeeper_outdated unless check_groundskeeper_version
122
123
  return unrecognized_version unless version_file.rails?
123
124
 
124
125
  version_file.create_initial_version! unless version_file.exists?
@@ -137,12 +138,12 @@ module Groundskeeper
137
138
  create_pr
138
139
  end
139
140
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
140
- # rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity
141
+ # rubocop:enable Metrics/MethodLength
141
142
 
142
143
  # :nocov:
143
144
  def predeploy(options = {})
144
145
  return unrecognized_version unless version_file.exists?
145
- return unless check_groundskeeper_version
146
+ return groundskeeper_outdated unless check_groundskeeper_version
146
147
 
147
148
  Executable.verbose = options[:verbose]
148
149
  pull_project_details
@@ -159,7 +160,7 @@ module Groundskeeper
159
160
  return missing_jira_credentials unless jira.credentials?
160
161
  return missing_sentry_credentials unless sentry.credentials?
161
162
  return missing_slack_credentials unless slack.credentials?
162
- return unless check_groundskeeper_version
163
+ return groundskeeper_outdated unless check_groundskeeper_version
163
164
  return unable_to_ssh unless ssh.can_connect?
164
165
 
165
166
  Executable.verbose = options[:verbose]
@@ -203,26 +204,32 @@ module Groundskeeper
203
204
  end
204
205
  end
205
206
 
206
- # rubocop:disable Metrics/MethodLength
207
207
  def check_groundskeeper_version
208
208
  @check_groundskeeper_version ||= begin
209
209
  console.say("Groundskeeper version #{Groundskeeper::VERSION}\n\n",
210
210
  :bold)
211
211
  latest_version = rubygems.latest_groundskeeper_version
212
212
 
213
- if SemanticVersion.new(latest_version) > SemanticVersion.new(VERSION)
214
- console.say(
215
- "Groundskeeper is outdated, please install #{latest_version}",
216
- :red
217
- )
213
+ return true unless SemanticVersion.new(latest_version) > VERSION
218
214
 
219
- false
220
- else
221
- true
222
- end
215
+ return false unless install_latest_groundskeeper?
216
+
217
+ console.run("gem install groundskeeper-bitcore")
218
+
219
+ true
223
220
  end
224
221
  end
225
- # rubocop:enable Metrics/MethodLength
222
+
223
+ # :nocov:
224
+ def install_latest_groundskeeper?
225
+ question = <<~TEXT.squish
226
+ Groundskeeper is outdated,
227
+ would you like the latest version installed?
228
+ TEXT
229
+
230
+ console.ask(question, :red, limited_to: %w[yes no]) == "yes"
231
+ end
232
+ # :nocov:
226
233
 
227
234
  def announce_latest_tag
228
235
  console.say(
@@ -281,8 +288,14 @@ module Groundskeeper
281
288
 
282
289
  def add_version_to_jira_issues
283
290
  issue_ids = jira.included_issues(recent_commits)
284
- jira.add_version_to_remote_issues(next_jira_version_name, issue_ids)
285
- console.say("# added version to Jira issues #{issue_ids}", :green)
291
+ message = jira.add_version_to_remote_issues(
292
+ next_jira_version_name, issue_ids
293
+ )
294
+ if message.blank?
295
+ console.say("# added version to Jira issues #{issue_ids}", :green)
296
+ else
297
+ announce_error(message)
298
+ end
286
299
  end
287
300
 
288
301
  def create_pr
@@ -307,6 +320,10 @@ module Groundskeeper
307
320
  tag.nil? ? false : git.list_tags.include?(tag)
308
321
  end
309
322
 
323
+ def announce_error(message)
324
+ console.say("# #{message}", :red)
325
+ end
326
+
310
327
  def unrecognized_tag
311
328
  console.say(
312
329
  "Tag not found, try again with an existing tag.",
@@ -321,6 +338,10 @@ module Groundskeeper
321
338
  )
322
339
  end
323
340
 
341
+ def groundskeeper_outdated
342
+ console.say("Groundskeeper outdated. Install the latest version.", :red)
343
+ end
344
+
324
345
  def missing_bitbucket_credentials
325
346
  console.say(
326
347
  "Please configure your Bitbucket environment variables.",
@@ -375,16 +396,24 @@ module Groundskeeper
375
396
 
376
397
  # rubocop:disable Metrics/MethodLength
377
398
  def update_deployed_issues
399
+ tries = 0
400
+
378
401
  announce_step(
379
402
  "Check deployed version at #{website.uri}/#{Website::VERSION_PATH}"
380
403
  )
381
- deployed_version = website.version
382
404
 
383
- if deployed_version == ENV[TAG]
405
+ begin
406
+ deployed_version = website.version
407
+
408
+ raise VersionError unless deployed_version == ENV[TAG]
409
+
384
410
  console.say("# deployment successful", :green)
385
411
  transition_remote_issues deployed_version
386
412
  announce_in_slack deployed_version
387
- else
413
+ rescue VersionError
414
+ tries += 1
415
+ sleep 5
416
+ retry if tries < 3
388
417
  # :nocov:
389
418
  console.say(
390
419
  "something went wrong: expected version #{ENV[TAG]}, " \
@@ -4,6 +4,8 @@ require "cgi"
4
4
  require "date"
5
5
  require "jira-ruby"
6
6
 
7
+ class IssueNotFoundError < StandardError; end
8
+
7
9
  module Groundskeeper
8
10
  # Wraps an interface to Jira.
9
11
  class Jira
@@ -46,6 +48,8 @@ module Groundskeeper
46
48
 
47
49
  # :nocov:
48
50
  def add_version_to_issue(issue_id:, version_name:)
51
+ raise IssueNotFoundError if client.Issue.find(issue_id).nil?
52
+
49
53
  client.Issue
50
54
  .find(issue_id)
51
55
  .save(update: { fixVersions: [{ add: { name: version_name } }] })
@@ -120,11 +124,22 @@ module Groundskeeper
120
124
  client.create_version(name: name, prefix: prefix)
121
125
  end
122
126
 
127
+ # rubocop:disable Metrics/MethodLength
123
128
  def add_version_to_remote_issues(name, issue_ids)
129
+ failed_issues = []
124
130
  issue_ids.each do |issue_id|
125
- client.add_version_to_issue(issue_id: issue_id, version_name: name)
131
+ begin
132
+ client.add_version_to_issue(issue_id: issue_id, version_name: name)
133
+ rescue IssueNotFoundError
134
+ failed_issues << issue_id
135
+ next
136
+ end
126
137
  end
138
+ return "" unless failed_issues.count.positive?
139
+
140
+ "Jira issue(s) not found, is #{failed_issues.join(', ')} correct?"
127
141
  end
142
+ # rubocop:enable Metrics/MethodLength
128
143
 
129
144
  def transition_remote_issues(transition_type, issue_ids)
130
145
  issue_ids.each do |issue_id|
@@ -17,6 +17,7 @@ module Groundskeeper
17
17
  DB_ENV_VARIABLES_KEY = "db_env_variables"
18
18
  SENTRY_DSN_KEY = "sentry_dsn"
19
19
  SENTRY_PROJECT_KEY = "sentry_project"
20
+ SMTP_DOMAIN = "smtp_domain"
20
21
  SSL_CERTIFICATE_FILE_KEY = "SSLCertificateFile"
21
22
  SSL_CERTIFICATE_CHAIN_FILE_KEY = "SSLCertificateChainFile"
22
23
  SSL_CERTIFICATE_KEY_FILE_KEY = "SSLCertificateKeyFile"
@@ -65,6 +66,12 @@ module Groundskeeper
65
66
  end
66
67
  # :nocov:
67
68
 
69
+ # :nocov:
70
+ def smtp_domain
71
+ details[SMTP_DOMAIN] || ""
72
+ end
73
+ # :nocov:
74
+
68
75
  # :nocov:
69
76
  def rvm_ruby_version
70
77
  details[RVM_RUBY_VERSION_KEY] || ""
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Groundskeeper
4
- VERSION = "0.16.0"
4
+ VERSION = "0.21.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groundskeeper-bitcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BIT Core
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - certs/ericcf.pem
12
- date: 2020-04-28 00:00:00.000000000 Z
12
+ date: 2021-01-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jira-ruby
@@ -217,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
217
  requirements:
218
218
  - - ">="
219
219
  - !ruby/object:Gem::Version
220
- version: '0'
220
+ version: '2.4'
221
221
  required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  requirements:
223
223
  - - ">="