diff --git a/XcodeServerSDK/Server Entities/BotConfiguration.swift b/XcodeServerSDK/Server Entities/BotConfiguration.swift index bccfe68..0a9de7c 100644 --- a/XcodeServerSDK/Server Entities/BotConfiguration.swift +++ b/XcodeServerSDK/Server Entities/BotConfiguration.swift @@ -59,24 +59,42 @@ public class BotConfiguration : XcodeServerEntity { } /** - Enum which describes identifiers of devices on which test should be run. - - - iOS_AllDevicesAndSimulators: iOS default - for build only - - iOS_AllDevices: All iOS devices - - iOS_AllSimulators: All iOS simulators - - iOS_SelectedDevicesAndSimulators: Manually selected devices/simulators - - Mac: Mac default (probably, crashes when saving in Xcode) - for build only - - AllCompatible: All Compatible (default) - for build only + Legacy property of what devices should be tested on. Now moved to `DeviceSpecification`, but + sending 0 or 7 still required. Sigh. */ public enum TestingDestinationIdentifier : Int { case iOSAndWatch = 0 case Mac = 7 } - public let builtFromClean: CleaningPolicy! + /** + Enum which describes whether code coverage data should be collected during tests. + + - Disabled: Turned off + - Enabled: Turned on, regardless of the preference in Scheme + - UseSchemeSettings: Respects the preference in Scheme + */ + public enum CodeCoveragePreference: Int { + case Disabled = 0 + case Enabled = 1 + case UseSchemeSetting = 2 + } + + /** + Enum describing build config preference. Xcode 7 API allows for overriding a config setup in the scheme for a specific one. UseSchemeSetting is the default. + */ + public enum BuildConfiguration { + case OverrideWithSpecific(String) + case UseSchemeSetting + } + + public let builtFromClean: CleaningPolicy + public let codeCoveragePreference: CodeCoveragePreference + public let buildConfiguration: BuildConfiguration public let analyze: Bool public let test: Bool public let archive: Bool + public let exportsProductFromArchive: Bool public let schemeName: String public let schedule: BotSchedule public let triggers: [Trigger] @@ -95,9 +113,17 @@ public class BotConfiguration : XcodeServerEntity { public required init(json: NSDictionary) { - self.builtFromClean = CleaningPolicy(rawValue: json.intForKey("builtFromClean")) + self.builtFromClean = CleaningPolicy(rawValue: json.intForKey("builtFromClean")) ?? .Never + self.codeCoveragePreference = CodeCoveragePreference(rawValue: json.optionalIntForKey("codeCoveragePreference") ?? 0) ?? .UseSchemeSetting + + if let buildConfigOverride = json.optionalStringForKey("buildConfiguration") { + self.buildConfiguration = BuildConfiguration.OverrideWithSpecific(buildConfigOverride) + } else { + self.buildConfiguration = .UseSchemeSetting + } self.analyze = json.boolForKey("performsAnalyzeAction") self.archive = json.boolForKey("performsArchiveAction") + self.exportsProductFromArchive = json.optionalBoolForKey("exportsProductFromArchive") ?? false self.test = json.boolForKey("performsTestAction") self.schemeName = json.stringForKey("schemeName") self.schedule = BotSchedule(json: json) @@ -120,9 +146,12 @@ public class BotConfiguration : XcodeServerEntity { public init( builtFromClean: CleaningPolicy, + codeCoveragePreference: CodeCoveragePreference = .UseSchemeSetting, + buildConfiguration: BuildConfiguration = .UseSchemeSetting, analyze: Bool, test: Bool, archive: Bool, + exportsProductFromArchive: Bool = true, schemeName: String, schedule: BotSchedule, triggers: [Trigger], @@ -130,9 +159,12 @@ public class BotConfiguration : XcodeServerEntity { sourceControlBlueprint: SourceControlBlueprint) { self.builtFromClean = builtFromClean + self.codeCoveragePreference = codeCoveragePreference + self.buildConfiguration = buildConfiguration self.analyze = analyze self.test = test self.archive = archive + self.exportsProductFromArchive = exportsProductFromArchive self.schemeName = schemeName self.schedule = schedule self.triggers = triggers @@ -151,14 +183,20 @@ public class BotConfiguration : XcodeServerEntity { //others dictionary["builtFromClean"] = self.builtFromClean.rawValue + dictionary["codeCoveragePreference"] = self.codeCoveragePreference.rawValue dictionary["performsTestAction"] = self.test dictionary["triggers"] = self.triggers.map { $0.dictionarify() } dictionary["performsAnalyzeAction"] = self.analyze dictionary["schemeName"] = self.schemeName dictionary["deviceSpecification"] = self.deviceSpecification.dictionarify() dictionary["performsArchiveAction"] = self.archive + dictionary["exportsProductFromArchive"] = self.exportsProductFromArchive dictionary["testingDestinationType"] = self.testingDestinationType.rawValue //TODO: figure out if we still need this in Xcode 7 + if case .OverrideWithSpecific(let buildConfig) = self.buildConfiguration { + dictionary["buildConfiguration"] = buildConfig + } + let botScheduleDict = self.schedule.dictionarify() //needs to be merged into the main bot config dict dictionary.addEntriesFromDictionary(botScheduleDict as [NSObject : AnyObject]) diff --git a/XcodeServerSDKTests/XcodeServerTests.swift b/XcodeServerSDKTests/XcodeServerTests.swift index 733acd8..6c3ba65 100644 --- a/XcodeServerSDKTests/XcodeServerTests.swift +++ b/XcodeServerSDKTests/XcodeServerTests.swift @@ -31,7 +31,17 @@ class XcodeServerTests: XCTestCase { XCTAssertNotNil(self.server) } - func DEV_testFetchAndRecordBot() { + func DEV_testLive_GetBots() { + + let exp = self.expectationWithDescription("Network") + self.server.getBots { (bots, error) in + print() + exp.fulfill() + } + self.waitForExpectationsWithTimeout(10, handler: nil) + } + + func DEV_testLive_FetchAndRecordBot() { let exp = self.expectationWithDescription("Network") let server = self.getRecordingXcodeServer("test_bot") @@ -51,7 +61,7 @@ class XcodeServerTests: XCTestCase { let privateKey = self.stringAtPath("~/.ssh/id_rsa") let publicKey = self.stringAtPath("~/.ssh/id_rsa.pub") - let blueprint = SourceControlBlueprint(branch: "hd/tested_devices_xcode_7", projectWCCIdentifier: "A36AEFA3F9FF1F738E92F0C497C14977DCE02B97", wCCName: "XcodeServerSDK", projectName: "XcodeServerSDK", projectURL: "git@github.com:czechboy0/XcodeServerSDK.git", projectPath: "XcodeServerSDK.xcworkspace", publicSSHKey: publicKey, privateSSHKey: privateKey, sshPassphrase: nil, certificateFingerprint: nil) + let blueprint = SourceControlBlueprint(branch: "swift-2", projectWCCIdentifier: "A36AEFA3F9FF1F738E92F0C497C14977DCE02B97", wCCName: "XcodeServerSDK", projectName: "XcodeServerSDK", projectURL: "git@github.com:czechboy0/XcodeServerSDK.git", projectPath: "XcodeServerSDK.xcworkspace", publicSSHKey: publicKey, privateSSHKey: privateKey, sshPassphrase: nil, certificateFingerprint: nil) let scriptBody = "cd XcodeServerSDK; /usr/local/bin/carthage update --no-build" let scriptTrigger = Trigger(phase: .Prebuild, kind: .RunScript, scriptBody: scriptBody, name: "Carthage", conditions: nil, emailConfiguration: nil)! @@ -61,7 +71,7 @@ class XcodeServerTests: XCTestCase { "a85553a5b26a7c1a4998f3b237004afd" ] let deviceSpec = DeviceSpecification.iOS(.SelectedDevicesAndSimulators, deviceIdentifiers: devices) - let config = BotConfiguration(builtFromClean: BotConfiguration.CleaningPolicy.Once_a_Day, analyze: true, test: true, archive: false, schemeName: "XcodeServerSDK - iOS", schedule: BotSchedule.commitBotSchedule(), triggers: [scriptTrigger], deviceSpecification: deviceSpec, sourceControlBlueprint: blueprint) + let config = BotConfiguration(builtFromClean: BotConfiguration.CleaningPolicy.Once_a_Day, codeCoveragePreference: .UseSchemeSetting, buildConfiguration: .UseSchemeSetting, analyze: true, test: true, archive: true, exportsProductFromArchive: true, schemeName: "XcodeServerSDK - iOS", schedule: BotSchedule.commitBotSchedule(), triggers: [scriptTrigger], deviceSpecification: deviceSpec, sourceControlBlueprint: blueprint) let bot = Bot(name: "TestBot From XcodeServerSDK", configuration: config)