GitHub Actions?

This commit is contained in:
Aaron Sky 2020-05-05 13:08:55 -04:00
parent 880af3d578
commit b4743e9b60
8 changed files with 42 additions and 43 deletions

32
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: CI
on: push
jobs:
test-macOS:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1.0.0
- name: SwiftPM Build
run: swift build
test-iOS:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1.0.0
- name: xcodebuild
run: |-
cd Packages/Buildkite
swift package generate-xcodeproj --enable-code-coverage
xcodebuild \
-project Buildkite.xcodeproj \
-scheme "Buildkite-Package" \
-destination "platform=iOS Simulator,OS=13.3,name=iPhone 11 Pro Max" \
-quiet \
build test
test-linux:
runs-on: ubuntu-latest
container:
image: swift:5.2.3
steps:
- uses: actions/checkout@v1.0.0
- name: SwiftPM Build
run: swift test --enable-test-discovery

View File

@ -7,7 +7,9 @@ let package = Package(
name: "Buildkite",
platforms: [
.iOS(.v10),
.macOS(.v10_12)
.macOS(.v10_12),
.tvOS(.v10),
.watchOS(.v3),
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.

View File

@ -124,7 +124,7 @@ public final class Buildkite {
#if canImport(Combine)
import Combine
@available(iOS 13.0, macOS 10.15, *)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension Buildkite {
public func sendPublisher<R: Resource & HasResponseBody>(_ resource: R) -> AnyPublisher<Response<R.Content>, Error> {
transport.sendPublisher(request: URLRequest(resource, configuration: configuration))

View File

@ -10,7 +10,7 @@ import Foundation
enum Formatters {
static let iso8601WithFractionalSeconds: ISO8601DateFormatter = {
let formatter: ISO8601DateFormatter
if #available(iOS 11.0, macOS 10.13, *) {
if #available(iOS 11.0, macOS 10.13, tvOS 11.0, watchOS 4.0, *) {
formatter = ISO8601DateFormatter()
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
} else {
@ -49,38 +49,3 @@ enum Formatters {
return date
}
}
class OptionalFractionalSecondsDateFormatter: DateFormatter {
static let withoutSeconds: DateFormatter = {
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(identifier: "UTC")
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXX"
return formatter
}()
func setup() {
calendar = Calendar(identifier: .iso8601)
locale = Locale(identifier: "en_US_POSIX")
timeZone = TimeZone(identifier: "UTC")
dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX" // handle up to 6 decimal places, although iOS currently only preserves 2 digits of precision
}
override init() {
super.init()
setup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
override func date(from string: String) -> Date? {
if let result = super.date(from: string) {
return result
}
return OptionalFractionalSecondsDateFormatter.withoutSeconds.date(from: string)
}
}

View File

@ -21,7 +21,7 @@ public protocol Transport {
func send(request: URLRequest, completion: @escaping (Result<Output, Error>) -> Void)
#if canImport(Combine)
@available(iOS 13.0, macOS 10.15, *)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
func sendPublisher(request: URLRequest) -> AnyPublisher<Output, Error>
#endif
}
@ -44,7 +44,7 @@ extension URLSession: Transport {
}
#if canImport(Combine)
@available(iOS 13.0, macOS 10.15, *)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public func sendPublisher(request: URLRequest) -> AnyPublisher<Output, Error> {
dataTaskPublisher(for: request)
.mapError { $0 as Error }

View File

@ -130,7 +130,7 @@ extension BuildkiteTests {
// MARK: Combine-based Requests
#if canImport(Combine)
@available(iOS 13.0, macOS 10.15, *)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension BuildkiteTests {
func testPublisherBasedRequest() throws {
let testData = try TestData(testCase: .success)

View File

@ -97,7 +97,7 @@ extension TransportTests {
// MARK: Combine-based Requests
#if canImport(Combine)
@available(iOS 13.0, macOS 10.15, *)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension TransportTests {
func testURLSessionSendPublisherBasedRequest() {
let request = URLRequest(url: URL())

View File

@ -40,7 +40,7 @@ extension MockTransport: Transport {
}
#if canImport(Combine)
@available(iOS 13.0, macOS 10.15, *)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
func sendPublisher(request: URLRequest) -> AnyPublisher<Output, Swift.Error> {
history.append(request)
return Future { [weak self] promise in