xcode_server 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fa30cd8b451335c5ec15657c0e9e17b1d2423af
4
- data.tar.gz: be97133717127bd8da4b448bcc3aa05f33887ef7
3
+ metadata.gz: 9f074ce05fa24df7dc274627ead59782a92fabd6
4
+ data.tar.gz: ea3a9f00c206f051e607286b08e8e19d4fd9f96b
5
5
  SHA512:
6
- metadata.gz: ead2a1898d377fbc0856a3024664e896a91a7e550587f90dc887ddd23109ad001e26a705c668480e8b0bc3433b890395ebf28df1b3bbfa13228a8ced17529b45
7
- data.tar.gz: 580cd770f94fd089ef1c323f11a5937b2490f31fe20b5fd95dbd4b43483a3cc8d4967bcbc900244d3bfaf6936b19df2a1777a86a08c14e0c9ffb14d08ed70080
6
+ metadata.gz: 9feaa2b1ce689fdcff9d431f59283e418ac63dcc80f456e3517d47d14c4275b921f5c38c74ce9c0f12539e5298d35b2d85fb25dd08e05fd09ac025ad5978f219
7
+ data.tar.gz: 7947205d9b1279a79b3680aa6d572fba213a6d41010fa1e70192b8710a4c1379207ce3ffb5c76cad5d34d31667a9965f0a47b66f698c5996ae2bfc1c3775780f
@@ -2,6 +2,7 @@
2
2
 
3
3
  Ruby library for working with Xcode Server and Xcode Bots.
4
4
 
5
+ > **Note:** This library uses an undocumented API within Xcode Bots and is not yet fully featured.
5
6
 
6
7
  ## Installation
7
8
 
@@ -3,7 +3,15 @@ require 'xcode_server/server'
3
3
  require 'xcode_server/bot'
4
4
 
5
5
  module XcodeServer
6
- def self.new(host)
6
+ def self.new(host=@default_host)
7
7
  Server.new(host)
8
8
  end
9
+
10
+ def self.default_host=(host)
11
+ @default_host = host
12
+ end
13
+
14
+ def self.default_host
15
+ @default_host
16
+ end
9
17
  end
@@ -1,9 +1,15 @@
1
1
  require 'xcode_server/server/networking'
2
+ require 'SecureRandom'
2
3
 
3
4
  module XcodeServer
4
5
  class Server
5
6
  include Networking
6
7
 
8
+ module TestingSchedule
9
+ ON_COMMIT = 2
10
+ PERIODIC = 1 # TODO: Verify this value
11
+ end
12
+
7
13
  attr_reader :scheme
8
14
  attr_reader :host
9
15
 
@@ -12,13 +18,95 @@ module XcodeServer
12
18
  @scheme = scheme
13
19
  end
14
20
 
21
+ ##
22
+ # Retrieve a list of all bots on the server
15
23
  def bots
16
24
  get_json('bots')['results'].map { |result| Bot.new(self, result) }
17
25
  end
18
26
 
27
+ ##
28
+ # Delete an existing bot based on the bot id
29
+ # @param id [String] The bot's id as returned by Bot#id
19
30
  def destroy_bot(id, rev = nil)
20
31
  rev ||= get_json("bots/#{id}")['_rev']
21
32
  delete("bots/#{id}/#{rev}").code.to_i == 204
22
33
  end
34
+
35
+ ##
36
+ # Create a new bot on the server
37
+ #
38
+ # @param bot_name [String] The human name of the bot (e.g. "venmo/venmo-iphone#99 (feature/ci)")
39
+ # @param branch_name [String] The name of the branch to integrate
40
+ # @param performs_analyze_action [Boolean] Whether or not to analyze during integration
41
+ # @param performs_archive_action [Boolean] Whether or not to archive during integration
42
+ # @param performs_test_action [Boolean] Whether or not to test during integration
43
+ # @param project_path [String] The path to the project or workspace within the working directory
44
+ # @param repo_url [String] The git URL for a repo containing the project to integrate
45
+ # @param scheme_name [String] The name of the Xcode scheme to integrate
46
+ # @param testing_schedule [Integer] See TestingSchedule
47
+ # @param working_copy_path [String] The name of the working copy directory, usually the name of the repo (e.g. venmo/venmo-iphone)
48
+ def create_bot(bot_name:,
49
+ branch_name: "master",
50
+ performs_analyze_action: true,
51
+ performs_archive_action: false,
52
+ performs_test_action: true,
53
+ project_path:,
54
+ repo_url:,
55
+ scheme_name:,
56
+ testing_schedule: TestingSchedule::ON_COMMIT,
57
+ working_copy_path:)
58
+ repo_identifier = SecureRandom.uuid
59
+ res = post('bots',
60
+ group: {
61
+ name: SecureRandom.uuid
62
+ },
63
+ configuration: {
64
+ builtFromClean: 1, # Always
65
+ periodicScheduleInterval: 0, # Run manually
66
+ performs_test_action: performs_test_action,
67
+ performs_analyze_action: performs_analyze_action,
68
+ scheme_name: scheme_name,
69
+ sourceControlBlueprint: {
70
+ DVTSourceControlWorkspaceBlueprintLocationsKey: {
71
+ repo_identifier => {
72
+ DVTSourceControlBranchIdentifierKey: branch_name,
73
+ DVTSourceControlBranchOptionsKey: 156, # Mystery meat
74
+ DVTSourceControlWorkspaceBlueprintLocationTypeKey: "DVTSourceControlBranch" # "Pull a git branch"
75
+ }
76
+ },
77
+ DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey: repo_identifier,
78
+ DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationStrategiesKey: {
79
+ repo_identifier => {
80
+ DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey: "DVTSourceControlAuthenticationStrategy"
81
+ }
82
+ },
83
+ DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey: {
84
+ repo_identifier => 0
85
+ },
86
+ DVTSourceControlWorkspaceBlueprintIdentifierKey: repo_identifier,
87
+ DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey: {
88
+ repo_identifier => working_copy_path
89
+ },
90
+ DVTSourceControlWorkspaceBlueprintNameKey: project_path,
91
+ DVTSourceControlWorkspaceBlueprintVersion: 203, # Mystery meat
92
+ DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey: project_path,
93
+ DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey: [{
94
+ DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey: project_url,
95
+ DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey: "com.apple.dt.Xcode.sourcecontrol.Git",
96
+ DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey: repo_identifier
97
+ }]
98
+ },
99
+ hourOfIntegration: 0,
100
+ scheduleType: testing_schedule,
101
+ performs_archive_action: performs_archive_action,
102
+ testingDestinationType: 0 # "iOS All Devices and All Simulators"
103
+ },
104
+ requiresUpgrade: false, # Mystery meat
105
+ name: bot_name,
106
+ type: 1 # Mystery meat
107
+ )
108
+
109
+ Bot.new(self, JSON.load(res.body))
110
+ end
23
111
  end
24
112
  end
@@ -1,26 +1,36 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
+ require 'openssl'
3
4
 
4
5
  module XcodeServer
5
6
  class Server
6
7
  module Networking
7
8
 
8
- def get(path)
9
- path = "/xcode/api/#{path}"
10
- http.request(Net::HTTP::Get.new(path))
9
+ def get(endpoint)
10
+ http.request(Net::HTTP::Get.new(path_to(endpoint)))
11
11
  end
12
12
 
13
- def get_json(path)
14
- JSON.load(get(path).body)
13
+ def post(endpoint, params)
14
+ puts params.to_json
15
+ req = Net::HTTP::Post.new(path_to(endpoint))
16
+ req['Content-Type'] = 'application/json'
17
+ http.request(req, params.to_json)
15
18
  end
16
19
 
17
- def delete(path)
18
- path = "/xcode/api/#{path}"
19
- http.request(Net::HTTP::Delete.new(path))
20
+ def get_json(endpoint)
21
+ JSON.load(get(endpoint).body)
22
+ end
23
+
24
+ def delete(endpoint)
25
+ http.request(Net::HTTP::Delete.new(path_to(endpoint)))
20
26
  end
21
27
 
22
28
  private
23
29
 
30
+ def path_to(endpoint)
31
+ "/xcode/api/#{endpoint}"
32
+ end
33
+
24
34
  def http
25
35
  @_http ||= begin
26
36
  http = Net::HTTP.new(host, 443)
@@ -1,3 +1,3 @@
1
1
  module XcodeServer
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcode_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Soffes