Skip to content

Commit

Permalink
Merge pull request #50 from czechboy0/hd/support_for_missing_xcode7_keys
Browse files Browse the repository at this point in the history
Added support for the last missing keys
  • Loading branch information
Honza Dvorsky committed Jun 28, 2015
2 parents 5be5118 + 0e40c70 commit 2320567
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 13 deletions.
58 changes: 48 additions & 10 deletions XcodeServerSDK/Server Entities/BotConfiguration.swift
Expand Up @@ -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]
Expand All @@ -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)
Expand All @@ -120,19 +146,25 @@ 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],
deviceSpecification: DeviceSpecification,
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
Expand All @@ -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])

Expand Down
16 changes: 13 additions & 3 deletions XcodeServerSDKTests/XcodeServerTests.swift
Expand Up @@ -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")
Expand All @@ -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)!
Expand All @@ -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)

Expand Down

0 comments on commit 2320567

Please sign in to comment.