renuo-cli 4.24.0 → 4.24.1
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/lib/renuo/cli/commands/ci/check_deploio_status.rb +56 -24
- data/lib/renuo/cli/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: 456b03fb5a2d4bfa991efb571755004c00a515b672de04d5d99cb40176445201
|
|
4
|
+
data.tar.gz: 108335dbceb383a2be328ed1f16f28c97f0e62dcb5c270495704c30ed1ecd23f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d69d47ce40a20dd5b590d684e62117613c074db0f6178a0a8c4470af451ddb171637b6fe23e23198f4f5ed2fa40661cbbfb87ed5b92357adbbfb56085a0e2689
|
|
7
|
+
data.tar.gz: 81e5ff22b46aa16b11ad3fa9cf1a0a91d7eb0c91cebc88604611610018ea47957b5e51d0c44217e0c9cca75aa86dc7eca37aea5a9ce7600b211d1b9f6c3c69c3
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
# simplecov:disable
|
|
4
4
|
module Renuo::Cli::Commands::Ci
|
|
5
|
-
class CheckDeploioStatus
|
|
5
|
+
class CheckDeploioStatus # rubocop:disable Metrics/ClassLength
|
|
6
6
|
TIMEOUT_IN_SECONDS = 600
|
|
7
7
|
INTERVAL_IN_SECONDS = 5
|
|
8
8
|
LOG_DRAIN_SECONDS = 2
|
|
9
9
|
|
|
10
10
|
command "ci check-deploio-status" do |c|
|
|
11
11
|
c.syntax = "renuo ci check-deploio-status [options] <app-name>"
|
|
12
|
-
c.summary = "Checks the build status of the deployment."
|
|
12
|
+
c.summary = "Checks the build and release status of the deployment."
|
|
13
13
|
c.description = c.summary
|
|
14
14
|
c.option "-p", "--project <name>", String, "The name of the project"
|
|
15
15
|
c.option "-g", "--git-revision <hash>", String, "The Git revision"
|
|
@@ -17,9 +17,12 @@ module Renuo::Cli::Commands::Ci
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def run
|
|
20
|
-
puts "Checking build status for revision #{@revision}..."
|
|
20
|
+
puts "[RENUO-CLI] (1/2) Checking build status for revision #{@revision}..."
|
|
21
21
|
succeeded = with_streamed_build_logs { poll_build }
|
|
22
|
-
abort "build check timed out after #{TIMEOUT_IN_SECONDS} seconds" unless succeeded
|
|
22
|
+
abort "[RENUO-CLI] build check timed out after #{TIMEOUT_IN_SECONDS} seconds" unless succeeded
|
|
23
|
+
|
|
24
|
+
puts "[RENUO-CLI] (2/2) Checking release status for build #{build_name}..."
|
|
25
|
+
abort "[RENUO-CLI] release check timed out after #{TIMEOUT_IN_SECONDS} seconds" unless poll_release
|
|
23
26
|
end
|
|
24
27
|
|
|
25
28
|
private
|
|
@@ -29,20 +32,20 @@ module Renuo::Cli::Commands::Ci
|
|
|
29
32
|
@project = options.project
|
|
30
33
|
@revision = options.git_revision || ENV.fetch("SEMAPHORE_GIT_SHA", nil)
|
|
31
34
|
|
|
32
|
-
abort "missing app name" unless @app
|
|
33
|
-
abort "missing project name" unless @project
|
|
34
|
-
abort "this command must be run in Semaphore" unless @revision
|
|
35
|
+
abort "[RENUO-CLI] missing app name" unless @app
|
|
36
|
+
abort "[RENUO-CLI] missing project name" unless @project
|
|
37
|
+
abort "[RENUO-CLI] this command must be run in Semaphore" unless @revision
|
|
35
38
|
end
|
|
36
39
|
|
|
37
40
|
def system!(cmd)
|
|
38
41
|
abort unless system cmd
|
|
39
42
|
end
|
|
40
43
|
|
|
41
|
-
def
|
|
42
|
-
command = "nctl get
|
|
44
|
+
def fetch(type)
|
|
45
|
+
command = "nctl get #{type} -a #{@app} -p #{@project} -o yaml"
|
|
43
46
|
stdout, stderr, status = Open3.capture3 command
|
|
44
47
|
|
|
45
|
-
abort "error fetching
|
|
48
|
+
abort "[RENUO-CLI] error fetching #{type} information: #{stderr}" unless status.success?
|
|
46
49
|
Psych.load_stream stdout
|
|
47
50
|
end
|
|
48
51
|
|
|
@@ -67,7 +70,7 @@ module Renuo::Cli::Commands::Ci
|
|
|
67
70
|
end
|
|
68
71
|
|
|
69
72
|
def build
|
|
70
|
-
@build ||=
|
|
73
|
+
@build ||= fetch("builds").find do |build|
|
|
71
74
|
build.dig("spec", "forProvider", "sourceConfig", "git", "revision") == @revision
|
|
72
75
|
end
|
|
73
76
|
end
|
|
@@ -80,34 +83,63 @@ module Renuo::Cli::Commands::Ci
|
|
|
80
83
|
build.dig("status", "atProvider", "buildStatus")
|
|
81
84
|
end
|
|
82
85
|
|
|
83
|
-
def
|
|
86
|
+
def release
|
|
87
|
+
@release ||= fetch("releases").find do |release|
|
|
88
|
+
release.dig("spec", "forProvider", "build", "name") == build_name
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def release_name
|
|
93
|
+
release.dig("metadata", "name")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def release_status
|
|
97
|
+
release.dig("status", "atProvider", "releaseStatus")
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def succeeded?(type, name, status) # rubocop:disable Metrics/MethodLength
|
|
84
101
|
time = Time.current.iso8601.to_s
|
|
85
102
|
|
|
86
|
-
case
|
|
103
|
+
case status
|
|
87
104
|
when "available", "success"
|
|
88
|
-
puts "[RENUO-CLI] #{time}
|
|
105
|
+
puts "[RENUO-CLI] #{time} #{type} #{name} succeeded"
|
|
106
|
+
true
|
|
107
|
+
when "superseded"
|
|
108
|
+
puts "[RENUO-CLI] #{time} #{type} #{name} was superseded"
|
|
89
109
|
true
|
|
90
110
|
when "paused"
|
|
91
111
|
abort "[RENUO-CLI] #{time} app is paused"
|
|
92
112
|
when "error", "failed", "failure"
|
|
93
|
-
abort "[RENUO-CLI] #{time}
|
|
113
|
+
abort "[RENUO-CLI] #{time} #{type} #{name} failed"
|
|
94
114
|
else
|
|
95
|
-
puts "[RENUO-CLI] #{time}
|
|
115
|
+
puts "[RENUO-CLI] #{time} #{type} #{name} status is #{status}, waiting..."
|
|
96
116
|
false
|
|
97
117
|
end
|
|
98
118
|
end
|
|
99
119
|
|
|
100
|
-
def poll_build
|
|
120
|
+
def poll_build
|
|
121
|
+
poll do
|
|
122
|
+
next puts("[RENUO-CLI] no matching build found, waiting...") unless build
|
|
123
|
+
next true if succeeded?("build", build_name, build_status)
|
|
124
|
+
|
|
125
|
+
@build = nil
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def poll_release
|
|
130
|
+
poll do
|
|
131
|
+
next puts("[RENUO-CLI] no matching release found, waiting...") unless release
|
|
132
|
+
next true if succeeded?("release", release_name, release_status)
|
|
133
|
+
|
|
134
|
+
@release = nil
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def poll
|
|
101
139
|
elapsed = 0
|
|
102
140
|
|
|
103
141
|
while elapsed < TIMEOUT_IN_SECONDS
|
|
104
|
-
if
|
|
105
|
-
return true if build_succeeded?
|
|
106
|
-
|
|
107
|
-
@build = nil
|
|
108
|
-
else
|
|
109
|
-
puts "no matching build found, waiting..."
|
|
110
|
-
end
|
|
142
|
+
return true if yield
|
|
111
143
|
|
|
112
144
|
sleep INTERVAL_IN_SECONDS
|
|
113
145
|
elapsed += INTERVAL_IN_SECONDS
|
data/lib/renuo/cli/version.rb
CHANGED