git-story-workflow 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/git-story-workflow.gemspec +2 -2
- data/lib/git/story/app.rb +71 -37
- data/lib/git/story/semaphore.rb +5 -6
- data/lib/git/story/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfb4794483a9fc8fae288f546621e9b2b3ca26cb4957a1b38234ed5a5c224f38
|
4
|
+
data.tar.gz: b41cfb8c0e1b5fe6aea8e7093b19a0d34aa743a2dbd4da89cb5fcc5fcf077a67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 529663aa542c6afc333d21bf6f3155d5a361456f05f76abfcb41581834fffb1f0271e3ea3a2a2ff97a8620c9805b9bedc6b33b77172617fb0b39868bc3cf363c
|
7
|
+
data.tar.gz: 971b4044b632e27edda167a514fffc97967bc73c5b17ff685ecfda07b73dfdaaa6d825412e5033d0f4b5988f69f53e14271f77a58b33e346c86315da52349b4b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/git-story-workflow.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: git-story-workflow 0.
|
2
|
+
# stub: git-story-workflow 0.5.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "git-story-workflow".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.5.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
data/lib/git/story/app.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'time'
|
2
2
|
require 'open-uri'
|
3
|
+
require 'tins/go'
|
3
4
|
|
4
5
|
class Git::Story::App
|
5
6
|
class ::String
|
@@ -9,6 +10,7 @@ class Git::Story::App
|
|
9
10
|
include Git::Story::Utils
|
10
11
|
extend Git::Story::Utils
|
11
12
|
include ComplexConfig::Provider::Shortcuts
|
13
|
+
include Tins::GO
|
12
14
|
|
13
15
|
annotate :command
|
14
16
|
|
@@ -26,8 +28,9 @@ class Git::Story::App
|
|
26
28
|
attr_accessor :story_author
|
27
29
|
end
|
28
30
|
|
29
|
-
def initialize(argv = ARGV, debug: ENV['DEBUG'].to_i == 1)
|
31
|
+
def initialize(argv = ARGV.dup, debug: ENV['DEBUG'].to_i == 1)
|
30
32
|
@argv = argv
|
33
|
+
@opts = go 'n:', @argv
|
31
34
|
@command = @argv.shift&.to_sym
|
32
35
|
@debug = debug
|
33
36
|
end
|
@@ -93,46 +96,52 @@ class Git::Story::App
|
|
93
96
|
|
94
97
|
command doc: '[BRANCH] display test status of branch'
|
95
98
|
def test_status(branch = current(check: false))
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
99
|
+
watch do
|
100
|
+
auth_token = complex_config.story.semaphore_auth_token
|
101
|
+
project = complex_config.story.semaphore_test_project
|
102
|
+
url = "https://semaphoreci.com/api/v1/projects/#{project}/#{branch}/status?auth_token=#{auth_token}"
|
103
|
+
Git::Story::SemaphoreResponse.get(url, debug: @debug)
|
104
|
+
end
|
100
105
|
rescue => e
|
101
106
|
"Getting #{url.inspect} => #{e.class}: #{e}".red
|
102
107
|
end
|
103
108
|
|
104
109
|
command doc: '[BRANCH] display docker build status of branch'
|
105
110
|
def docker_status
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
111
|
+
watch do
|
112
|
+
auth_token = complex_config.story.semaphore_auth_token
|
113
|
+
project = complex_config.story.semaphore_docker_project
|
114
|
+
url = "https://semaphoreci.com/api/v1/projects/#{project}/docker/status?auth_token=#{auth_token}"
|
115
|
+
Git::Story::SemaphoreResponse.get(url, debug: @debug)
|
116
|
+
end
|
110
117
|
rescue => e
|
111
118
|
"Getting #{url.inspect} => #{e.class}: #{e}".red
|
112
119
|
end
|
113
120
|
|
114
121
|
command doc: '[SERVER] display deploy status of branch'
|
115
122
|
def deploy_status(server = complex_config.story.semaphore_default_server)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
123
|
+
watch do
|
124
|
+
auth_token = complex_config.story.semaphore_auth_token
|
125
|
+
project = complex_config.story.semaphore_docker_project
|
126
|
+
url = "https://semaphoreci.com/api/v1/projects/#{project}/servers/#{server}?auth_token=#{auth_token}"
|
127
|
+
server = Git::Story::SemaphoreResponse.get(url, debug: @debug)
|
128
|
+
deploys = server.deploys
|
129
|
+
upcoming = deploys.select(&:pending?)&.last
|
130
|
+
passed = deploys.select(&:passed?)
|
131
|
+
current = passed.first
|
132
|
+
if !passed.empty? && upcoming
|
133
|
+
upcoming.estimated_duration = passed.sum { |d| d.duration.to_f } / passed.size
|
134
|
+
end
|
135
|
+
<<~end
|
136
|
+
Server: #{server.server_name&.green}
|
137
|
+
Branch: #{server.branch_name&.color('#ff5f00')}
|
138
|
+
Semaphore: #{server.server_url}
|
139
|
+
Strategy: #{server.strategy}
|
140
|
+
Upcoming:
|
141
|
+
#{upcoming}
|
142
|
+
Current:
|
143
|
+
#{current}
|
144
|
+
end
|
136
145
|
end
|
137
146
|
rescue => e
|
138
147
|
"Getting #{url.inspect} => #{e.class}: #{e}".red
|
@@ -140,14 +149,16 @@ class Git::Story::App
|
|
140
149
|
|
141
150
|
command doc: '[BRANCH] display build status for branch'
|
142
151
|
def build_status(branch = current(check: false))
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
152
|
+
watch do
|
153
|
+
[
|
154
|
+
"Test Status".bold,
|
155
|
+
test_status(branch) || 'n/a',
|
156
|
+
"Docker Status".bold,
|
157
|
+
docker_status || 'n/a',
|
158
|
+
"Deploy Status".bold,
|
159
|
+
deploy_status || 'n/a',
|
160
|
+
] * "\n\n"
|
161
|
+
end
|
151
162
|
end
|
152
163
|
|
153
164
|
|
@@ -316,6 +327,29 @@ class Git::Story::App
|
|
316
327
|
|
317
328
|
private
|
318
329
|
|
330
|
+
def watch(&block)
|
331
|
+
if seconds = @opts[?n]&.to_i and !@watching
|
332
|
+
@watching = true
|
333
|
+
if seconds == 0
|
334
|
+
seconds = 60
|
335
|
+
end
|
336
|
+
loop do
|
337
|
+
r = block.()
|
338
|
+
system('clear')
|
339
|
+
start = Time.now
|
340
|
+
puts r
|
341
|
+
refresh_at = start + seconds
|
342
|
+
duration = refresh_at - start
|
343
|
+
if duration > 0
|
344
|
+
puts "<<< #{Time.now.iso8601} Refresh every #{seconds} seconds >>>".rjust(Tins::Terminal.cols)
|
345
|
+
sleep duration
|
346
|
+
end
|
347
|
+
end
|
348
|
+
else
|
349
|
+
block.()
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
319
353
|
def normalize_name(name, max_size: nil)
|
320
354
|
name = name.downcase
|
321
355
|
name = name.tr('äöü', 'aou').tr(?ß, 'ss')
|
data/lib/git/story/semaphore.rb
CHANGED
@@ -101,12 +101,11 @@ class Git::Story::SemaphoreResponse < JSON::GenericObject
|
|
101
101
|
end
|
102
102
|
r = StringIO.new(r)
|
103
103
|
duration_seconds = duration.to_f.to_i
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
104
|
+
if passed? || failed?
|
105
|
+
total_seconds = duration_seconds
|
106
|
+
else
|
107
|
+
total_seconds = estimated_duration.to_i
|
108
|
+
end
|
110
109
|
Infobar(
|
111
110
|
current: duration_seconds,
|
112
111
|
total: total_seconds,
|
data/lib/git/story/version.rb
CHANGED