Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 2! #122

Merged
merged 84 commits into from
Sep 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
95d859e
Merge pull request #1 from czechboy0/master
Higgcz Jun 16, 2015
15fb494
New App Icon and small fixes.
Higgcz Jun 16, 2015
2fc7d8c
Make Bulda slightly more adorable by rounding eyes and making smile.
Higgcz Jun 17, 2015
d35886c
WIP on migrating to Swift 2, as per #76
Jun 28, 2015
f41a136
swift2ification in progress
Jun 28, 2015
30b0004
wippp
Jun 28, 2015
20d387a
this bad boy now builds. ok, let's make it work now. but first, sleep.
Jun 28, 2015
3568fff
added changelog
Jun 30, 2015
b0f1973
starting to add the parsing of device type from a scheme to infer the…
Jun 30, 2015
5dce690
xcode 7 workspace parsing fixes, integrating the detection of scheme …
Jul 2, 2015
aa76daa
wip on fixing device choosing in build template
Jul 2, 2015
252f5b4
hacking towards working with xcode 7. tested and works for OS X apps …
Jul 2, 2015
b037a1b
got the devices working... ok xcode 7 alpha ready.
Jul 2, 2015
cc512b6
Merge pull request #78 from czechboy0/hd/device_type_from_scheme
Jul 2, 2015
1b0e664
disabled test
Jul 2, 2015
886ab1a
changelog
Jul 2, 2015
7dd0f6e
new cpods
Jul 3, 2015
22f6e3f
Merge pull request #74 from Higgcz/master
Jul 13, 2015
83f510f
Merge pull request #86 from czechboy0/master
Jul 13, 2015
8c219db
merge conflicts
Jul 13, 2015
52dff2b
changelog
Jul 13, 2015
85f4ef4
Merge pull request #88 from czechboy0/master
Jul 13, 2015
a540380
changelog
Jul 13, 2015
e579ea4
Fixed generic array parameter name changed in Xcode 7 beta 3
Jul 15, 2015
a8a5a49
Merge pull request #90 from czechboy0/hd/xcode7_beta3_fixes
Jul 15, 2015
0e1890c
changelog
Jul 15, 2015
9c956c6
adding code coverage and test number changes to comments
Jul 15, 2015
acccd55
new comment format
Jul 15, 2015
eeea1e0
backwards compatible parsing of code coverage...
Jul 15, 2015
bf12641
Merge pull request #91 from czechboy0/hd/code_coverage_comments
Jul 15, 2015
c93bbbf
changelog
Jul 15, 2015
4672b05
swift and xcode compatibility flags
Jul 17, 2015
3dc0429
Merge pull request #95 from czechboy0/master
Jul 17, 2015
3aa00ac
Fixes #85, now testing device IDs are cleaned when the scheme/testing…
Jul 17, 2015
e56bd68
Merge pull request #97 from czechboy0/hd/clean_stale_testing_devices
Jul 17, 2015
397b974
renamed LocalSource -> Project
Jul 17, 2015
4c84fd2
refactoring LocalSource -> Project, added projectName to BuildTemplate
Jul 17, 2015
bf76ac1
filtering added, also fixed the annoying Build Template name retentio…
Jul 17, 2015
2d2df64
Merge pull request #98 from czechboy0/hd/build_templates_by_project
Jul 17, 2015
11ea16f
adding BuildaKit to host files for buildasaur's logic (but not the UI)
Jul 18, 2015
c9a00ec
moving things around
Jul 18, 2015
2cf4dd6
finally split out BuilaUtils into a separate project. now let's migra…
Jul 18, 2015
ae1ed7a
removed schemes
Jul 18, 2015
c92b882
BuildaKit arrives!
Jul 18, 2015
6ae6e83
made required things public
Jul 18, 2015
88f7a11
fixed tests as well
Jul 18, 2015
bb6c51f
Merge pull request #101 from czechboy0/hd/buildakit
Jul 18, 2015
9ae82d1
moved logging to BuildaKit
Jul 18, 2015
a277382
Merge pull request #102 from czechboy0/hd/logging_to_buildakit
Jul 18, 2015
6c2face
changelog
Jul 18, 2015
e1cd331
Merge pull request #103 from czechboy0/master
Jul 19, 2015
c8b01ca
Singular/Plural noun fixes and updated screenshot
Jul 19, 2015
590c7b1
master has an old image
Jul 19, 2015
71d5488
Merge pull request #104 from czechboy0/hd/plural_fixes
Jul 19, 2015
f632680
changelog
Jul 19, 2015
f1ba5c5
xcode 7 beta 4 fixes
Jul 22, 2015
31a101e
Merge pull request #108 from czechboy0/hd/xcode7b4_fixes
Jul 22, 2015
4208212
changelog
Jul 22, 2015
e968cb0
adopting new XcodeServerSDK with a fix for postbuild triggers
Jul 25, 2015
0bc0c97
xcode project parser fixes for cases with empty scheme folders
Jul 26, 2015
f974871
fastlane WIP
Jul 26, 2015
15b7274
Update README.md
Aug 4, 2015
2078023
upping dependency versions, fixes for Xcode 7 Beta 5.
Aug 10, 2015
69c6694
changelog
Aug 10, 2015
57aefa9
still prerelease
Aug 10, 2015
823f3b0
don't update
Aug 10, 2015
2f45e52
changelog
Aug 10, 2015
165b129
Update README.md
Aug 10, 2015
97d978c
Remove "Buildasaur:" from GitHub build status
joelekstrom Aug 21, 2015
0bffd1b
Merge pull request #115 from accatyyc/gladiolus
Aug 21, 2015
0853dc2
Update README.md
Aug 23, 2015
ac43033
fixes
Aug 25, 2015
3915355
Merge pull request #116 from czechboy0/hd/xcode7_beta6_fixes
Aug 25, 2015
877156d
fixes
Aug 25, 2015
069a30f
changelog
Aug 25, 2015
065b50b
Update README.md
Aug 25, 2015
60a2cc9
Update README.md
Aug 25, 2015
96fec3d
changelog
Aug 25, 2015
ab9149c
Merge branch 'gladiolus' of github.com:czechboy0/Buildasaur into glad…
Aug 25, 2015
5049ba9
improved fastfile - waiting for my changes in fastlane to be released…
Sep 1, 2015
0bf399f
don't codesign in tests & debug
Sep 3, 2015
55c1b91
Update README.md
Sep 3, 2015
2088165
Update README.md
Sep 10, 2015
79d607a
Update README.md
Sep 10, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions BuildaGitServer/GitHubEndpoints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import Foundation
import XcodeServerSDK
import BuildaUtils

public class GitHubEndpoints {

Expand Down Expand Up @@ -137,22 +137,19 @@ public class GitHubEndpoints {
assert(params?["repo"] != nil, "A repo must be specified")
let repo = self.endpointURL(.Repos, params: params)
return "\(repo)/merges"

default:
assertionFailure("Unsupported endpoint")
}
}


public func createRequest(method:HTTP.Method, endpoint:Endpoint, params: [String : String]? = nil, query: [String : String]? = nil, body:NSDictionary? = nil) -> NSMutableURLRequest? {
public func createRequest(method:HTTP.Method, endpoint:Endpoint, params: [String : String]? = nil, query: [String : String]? = nil, body:NSDictionary? = nil) throws -> NSMutableURLRequest {

let endpointURL = self.endpointURL(endpoint, params: params)
let queryString = HTTP.stringForQuery(query)
let wholePath = "\(self.baseURL)\(endpointURL)\(queryString)"

let url = NSURL(string: wholePath)!

var request = NSMutableURLRequest(URL: url)
let request = NSMutableURLRequest(URL: url)

request.HTTPMethod = method.rawValue
if let token = self.token {
Expand All @@ -161,14 +158,7 @@ public class GitHubEndpoints {

if let body = body {

var error: NSError?
let data = NSJSONSerialization.dataWithJSONObject(body, options: .allZeros, error: &error)
if let error = error {
//parsing error
Log.error("Parsing error \(error.description)")
return nil
}

let data = try NSJSONSerialization.dataWithJSONObject(body, options: NSJSONWritingOptions())
request.HTTPBody = data
}

Expand Down
1 change: 0 additions & 1 deletion BuildaGitServer/GitHubRateLimit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public struct GitHubRateLimit {
let maxRateOfConsumptionPretty = maxRateOfConsumption.clipTo(2)

//how much faster we can be consuming requests before we hit the maximum rate of 5000/hour
let extraRateOfConsumption = (maxRateOfConsumption - rateOfConsumption).clipTo(2)
let usedRatePercent = (100.0 * rateOfConsumption / maxRateOfConsumption).clipTo(2)

let report = "count: \(consumed)/\(self.limit), renews in \(Int(remainingTime)) seconds, rate: \(rateOfConsumptionPretty)/\(maxRateOfConsumptionPretty), using \(usedRatePercent)% of the allowed request rate."
Expand Down
16 changes: 8 additions & 8 deletions BuildaGitServer/GitHubServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import Foundation
import XcodeServerSDK
import BuildaUtils

public class GitHubServer : GitServer {

Expand Down Expand Up @@ -180,16 +180,16 @@ extension GitHubServer {

//merge the two params
if let params = params {
for (let key, let value) in params {
for (key, value) in params {
allParams[key] = value
}
}

if let request = self.endpoints.createRequest(method, endpoint: endpoint, params: allParams, query: query, body: body) {

do {
let request = try self.endpoints.createRequest(method, endpoint: endpoint, params: allParams, query: query, body: body)
self.sendRequestWithPossiblePagination(request, accumulatedResponseBody: NSArray(), completion: completion)
} else {
completion(response: nil, body: nil, error: Error.withInfo("Couldn't create Request"))
} catch {
completion(response: nil, body: nil, error: Error.withInfo("Couldn't create Request, error \(error)"))
}
}

Expand Down Expand Up @@ -373,7 +373,7 @@ extension GitHubServer {
if let body = body as? NSArray {
let statuses: [Status] = GitHubArray(body)
//sort them by creation date
let mostRecentStatus = statuses.sorted({ return $0.created! > $1.created! }).first
let mostRecentStatus = statuses.sort({ return $0.created! > $1.created! }).first
completion(status: mostRecentStatus, error: nil)
} else {
completion(status: nil, error: Error.withInfo("Wrong body \(body)"))
Expand Down Expand Up @@ -500,7 +500,7 @@ extension GitHubServer {
* POST merge a head branch/commit into a base branch.
* has a couple of different responses, a bit tricky
*/
public func mergeHeadIntoBase(#head: String, base: String, commitMessage: String, repo: String, completion: (result: GitHubEndpoints.MergeResult?, error: NSError?) -> ()) {
public func mergeHeadIntoBase(head head: String, base: String, commitMessage: String, repo: String, completion: (result: GitHubEndpoints.MergeResult?, error: NSError?) -> ()) {

let params = [
"repo": repo
Expand Down
2 changes: 1 addition & 1 deletion BuildaGitServer/GitHubServerExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import Foundation
import XcodeServerSDK
import BuildaUtils

//functions to make working with github easier - utility functions
public extension GitHubServer {
Expand Down
2 changes: 1 addition & 1 deletion BuildaGitServer/GitServerPublic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import Foundation
import XcodeServerSDK
import BuildaUtils

public class GitServer : HTTPServer {

Expand Down
2 changes: 1 addition & 1 deletion BuildaGitServer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.honzadvorsky.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
2 changes: 1 addition & 1 deletion BuildaGitServer/Status.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class Status : GitHubEntity, Equatable {

public override func dictionarify() -> NSDictionary {

var dictionary = NSMutableDictionary()
let dictionary = NSMutableDictionary()

dictionary["state"] = self.state.rawValue
dictionary.optionallyAddValueForKey(self.description, key: "description")
Expand Down
19 changes: 7 additions & 12 deletions BuildaGitServerTests/GitHubServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Cocoa
import XCTest
import BuildaGitServer
import BuildaUtils
import XcodeServerSDK

class GitHubSourceTests: XCTestCase {

Expand All @@ -33,17 +32,13 @@ class GitHubSourceTests: XCTestCase {

let expect = expectationWithDescription("Waiting for url request")

if let request = self.github.endpoints.createRequest(method, endpoint: endpoint, params: params) {

self.github.http.sendRequest(request, completion: { (response, body, error) -> () in

completion(body: body, error: error)
expect.fulfill()
})
let request = try! self.github.endpoints.createRequest(method, endpoint: endpoint, params: params)

self.github.http.sendRequest(request, completion: { (response, body, error) -> () in

} else {
assertionFailure("Couldn't create request")
}
completion(body: body, error: error)
expect.fulfill()
})

waitForExpectationsWithTimeout(10, handler: nil)
}
Expand Down Expand Up @@ -124,7 +119,7 @@ class GitHubSourceTests: XCTestCase {

func testCommitParsing() {

let dictionary = [
let dictionary: NSDictionary = [
"sha": "08182438ed2ef3b34bd97db85f39deb60e2dcd7d",
"url": "https://api.github.com/repos/czechboy0/Buildasaur/commits/08182438ed2ef3b34bd97db85f39deb60e2dcd7d"
]
Expand Down
2 changes: 1 addition & 1 deletion BuildaGitServerTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.honzadvorsky.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
84 changes: 53 additions & 31 deletions Buildasaur/BuildTemplate.swift → BuildaKit/BuildTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,65 @@ import BuildaUtils
import XcodeServerSDK

private let kKeyUniqueId = "id"
private let kKeyProjectName = "project_name"
private let kKeyName = "name"
private let kKeyScheme = "scheme"
private let kKeySchedule = "schedule"
private let kKeyCleaningPolicy = "cleaning_policy"
private let kKeyTriggers = "triggers"
private let kKeyTestingDevices = "testing_devices"
private let kKeyDestinationType = "destination_type"
private let kKeyDeviceFilter = "device_filter"
private let kKeyPlatformType = "platform_type"
private let kKeyShouldAnalyze = "should_analyze"
private let kKeyShouldTest = "should_test"
private let kKeyShouldArchive = "should_archive"

class BuildTemplate: JSONSerializable {
public class BuildTemplate: JSONSerializable {

public let uniqueId: String //unique id of this build template, so that we can rename them easily

public var projectName: String?
public var name: String?
public var scheme: String?
public var schedule: BotSchedule? //will be ignored for Synced bots, only useful for Manual creation. default: Manual
public var cleaningPolicy: BotConfiguration.CleaningPolicy
public var triggers: [Trigger]
public var shouldAnalyze: Bool?
public var shouldTest: Bool?
public var shouldArchive: Bool?
public var testingDeviceIds: [String]
public var deviceFilter: DeviceFilter.FilterType
public var platformType: DevicePlatform.PlatformType?

var uniqueId: String //unique id of this build template, so that we can rename them easily
var name: String?
var scheme: String?
var schedule: BotSchedule? //will be ignored for Synced bots, only useful for Manual creation. default: Manual
var cleaningPolicy: BotConfiguration.CleaningPolicy
var triggers: [Trigger]
var shouldAnalyze: Bool?
var shouldTest: Bool?
var shouldArchive: Bool?
var destinationType: BotConfiguration.TestingDestinationIdentifier
var testingDeviceIds: [String]

func validate() -> Bool {

if count(self.uniqueId) == 0 { return false }
if self.uniqueId.isEmpty { return false }
if self.name == nil { return false }
if self.scheme == nil { return false }
//TODO: add all the other required values! this will be called on saving from the UI to make sure we have all the required fields.
return true
}

init() {
public init(projectName: String) {
self.uniqueId = NSUUID().UUIDString
self.name = "New Build Template Name"
self.projectName = projectName
self.name = "New Build Template"
self.scheme = nil
self.schedule = BotSchedule.manualBotSchedule()
self.cleaningPolicy = BotConfiguration.CleaningPolicy.Never
self.triggers = []
self.destinationType = BotConfiguration.TestingDestinationIdentifier.AllCompatible
self.shouldAnalyze = false
self.shouldTest = false
self.shouldArchive = false
self.testingDeviceIds = []
self.deviceFilter = .AllAvailableDevicesAndSimulators
self.platformType = nil
}

required init?(json: NSDictionary) {
public required init?(json: NSDictionary) {

self.uniqueId = json.optionalStringForKey(kKeyUniqueId) ?? ""
self.projectName = json.optionalStringForKey(kKeyProjectName)
self.name = json.optionalStringForKey(kKeyName)
self.scheme = json.optionalStringForKey(kKeyScheme)
if let scheduleDict = json.optionalDictionaryForKey(kKeySchedule) {
Expand All @@ -81,37 +89,51 @@ class BuildTemplate: JSONSerializable {
} else {
self.triggers = []
}
if
let destinationType = json.optionalIntForKey(kKeyDestinationType),
let destination = BotConfiguration.TestingDestinationIdentifier(rawValue: destinationType){
self.destinationType = destination
} else {
self.destinationType = .AllCompatible
}

self.shouldAnalyze = json.optionalBoolForKey(kKeyShouldAnalyze)
self.shouldTest = json.optionalBoolForKey(kKeyShouldTest)
self.shouldArchive = json.optionalBoolForKey(kKeyShouldArchive)

self.testingDeviceIds = json.optionalArrayForKey(kKeyTestingDevices) as? [String] ?? []


if
let deviceFilterInt = json.optionalIntForKey(kKeyDeviceFilter),
let deviceFilter = DeviceFilter.FilterType(rawValue: deviceFilterInt)
{
self.deviceFilter = deviceFilter
} else {
self.deviceFilter = .AllAvailableDevicesAndSimulators
}

if
let platformTypeString = json.optionalStringForKey(kKeyPlatformType),
let platformType = DevicePlatform.PlatformType(rawValue: platformTypeString) {
self.platformType = platformType
} else {
self.platformType = nil
}

if !self.validate() {
return nil
}
}

func jsonify() -> NSDictionary {
var dict = NSMutableDictionary()
public func jsonify() -> NSDictionary {
let dict = NSMutableDictionary()

dict[kKeyUniqueId] = self.uniqueId
dict[kKeyTriggers] = self.triggers.map({ $0.dictionarify() })
dict[kKeyTestingDevices] = self.testingDeviceIds
dict[kKeyDeviceFilter] = self.deviceFilter.rawValue
dict[kKeyTestingDevices] = self.testingDeviceIds ?? []
dict[kKeyCleaningPolicy] = self.cleaningPolicy.rawValue
dict[kKeyDestinationType] = self.destinationType.rawValue
dict.optionallyAddValueForKey(self.projectName, key: kKeyProjectName)
dict.optionallyAddValueForKey(self.name, key: kKeyName)
dict.optionallyAddValueForKey(self.scheme, key: kKeyScheme)
dict.optionallyAddValueForKey(self.schedule?.dictionarify(), key: kKeySchedule)
dict.optionallyAddValueForKey(self.shouldAnalyze, key: kKeyShouldAnalyze)
dict.optionallyAddValueForKey(self.shouldTest, key: kKeyShouldTest)
dict.optionallyAddValueForKey(self.shouldArchive, key: kKeyShouldArchive)
dict.optionallyAddValueForKey(self.platformType?.rawValue, key: kKeyPlatformType)

return dict
}
Expand Down
19 changes: 19 additions & 0 deletions BuildaKit/BuildaKit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// BuildaKit.h
// BuildaKit
//
// Created by Honza Dvorsky on 18/07/2015.
// Copyright © 2015 Honza Dvorsky. All rights reserved.
//

#import <Cocoa/Cocoa.h>

//! Project version number for BuildaKit.
FOUNDATION_EXPORT double BuildaKitVersionNumber;

//! Project version string for BuildaKit.
FOUNDATION_EXPORT const unsigned char BuildaKitVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <BuildaKit/PublicHeader.h>


Loading