Skip to content

Commit

Permalink
Make Octokit build with Linux (#69)
Browse files Browse the repository at this point in the history
* Remove not used Color extension

* Duplicate Models to compile also with Linux

* Added allTests property to make the tests executable also on Linux

* Updated .travis.yml to use also Linux

* Renamed travis scripts

* Use the correct Script folder name

* Updated permissions for travis scripts

* Use swift version 4.2 on Linux

* Added LinuxMain.swift

* Try to make swift find LinuxMain file

* Update LinuxMain permissions

* Reverse 21892d6

* Updated macos install script

* install bundler on macos

* Use SPM default test location to make it find LinuxMain.swift

* Fixed defaultTestSuite compilation issue for macOS and tvOS

* Set correct path to the Tests info.plist

* Don't use Bundle(for:) on Linux

* Not use the Bundle at all on Linux

* Make tests compile

* Remove all the other Bundle(for:) calls on Linux

* Fix: Use resourceName

* Find files also on Fixtures folder

* Remove objc compatibility

* Remove spaces from User.swift file
  • Loading branch information
f-meloni authored and pietbrauer committed Nov 12, 2018
1 parent dd7b487 commit b63f2ec
Show file tree
Hide file tree
Showing 40 changed files with 432 additions and 191 deletions.
22 changes: 13 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: objective-c
language: generic
osx_image: xcode9.2
sudo: false
env:
Expand All @@ -8,20 +8,24 @@ env:
- FASTLANE_LANE=ci_commit
matrix:
include:
- osx_image: xcode9.2
- os: osx
env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default
- osx_image: xcode9.2
- os: osx
env: FASTLANE_ENV=ios93
- osx_image: xcode9.2
- os: osx
env: FASTLANE_ENV=tvos92
- osx_image: xcode9.2
- os: osx
env: FASTLANE_ENV=osx
- os: linux
sudo: required
dist: trusty
env: SWIFT_VERSION=4.2
before_install:
- make install
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./Script/travis-install-linux; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./Script/travis-install-macos; fi
script:
- set -o pipefail
- bundle exec fastlane $FASTLANE_LANE configuration:Debug --env $FASTLANE_ENV
- bundle exec fastlane $FASTLANE_LANE configuration:Release --env $FASTLANE_ENV
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./Script/travis-script-linux; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./Script/travis-script-macos; fi
after_success:
- if [ "$FASTLANE_LANE" == "code_coverage" ]; then
make post_coverage;
Expand Down
15 changes: 8 additions & 7 deletions OctoKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@
234F4BAD1BDDE31A00A58EF7 /* Info.plist */,
BF8C76EB002802C14A08F63E /* PullRequestTests.swift */,
);
path = OctoKitTests;
name = OctoKitTests;
path = Tests/OctoKitTests;
sourceTree = "<group>";
};
234F4BD71BDDE40400A58EF7 /* Fixtures */ = {
Expand Down Expand Up @@ -909,7 +910,7 @@
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = OctoKitTests/Info.plist;
INFOPLIST_FILE = Tests/OctoKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -930,7 +931,7 @@
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = OctoKitTests/Info.plist;
INFOPLIST_FILE = Tests/OctoKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
PRODUCT_BUNDLE_IDENTIFIER = com.nerdishbynature.OctoKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -1064,7 +1065,7 @@
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = OctoKitTests/Info.plist;
INFOPLIST_FILE = Tests/OctoKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1085,7 +1086,7 @@
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = OctoKitTests/Info.plist;
INFOPLIST_FILE = Tests/OctoKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -1164,7 +1165,7 @@
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = OctoKitTests/Info.plist;
INFOPLIST_FILE = Tests/OctoKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)";
PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1185,7 +1186,7 @@
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = OctoKitTests/Info.plist;
INFOPLIST_FILE = Tests/OctoKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(FRAMEWORK_SEARCH_PATHS)";
PRODUCT_BUNDLE_IDENTIFIER = "com.nerdishbynature.OctoKit-MacTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
36 changes: 18 additions & 18 deletions OctoKit/Issue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ public enum Openness: String, Codable {
case All = "all"
}

@objc open class Issue: NSObject, Codable {
@objc open private(set) var id: Int = -1
@objc open var url: URL?
@objc open var repositoryURL: URL?
@objc open var labelsURL: URL?
@objc open var commentsURL: URL?
@objc open var eventsURL: URL?
@objc open var htmlURL: URL?
open class Issue: Codable {
open private(set) var id: Int = -1
open var url: URL?
open var repositoryURL: URL?
open var labelsURL: URL?
open var commentsURL: URL?
open var eventsURL: URL?
open var htmlURL: URL?
open var number: Int?
open var state: Openness?
@objc open var title: String?
@objc open var body: String?
@objc open var user: User?
@objc open var labels: [Label]?
@objc open var assignee: User?
@objc open var milestone: Milestone?
open var title: String?
open var body: String?
open var user: User?
open var labels: [Label]?
open var assignee: User?
open var milestone: Milestone?
open var locked: Bool?
open var comments: Int?
@objc open var closedAt: Date?
@objc open var createdAt: Date?
@objc open var updatedAt: Date?
@objc open var closedBy: User?
open var closedAt: Date?
open var createdAt: Date?
open var updatedAt: Date?
open var closedBy: User?

enum CodingKeys: String, CodingKey {
case id
Expand Down
32 changes: 5 additions & 27 deletions OctoKit/Label.swift
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
#if os(OSX)
import Cocoa
typealias Color = NSColor
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit
typealias Color = UIColor
#endif
import Foundation

extension Color {
@objc convenience init?(hexTriplet hex: String) {
var hexChars = Substring(hex)
let red = Int(String(hex.prefix(2)), radix: 16)
hexChars = hexChars.dropFirst(2)
let green = Int(String(hexChars.prefix(2)), radix: 16)
hexChars = hexChars.dropFirst(2)
let blue = Int(String(hexChars), radix: 16)
if let red = red, let green = green, let blue = blue {
self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1)
} else {
return nil
}
}
}

@objc open class Label: NSObject, Codable {
@objc open var url: URL?
@objc open var name: String?
@objc open var color: String?
open class Label: Codable {
open var url: URL?
open var name: String?
open var color: String?
}
24 changes: 12 additions & 12 deletions OctoKit/Milestone.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import Foundation

@objc open class Milestone: NSObject, Codable {
@objc open var url: URL?
@objc open var htmlURL: URL?
@objc open var labelsURL: URL?
@objc open private(set) var id: Int = -1
open class Milestone: Codable {
open var url: URL?
open var htmlURL: URL?
open var labelsURL: URL?
open private(set) var id: Int = -1
open var number: Int?
open var state: Openness?
@objc open var title: String?
@objc open var milestoneDescription: String?
@objc open var creator: User?
open var title: String?
open var milestoneDescription: String?
open var creator: User?
open var openIssues: Int?
open var closedIssues: Int?
@objc open var createdAt: Date?
@objc open var updatedAt: Date?
@objc open var closedAt: Date?
@objc open var dueOn: Date?
open var createdAt: Date?
open var updatedAt: Date?
open var closedAt: Date?
open var dueOn: Date?

enum CodingKeys: String, CodingKey {
case id
Expand Down
58 changes: 29 additions & 29 deletions OctoKit/PullRequest.swift
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
import Foundation
import RequestKit

@objc open class PullRequest: NSObject, Codable {

@objc private(set) open var id: Int = -1
@objc open var url: URL?

@objc open var htmlURL: URL?
@objc open var diffURL: URL?
@objc open var patchURL: URL?
@objc open var issueURL: URL?
@objc open var commitsURL: URL?
@objc open var reviewCommentsURL: URL?
@objc open var reviewCommentURL: URL?
@objc open var commentsURL: URL?
@objc open var statusesURL: URL?

open class PullRequest: Codable {
private(set) open var id: Int = -1
open var url: URL?

open var htmlURL: URL?
open var diffURL: URL?
open var patchURL: URL?
open var issueURL: URL?
open var commitsURL: URL?
open var reviewCommentsURL: URL?
open var reviewCommentURL: URL?
open var commentsURL: URL?
open var statusesURL: URL?

open var title: String?
open var body: String?

open var assignee: User?
open var milestone: Milestone?

open var locked: Bool?
open var createdAt: Date?
open var updatedAt: Date?
open var closedAt: Date?
open var mergedAt: Date?

open var user: User?
open var number: Int?
open var state: Openness?
@objc open var title: String?
@objc open var body: String?

@objc open var assignee: User?
@objc open var milestone: Milestone?

open var locked: Bool?
@objc open var createdAt: Date?
@objc open var updatedAt: Date?
@objc open var closedAt: Date?
@objc open var mergedAt: Date?

@objc open var user: User?


enum CodingKeys: String, CodingKey {
case id
case url
Expand All @@ -56,6 +55,7 @@ import RequestKit
}
}


// MARK: Request

public extension Octokit {
Expand Down
31 changes: 15 additions & 16 deletions OctoKit/Repositories.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ import Foundation
import RequestKit

// MARK: model

@objc open class Repository: NSObject, Codable {
@objc open private(set) var id: Int = -1
@objc open private(set) var owner = User()
@objc open var name: String?
@objc open var fullName: String?
@objc open private(set) var isPrivate: Bool = false
@objc open var repositoryDescription: String?
@objc open private(set) var isFork: Bool = false
@objc open var gitURL: String?
@objc open var sshURL: String?
@objc open var cloneURL: String?
@objc open var htmlURL: String?
@objc open private(set) var size: Int = -1
@objc open var lastPush: Date?

open class Repository: Codable {
open private(set) var id: Int = -1
open private(set) var owner = User()
open var name: String?
open var fullName: String?
open private(set) var isPrivate: Bool = false
open var repositoryDescription: String?
open private(set) var isFork: Bool = false
open var gitURL: String?
open var sshURL: String?
open var cloneURL: String?
open var htmlURL: String?
open private(set) var size: Int = -1
open var lastPush: Date?

enum CodingKeys: String, CodingKey {
case id
case owner
Expand Down
23 changes: 11 additions & 12 deletions OctoKit/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import Foundation
import RequestKit

// MARK: model

@objc open class User: NSObject, Codable {
@objc open internal(set) var id: Int = -1
@objc open var login: String?
@objc open var avatarURL: String?
@objc open var gravatarID: String?
@objc open var type: String?
@objc open var name: String?
@objc open var company: String?
@objc open var blog: String?
@objc open var location: String?
@objc open var email: String?
open class User: Codable {
open internal(set) var id: Int = -1
open var login: String?
open var avatarURL: String?
open var gravatarID: String?
open var type: String?
open var name: String?
open var company: String?
open var blog: String?
open var location: String?
open var email: String?
open var numberOfPublicRepos: Int?
open var numberOfPublicGists: Int?
open var numberOfPrivateRepos: Int?
Expand Down
17 changes: 0 additions & 17 deletions OctoKitTests/OctokitSwiftTests.swift

This file was deleted.

Loading

0 comments on commit b63f2ec

Please sign in to comment.