xcskarel 0.14.0 → 0.15.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
  SHA1:
3
- metadata.gz: f69158b3f6c2220edec0c74f13e59c1dc1785ae5
4
- data.tar.gz: 2584d85e540450a8c65e52ea9f2987a23b93e8e3
3
+ metadata.gz: 574302ce3ad97095eca2691cdcc2c2b3e36a06cb
4
+ data.tar.gz: b842efd364ac80cbf6807395f253f747b3edc590
5
5
  SHA512:
6
- metadata.gz: 2ecc1b825c615c8be675b732a52639553bcdbd34d10200499d70de79dd78bdf7ef82c70d794f5f7b2125cdd7a07d96e09b838de32a6e8e8551aa5cdf73e39833
7
- data.tar.gz: 7136da6e5c5d838eb575d54aad6ffbcd060dce1265b0a87b76d9f4adba2e8b41354f306c7c544497c37237892381a1c6852770fb52bc3b1e98b3f8746d2e6b77
6
+ metadata.gz: 37a86b4a153c96bd64e574555a7795bcbe97743e22c93e0a458362f5a75d8924479cdf16522210138d6831d36404979e1ba347ab36bb9f24cc749a22a1a78062
7
+ data.tar.gz: a12a031ae0d52e57bc978358386fc0ca10b2725caa609ac88e801b3f3353df4973c49c24638e7112e582d76f5cef5c738230f97ca2f280b47a5a4a81ac747f4b
data/bin/xcskarel CHANGED
@@ -11,12 +11,16 @@ XCSKarel.set_no_log(true)
11
11
  class XCSKarelApplication
12
12
  include Commander::Methods
13
13
 
14
- def add_xcs_options(c)
14
+ def add_xcs_creds(c)
15
15
  c.option '--host Hostname', 'Xcode Server\'s hostname or IP address (default: localhost) (also can be specified as the environment variable XCSKAREL_HOST)'
16
16
  c.option '--user Username', 'Xcode Server username (also can be specified as the environment variable XCSKAREL_USER)'
17
17
  c.option '--pass Password', 'Xcode Server password (also can be specified as the environment variable XCSKAREL_PASS)'
18
18
  end
19
19
 
20
+ def add_xcs_options(c)
21
+ add_xcs_creds(c)
22
+ end
23
+
20
24
  def add_bot_options(c)
21
25
  c.option '--bot BOT_ID_OR_NAME', '(required) Bot identifier or name'
22
26
  end
@@ -26,11 +30,21 @@ class XCSKarelApplication
26
30
  c.option '--integration INTEGRATION_ID', 'Integration identifier'
27
31
  end
28
32
 
29
- def create_server_from_options(options)
33
+ def creds_from_options(options)
30
34
  host = options.host || ENV['XCSKAREL_HOST'] || "localhost"
31
- user = options.user || ENV['XCSKAREL_USER']
35
+ user = options.user || ENV['XCSKAREL_USER'] || ENV['USER']
32
36
  pass = options.pass || ENV['XCSKAREL_PASS']
33
- XCSKarel::Server.new(host, user, pass)
37
+ return host, user, pass
38
+ end
39
+
40
+ def create_server_from_options(options)
41
+ creds = creds_from_options(options)
42
+ XCSKarel::Server.new(*creds)
43
+ end
44
+
45
+ def create_connection_from_options(options)
46
+ creds = creds_from_options(options)
47
+ XCSKarel::Remote::Connection.new(*creds)
34
48
  end
35
49
 
36
50
  def run
@@ -184,6 +198,19 @@ class XCSKarelApplication
184
198
  end
185
199
  end
186
200
 
201
+ # Connecting to an Xcode Server machine
202
+
203
+ command :logs do |c|
204
+ c.syntax = 'xcskarel logs [options]'
205
+ c.description = 'Gets build and control logs'
206
+ c.example 'print logs', 'xcskarel logs --host 192.168.1.64 --user honzadvorsky'
207
+ add_xcs_creds(c)
208
+ c.action do |args, options|
209
+ connection = create_connection_from_options(options)
210
+ XCSKarel::Application.remote_logs(connection)
211
+ end
212
+ end
213
+
187
214
  # Managing a local Xcode Server
188
215
 
189
216
  command :'server start' do |c|
data/lib/xcskarel.rb CHANGED
@@ -7,3 +7,5 @@ require 'xcskarel/control'
7
7
  require 'xcskarel/config'
8
8
  require 'xcskarel/xcsfile'
9
9
  require 'xcskarel/application'
10
+ require 'xcskarel/shell'
11
+ require 'xcskarel/remote'
@@ -158,5 +158,21 @@ module XCSKarel
158
158
  return out
159
159
  end
160
160
 
161
+ def self.remote_logs(connection)
162
+ logs_path = "/Library/Developer/XcodeServer/Logs"
163
+ log_control = File.join(logs_path, "xcscontrol.log")
164
+ log_build = File.join(logs_path, "xcsbuildd.log")
165
+ lives = []
166
+ [log_control, log_build].each do |log|
167
+ puts "\n\n------- Printing output of #{log} at #{connection.host} -------\n".green
168
+ res = connection.execute("tail -n 20 #{log}")
169
+ puts res.yellow
170
+ live = "ssh #{connection.user}@#{connection.host} tail -f #{log}".green
171
+ lives << live
172
+ end
173
+ live_all = lives.map { |l| "\"#{l}\"" }.join("\n")
174
+ XCSKarel.log.info "To connect to the logs live run either:\n#{live_all}"
175
+ end
176
+
161
177
  end
162
178
  end
@@ -7,7 +7,7 @@ module XCSKarel
7
7
  return nil
8
8
  end
9
9
 
10
- status, output = self.execute('mdfind "kMDItemCFBundleIdentifier == \'com.apple.dt.Xcode\'" 2>/dev/null')
10
+ status, output = XCSKarel::Shell.execute('mdfind "kMDItemCFBundleIdentifier == \'com.apple.dt.Xcode\'" 2>/dev/null')
11
11
  raise "Failed to fetch Xcode paths: #{output}" if status != 0
12
12
  output.split("\n")
13
13
  end
@@ -19,49 +19,26 @@ module XCSKarel
19
19
 
20
20
  XCSKarel.log.info "Starting Xcode Server... This may take up to a minute.".yellow
21
21
 
22
- self.exec_sudo("sudo xcrun xcscontrol --initialize")
23
- self.exec_sudo("sudo xcrun xcscontrol --preflight")
22
+ XCSKarel::Shell.exec_sudo("sudo xcrun xcscontrol --initialize")
23
+ XCSKarel::Shell.exec_sudo("sudo xcrun xcscontrol --preflight")
24
24
 
25
25
  XCSKarel.log.info "Xcode Server started & running on localhost now!".green
26
26
  end
27
27
 
28
28
  def self.stop
29
- self.exec_sudo("sudo xcrun xcscontrol --shutdown")
29
+ XCSKarel::Shell.exec_sudo("sudo xcrun xcscontrol --shutdown")
30
30
  end
31
31
 
32
32
  def self.restart
33
- self.exec_sudo("sudo xcrun xcscontrol --restart")
33
+ XCSKarel::Shell.exec_sudo("sudo xcrun xcscontrol --restart")
34
34
  end
35
35
 
36
36
  def self.reset
37
- self.exec_sudo("sudo xcrun xcscontrol --reset")
37
+ XCSKarel::Shell.exec_sudo("sudo xcrun xcscontrol --reset")
38
38
  end
39
39
 
40
40
  def self.select(xcode)
41
- self.exec_sudo("sudo xcode-select -s #{xcode}")
42
- end
43
-
44
- private
45
-
46
- def self.exec_sudo(script)
47
- XCSKarel.log.warn "Running \'#{script}\', so we need root privileges."
48
- status, output = self.execute(script)
49
- raise "Failed to \'#{script}\':\n#{output}".red if status != 0
50
- XCSKarel.log.debug "Script \'#{script}\' output:\n#{output}"
51
- return status, output
52
- end
53
-
54
- def self.execute(script)
55
- exit_status = nil
56
- result = []
57
- IO.popen(script, err: [:child, :out]) do |io|
58
- io.each do |line|
59
- result << line.strip
60
- end
61
- io.close
62
- exit_status = $?.exitstatus
63
- end
64
- [exit_status, result.join("\n")]
41
+ XCSKarel::Shell.exec_sudo("sudo xcode-select -s #{xcode}")
65
42
  end
66
43
  end
67
44
  end
@@ -0,0 +1,48 @@
1
+ module XCSKarel
2
+ module Remote
3
+
4
+ require 'net/ssh'
5
+
6
+ # preferably set up SSH keys to be able to SSH into the host
7
+ # see http://serverfault.com/a/241593
8
+ class Connection
9
+
10
+ attr_reader :host
11
+ attr_reader :user
12
+ attr_reader :pass
13
+
14
+ @ssh
15
+
16
+ def initialize(host, user, pass)
17
+ @host = host
18
+ @user = user
19
+ @pass = pass
20
+
21
+ raise "Invalid host: \"#{host}\"".red if !host || host.empty?
22
+ raise "Invalid user: \"#{user}\"".red if !user || user.empty?
23
+
24
+ connect
25
+ end
26
+
27
+ def connect
28
+ raise "Already connected".red if @ssh
29
+ XCSKarel.log.info "Connecting to \"#{@host}\" as user \"#{@user}\" over SSH...".yellow
30
+ @ssh = Net::SSH.start(host, user, :password => pass)
31
+ end
32
+
33
+ def disconnect
34
+ @ssh.shutdown!
35
+ @ssh = nil
36
+ end
37
+
38
+ def execute(script)
39
+ raise "Not connected yet".red unless @ssh
40
+ XCSKarel.log.debug "SSH: executing \"#{script}\"".green
41
+ result = @ssh.exec!(script)
42
+ result.strip! if result
43
+ XCSKarel.log.debug "SSH: result\n \"#{result}\"".yellow
44
+ return result
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,25 @@
1
+ module XCSKarel
2
+ module Shell
3
+ def self.execute(script)
4
+ XCSKarel.log.debug "Executing script: \"#{script}\""
5
+ exit_status = nil
6
+ result = []
7
+ IO.popen(script, err: [:child, :out]) do |io|
8
+ io.each do |line|
9
+ result << line.strip
10
+ end
11
+ io.close
12
+ exit_status = $?.exitstatus
13
+ end
14
+ [exit_status, result.join("\n")]
15
+ end
16
+
17
+ def self.exec_sudo(script)
18
+ XCSKarel.log.warn "Running \'#{script}\', so we need root privileges."
19
+ status, output = self.execute(script)
20
+ raise "Failed to \'#{script}\':\n#{output}".red if status != 0
21
+ XCSKarel.log.debug "Script \'#{script}\' output:\n#{output}"
22
+ return status, output
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module XCSKarel
2
- VERSION = '0.14.0'
2
+ VERSION = '0.15.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcskarel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honza Dvorsky
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: github_changelog_generator
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  description: Tool for managing your Xcode Server & Bot configurations from the command
182
196
  line
183
197
  email: http://honzadvorsky.com
@@ -193,7 +207,9 @@ files:
193
207
  - lib/xcskarel/control.rb
194
208
  - lib/xcskarel/filter.rb
195
209
  - lib/xcskarel/log.rb
210
+ - lib/xcskarel/remote.rb
196
211
  - lib/xcskarel/server.rb
212
+ - lib/xcskarel/shell.rb
197
213
  - lib/xcskarel/version.rb
198
214
  - lib/xcskarel/xcsfile.rb
199
215
  - spec/application_spec.rb
@@ -219,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
235
  version: '0'
220
236
  requirements: []
221
237
  rubyforge_project:
222
- rubygems_version: 2.4.5
238
+ rubygems_version: 2.4.5.1
223
239
  signing_key:
224
240
  specification_version: 4
225
241
  summary: Manage your Xcode Server & Bots from the command line
@@ -227,4 +243,3 @@ test_files:
227
243
  - spec/application_spec.rb
228
244
  - spec/default_spec.rb
229
245
  - spec/filter_spec.rb
230
- has_rdoc: