groundskeeper-bitcore 0.2.7 → 0.3.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 +4 -4
- data/README.md +13 -1
- data/groundskeeper.gemspec +1 -0
- data/lib/groundskeeper.rb +1 -0
- data/lib/groundskeeper/commands.rb +44 -13
- data/lib/groundskeeper/git.rb +10 -0
- data/lib/groundskeeper/project.rb +5 -0
- data/lib/groundskeeper/sentry.rb +48 -0
- data/lib/groundskeeper/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cf64d2506cf32911c7e1ab501f47c1252448101
|
4
|
+
data.tar.gz: 0f549714b3219739a4bec6d42742ebbf57a09159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddc494c4bf9437239d7a4fe37bea74bbf36df700faa6ec0bd6f418d9b9ec7837b391b21e565e73749a95733784d990cca96f104339a7523c428f880cbccaed04
|
7
|
+
data.tar.gz: c43ce1f114abd12e195ba268c155e041b949813a920c5d7e94b799fdfaa497bdc73c31d38ea0e8f7779b79954f63e8560b1d13ad2e7b3dc67fb56587b5dd3b2d
|
data/README.md
CHANGED
@@ -23,12 +23,24 @@ export JIRA_PASSWORD="my-password"
|
|
23
23
|
export JIRA_SITE="https://cbit123.atlassian.net"
|
24
24
|
```
|
25
25
|
|
26
|
-
|
26
|
+
You also need to add a GitHub API Token with `repo` scope to your `bash_profile`.
|
27
|
+
You can create one [here](https://github.com/settings/tokens) if you don't have
|
28
|
+
one already.
|
27
29
|
|
28
30
|
```bash
|
29
31
|
export GITHUB_API_TOKEN="my-github-api-token"
|
30
32
|
```
|
31
33
|
|
34
|
+
For integration with Sentry, find and add your auth token
|
35
|
+
[from here](https://sentry.io/settings/account/api/auth-tokens/):
|
36
|
+
|
37
|
+
```bash
|
38
|
+
export SENTRY_AUTH_TOKEN="auth-token"
|
39
|
+
export SENTRY_ORG=cbits
|
40
|
+
```
|
41
|
+
|
42
|
+
Then you will need to [install/update the Sentry CLI](https://docs.sentry.io/learn/cli/installation/).
|
43
|
+
|
32
44
|
Jira integration also depends on a repository that contains metadata for
|
33
45
|
projects. Clone it as follows:
|
34
46
|
|
data/groundskeeper.gemspec
CHANGED
data/lib/groundskeeper.rb
CHANGED
@@ -12,6 +12,7 @@ require "groundskeeper/rails_version"
|
|
12
12
|
require "groundskeeper/repository"
|
13
13
|
require "groundskeeper/rubygems"
|
14
14
|
require "groundskeeper/semantic_version"
|
15
|
+
require "groundskeeper/sentry"
|
15
16
|
require "groundskeeper/version"
|
16
17
|
require "groundskeeper/website"
|
17
18
|
|
@@ -18,14 +18,20 @@ module Groundskeeper
|
|
18
18
|
DEFAULT_STAGE = STAGING
|
19
19
|
TAG = "tag"
|
20
20
|
|
21
|
-
# rubocop:disable Metrics/MethodLength
|
21
|
+
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
22
22
|
def self.build(console)
|
23
23
|
repository = Repository.new
|
24
24
|
project = Project.build(repository.name)
|
25
|
+
deploy_url = "https://#{project.full_dns(stage)}"
|
26
|
+
website = Website.new(deploy_url)
|
25
27
|
git_hub = GitHub.build(
|
26
28
|
username: project.source_control_username,
|
27
29
|
repository_name: repository.name
|
28
30
|
)
|
31
|
+
sentry = Sentry.build(
|
32
|
+
project_name: project.sentry_project,
|
33
|
+
version_prefix: repository.name
|
34
|
+
)
|
29
35
|
|
30
36
|
new(
|
31
37
|
changelog: Changelog.build,
|
@@ -36,10 +42,16 @@ module Groundskeeper
|
|
36
42
|
project: project,
|
37
43
|
repository: repository,
|
38
44
|
rubygems: Rubygems,
|
39
|
-
|
45
|
+
sentry: sentry,
|
46
|
+
version_file: RailsVersion.new,
|
47
|
+
website: website
|
40
48
|
)
|
41
49
|
end
|
42
|
-
# rubocop:enable Metrics/MethodLength
|
50
|
+
# rubocop:enable Metrics/AbcSize,Metrics/MethodLength
|
51
|
+
|
52
|
+
def self.stage
|
53
|
+
ENV[STAGE] == PRODUCTION ? PRODUCTION : DEFAULT_STAGE
|
54
|
+
end
|
43
55
|
|
44
56
|
# rubocop:disable Metrics/MethodLength,Metrics/ParameterLists
|
45
57
|
def initialize(
|
@@ -51,6 +63,8 @@ module Groundskeeper
|
|
51
63
|
project: nil,
|
52
64
|
repository: nil,
|
53
65
|
rubygems: nil,
|
66
|
+
sentry: nil,
|
67
|
+
website: nil,
|
54
68
|
version_file:
|
55
69
|
)
|
56
70
|
@changelog = changelog
|
@@ -61,17 +75,19 @@ module Groundskeeper
|
|
61
75
|
@project = project
|
62
76
|
@repository = repository
|
63
77
|
@rubygems = rubygems
|
78
|
+
@sentry = sentry
|
79
|
+
@website = website
|
64
80
|
@version_file = version_file
|
65
81
|
@did_checkout_branch = false
|
66
82
|
@did_push_to_remote = false
|
67
83
|
end
|
68
84
|
# rubocop:enable Metrics/MethodLength,Metrics/ParameterLists
|
69
85
|
|
70
|
-
# rubocop:disable Metrics/MethodLength
|
86
|
+
# rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
71
87
|
def info
|
72
88
|
return unrecognized_version unless version_file.exists?
|
73
|
-
|
74
89
|
return unless check_groundskeeper_version
|
90
|
+
pull_project_details
|
75
91
|
|
76
92
|
announce_latest_tag
|
77
93
|
console.say(
|
@@ -84,12 +100,14 @@ module Groundskeeper
|
|
84
100
|
:yellow
|
85
101
|
)
|
86
102
|
end
|
103
|
+
# rubocop:enable Metrics/AbcSize
|
87
104
|
|
88
105
|
# rubocop:disable Metrics/AbcSize
|
89
106
|
def release
|
90
107
|
return unrecognized_version unless version_file.exists?
|
91
108
|
return missing_jira_credentials unless jira.credentials?
|
92
109
|
return unless check_groundskeeper_version
|
110
|
+
pull_project_details
|
93
111
|
|
94
112
|
summarize_recent_commits
|
95
113
|
ask_next_version
|
@@ -108,27 +126,32 @@ module Groundskeeper
|
|
108
126
|
def predeploy(options)
|
109
127
|
return unrecognized_version unless version_file.exists?
|
110
128
|
return unless check_groundskeeper_version
|
129
|
+
pull_project_details
|
111
130
|
|
112
131
|
mina "predeploy", options
|
113
132
|
end
|
114
133
|
|
134
|
+
# rubocop:disable Metrics/AbcSize
|
115
135
|
def deploy(options)
|
116
136
|
return unrecognized_version unless version_file.exists?
|
117
137
|
return missing_jira_credentials unless jira.credentials?
|
118
138
|
return unless check_groundskeeper_version
|
139
|
+
pull_project_details
|
119
140
|
|
120
141
|
ENV["whenever"] = "1" if project.uses_whenever?
|
121
142
|
|
122
143
|
mina "deploy", options
|
123
144
|
console.say("waiting for deployed application to restart...", :yellow)
|
124
145
|
update_deployed_issues
|
146
|
+
add_version_to_sentry
|
125
147
|
end
|
148
|
+
# rubocop:enable Metrics/AbcSize
|
126
149
|
|
127
150
|
private
|
128
151
|
|
129
152
|
# collaborators
|
130
153
|
attr_reader :changelog, :console, :git, :git_hub, :jira, :project,
|
131
|
-
:repository, :rubygems, :version_file
|
154
|
+
:repository, :rubygems, :sentry, :version_file, :website
|
132
155
|
# state
|
133
156
|
attr_reader :next_version, :recent_commits, :did_checkout_branch,
|
134
157
|
:did_push_to_remote
|
@@ -141,6 +164,12 @@ module Groundskeeper
|
|
141
164
|
run_mina cmd
|
142
165
|
end
|
143
166
|
|
167
|
+
def pull_project_details
|
168
|
+
console.say("Updating ~/.project_details from "\
|
169
|
+
"#{git.remote_url('.project_details')}")
|
170
|
+
git.pull(".project_details")
|
171
|
+
end
|
172
|
+
|
144
173
|
def check_groundskeeper_version
|
145
174
|
console.say("Groundskeeper version #{Groundskeeper::VERSION}\n\n", :bold)
|
146
175
|
latest_version = rubygems.latest_groundskeeper_version
|
@@ -239,6 +268,12 @@ module Groundskeeper
|
|
239
268
|
"#{repository.name} #{next_version}"
|
240
269
|
end
|
241
270
|
|
271
|
+
def add_version_to_sentry
|
272
|
+
sentry.create_release(ENV[TAG])
|
273
|
+
sentry.associate_commits(ENV[TAG])
|
274
|
+
console.say("# added version to Sentry", :green)
|
275
|
+
end
|
276
|
+
|
242
277
|
def unrecognized_version
|
243
278
|
console.say(
|
244
279
|
"Unable to find version file, is this a Rails application?",
|
@@ -275,8 +310,7 @@ module Groundskeeper
|
|
275
310
|
end
|
276
311
|
|
277
312
|
def update_deployed_issues
|
278
|
-
|
279
|
-
deployed_version = Website.new(deployed_url).version
|
313
|
+
deployed_version = website.version
|
280
314
|
|
281
315
|
if deployed_version == ENV[TAG]
|
282
316
|
console.say("# deployment successful", :green)
|
@@ -286,14 +320,11 @@ module Groundskeeper
|
|
286
320
|
end
|
287
321
|
end
|
288
322
|
|
289
|
-
def stage
|
290
|
-
ENV[STAGE] == PRODUCTION ? PRODUCTION : DEFAULT_STAGE
|
291
|
-
end
|
292
|
-
|
293
323
|
def transition_remote_issues(version)
|
294
324
|
version_name = "#{repository.name} #{version}"
|
295
325
|
deployed_issues = jira.fetch_issues_by_fix_version(version_name)
|
296
|
-
action =
|
326
|
+
action =
|
327
|
+
self.class.stage == PRODUCTION ? Jira::DELIVER : Jira::DEPLOY_TO_STAGING
|
297
328
|
console.say(
|
298
329
|
"transitioning deployed issues in Jira: " \
|
299
330
|
"#{action} #{deployed_issues.join(', ')}",
|
data/lib/groundskeeper/git.rb
CHANGED
@@ -18,6 +18,8 @@ module Groundskeeper
|
|
18
18
|
COMMIT = "commit -m \"%s\""
|
19
19
|
ADD_TAG = "tag %s"
|
20
20
|
PUSH_HEAD_WITH_TAGS = "push origin head --tags"
|
21
|
+
PULL = "-C #{Dir.home}/%s pull"
|
22
|
+
REMOTE_URL = "-C #{Dir.home}/%s config --get remote.origin.url"
|
21
23
|
|
22
24
|
attr_reader :git
|
23
25
|
|
@@ -87,5 +89,13 @@ module Groundskeeper
|
|
87
89
|
def push_with_tags
|
88
90
|
git.execute(PUSH_HEAD_WITH_TAGS)
|
89
91
|
end
|
92
|
+
|
93
|
+
def pull(name)
|
94
|
+
git.execute(format(PULL, name))
|
95
|
+
end
|
96
|
+
|
97
|
+
def remote_url(name)
|
98
|
+
git.execute(format(REMOTE_URL, name))
|
99
|
+
end
|
90
100
|
end
|
91
101
|
end
|
@@ -18,6 +18,7 @@ module Groundskeeper
|
|
18
18
|
DB_ENV_VARIABLES_KEY = "db_env_variables"
|
19
19
|
SENTRY_DSN_KEY = "sentry_dsn"
|
20
20
|
SENTRY_PUBLIC_DSN_KEY = "sentry_public_dsn"
|
21
|
+
SENTRY_PROJECT_KEY = "sentry_project"
|
21
22
|
SSL_CERTIFICATE_FILE_KEY = "SSLCertificateFile"
|
22
23
|
SSL_CERTIFICATE_CHAIN_FILE_KEY = "SSLCertificateChainFile"
|
23
24
|
SSL_CERTIFICATE_KEY_FILE_KEY = "SSLCertificateKeyFile"
|
@@ -76,6 +77,10 @@ module Groundskeeper
|
|
76
77
|
details[SENTRY_PUBLIC_DSN_KEY] || ""
|
77
78
|
end
|
78
79
|
|
80
|
+
def sentry_project
|
81
|
+
details[SENTRY_PROJECT_KEY] || ""
|
82
|
+
end
|
83
|
+
|
79
84
|
def ssl_certificate_file(stage)
|
80
85
|
details.dig(SSL_CERTIFICATE_FILE_KEY, stage.to_s) || ""
|
81
86
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Groundskeeper
|
4
|
+
# Wraps Sentry CLI executable.
|
5
|
+
class Sentry
|
6
|
+
COMMAND = "sentry-cli"
|
7
|
+
# sentry-cli arguments
|
8
|
+
RELEASE = "releases new -p %<project>s \"%<version>s\""
|
9
|
+
ASSOCIATE = "releases set-commits --auto \"%<version>s\""
|
10
|
+
|
11
|
+
attr_reader :sentry, :project_name, :version_prefix
|
12
|
+
|
13
|
+
# Wraps the "sentry-cli" shell command.
|
14
|
+
class Executable
|
15
|
+
def execute(arguments)
|
16
|
+
`#{COMMAND} #{arguments}`
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.build(project_name:, version_prefix:)
|
21
|
+
new(
|
22
|
+
sentry: Executable.new,
|
23
|
+
project_name: project_name,
|
24
|
+
version_prefix: version_prefix
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(sentry:, project_name:, version_prefix:)
|
29
|
+
@sentry = sentry
|
30
|
+
@project_name = project_name
|
31
|
+
@version_prefix = version_prefix
|
32
|
+
end
|
33
|
+
|
34
|
+
# Notify Sentry about release
|
35
|
+
def create_release(version)
|
36
|
+
name = "#{version_prefix} #{version}"
|
37
|
+
|
38
|
+
sentry.execute(format(RELEASE, project: project_name, version: name))
|
39
|
+
end
|
40
|
+
|
41
|
+
# Associate commits with the release
|
42
|
+
def associate_commits(version)
|
43
|
+
name = "#{version_prefix} #{version}"
|
44
|
+
|
45
|
+
sentry.execute(format(ASSOCIATE, version: name))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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.
|
4
|
+
version: 0.3.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: 2018-
|
12
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jira-ruby
|
@@ -123,6 +123,20 @@ dependencies:
|
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0.14'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: byebug
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
126
140
|
description:
|
127
141
|
email:
|
128
142
|
- ericcf@northwestern.edu
|
@@ -167,6 +181,7 @@ files:
|
|
167
181
|
- lib/groundskeeper/repository.rb
|
168
182
|
- lib/groundskeeper/rubygems.rb
|
169
183
|
- lib/groundskeeper/semantic_version.rb
|
184
|
+
- lib/groundskeeper/sentry.rb
|
170
185
|
- lib/groundskeeper/version.rb
|
171
186
|
- lib/groundskeeper/website.rb
|
172
187
|
- servers.yml
|