Skip to content

Commit

Permalink
[ci] Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Jun 25, 2021
1 parent dc04daa commit c8378a2
Show file tree
Hide file tree
Showing 20 changed files with 80 additions and 32 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true
jobs:
smoke:
lint:
runs-on: ubuntu-latest
steps:
- uses: harupy/[email protected]

linux:
name: linux
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -57,6 +56,7 @@ jobs:
- 5.3
- 5.4
- 5.5
name: ${{ matrix.platform }} (${{ matrix.swift }})
steps:
- uses: actions/checkout@v2
- run: |
Expand All @@ -71,3 +71,23 @@ jobs:
code-coverage: true
warnings-as-errors: true
- uses: codecov/codecov-action@v1

windows:
runs-on: windows-latest
steps:
- uses: seanmiddleditch/gha-setup-vsdevenv@v3
- run: |
Install-Binary -Url "https://swift.org/builds/swift-5.4.1-release/windows10/swift-5.4.1-RELEASE/swift-5.4.1-RELEASE-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
- run: |
echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "DEVELOPER_DIR=C:\Library\Developer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- run: |
echo "C:\Library\Swift-development\bin;C:\Library\icu-67\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- run: |
Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap"
Copy-Item "$env:SDKROOT\usr\share\visualc.modulemap" -destination "$env:VCToolsInstallDir\include\module.modulemap"
Copy-Item "$env:SDKROOT\usr\share\visualc.apinotes" -destination "$env:VCToolsInstallDir\include\visualc.apinotes"
Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap"
- uses: actions/checkout@v2
- run: swift test --parallel
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pkg.platforms = [
]
pkg.swiftLanguageVersions = [.v5]

#if !os(Linux)
#if !os(Linux) && !os(Windows)
pkg.dependencies = [
.package(url: "https://github.com/AliSoftware/OHHTTPStubs", from: "9.1.0")
]
Expand All @@ -30,7 +30,7 @@ func has(tests name: String) -> Target? {
switch name {
case "PMKFoundation":
var deps = [Target.Dependency.target(name: "PMKFoundation")]
#if !os(Linux)
#if !os(Linux) && !os(Windows)
deps.append(.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs"))
#endif
return .testTarget(name: "\(name)Tests", dependencies: deps, path: "Tests/\(name)")
Expand All @@ -43,7 +43,7 @@ func has(tests name: String) -> Target? {

for name in ["PMKCloudKit", "PMKCoreLocation", "PMKFoundation", "PMKHealthKit", "PMKHomeKit", "PMKMapKit", "PMKPhotos", "PMKStoreKit", "PromiseKit"] {

#if os(Linux)
#if os(Linux) || os(Windows)
guard name == "PromiseKit" || name == "PMKFoundation" else { continue }
#endif

Expand Down
2 changes: 1 addition & 1 deletion Sources/PMKFoundation/NSObject+Promise.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !os(Linux)
#if !os(Linux) && !os(Windows)

import Foundation
#if !PMKCocoaPods
Expand Down
2 changes: 1 addition & 1 deletion Sources/PMKFoundation/NSURLSession+Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ extension URL: URLRequestConvertible {
}


#if !os(Linux)
#if !os(Linux) && !os(Windows)
public extension String {
/**
- Remark: useful when converting a `URLSession` response into a `String`
Expand Down
2 changes: 1 addition & 1 deletion Sources/PMKFoundation/afterlife.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !os(Linux)
#if !os(Linux) && !os(Windows)

import Foundation
#if !PMKCocoaPods
Expand Down
3 changes: 1 addition & 2 deletions Sources/PromiseKit/Dispatchers/CoreDataDispatcher.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !os(Linux)
#if canImport(CoreData)

import Foundation
import CoreData
Expand Down Expand Up @@ -28,4 +28,3 @@ public struct CoreDataDispatcher: Dispatcher {
}

#endif

11 changes: 0 additions & 11 deletions Sources/PromiseKit/Guarantee.swift
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,3 @@ public extension Dispatcher {
return rg
}
}

#if os(Linux)
import func CoreFoundation._CFIsMainThread

extension Thread {
// `isMainThread` is not implemented yet in swift-corelibs-foundation.
static var isMainThread: Bool {
return _CFIsMainThread()
}
}
#endif
4 changes: 4 additions & 0 deletions Sources/PromiseKit/hang.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if canImport(CoreFoundation)

import Foundation
import CoreFoundation

Expand Down Expand Up @@ -64,3 +66,5 @@ public func hang<T>(_ promise: Promise<T>) throws -> T {
public func hang<T>(_ promise: CancellablePromise<T>) throws -> T {
return try hang(promise.promise)
}

#endif
2 changes: 1 addition & 1 deletion Tests/A+/JavaScript/AllTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Lois Di Qual on 2/28/18.
//

#if !os(Linux) && !os(watchOS)
#if !os(Linux) && !os(watchOS) && !os(Windows)
import JavaScriptCore
import PromiseKit
import XCTest
Expand Down
2 changes: 1 addition & 1 deletion Tests/A+/JavaScript/JSAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Lois Di Qual on 3/2/18.
//

#if !os(Linux) && !os(watchOS)
#if !os(Linux) && !os(watchOS) && !os(Windows)
import JavaScriptCore
import PromiseKit

Expand Down
2 changes: 1 addition & 1 deletion Tests/A+/JavaScript/JSPromise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Lois Di Qual on 3/1/18.
//

#if !os(Linux) && !os(watchOS)
#if !os(Linux) && !os(watchOS) && !os(Windows)
import JavaScriptCore
import PromiseKit
import XCTest
Expand Down
2 changes: 1 addition & 1 deletion Tests/A+/JavaScript/JSUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Lois Di Qual on 3/2/18.
//

#if !os(Linux) && !os(watchOS)
#if !os(Linux) && !os(watchOS) && !os(Windows)
import JavaScriptCore

enum JSUtils {
Expand Down
2 changes: 1 addition & 1 deletion Tests/A+/JavaScript/MockNodeEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Lois Di Qual on 3/1/18.
//

#if !os(Linux) && !os(watchOS)
#if !os(Linux) && !os(watchOS) && !os(Windows)
import JavaScriptCore
import Foundation

Expand Down
8 changes: 8 additions & 0 deletions Tests/A+/Swift/0.0.0.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,15 @@ import func Glibc.random
func arc4random() -> UInt32 {
return UInt32(random())
}
#endif

#if os(Windows)
func arc4random() -> UInt32 {
return UInt32.random(in: UInt32.min...UInt32.max)
}
#endif

#if os(Linux) || os(Windows)
extension XCTestExpectation {
func fulfill() {
fulfill(#file, line: #line)
Expand Down
4 changes: 4 additions & 0 deletions Tests/Cancel/HangTests.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if canImport(CoreFoundation)

import PromiseKit
import XCTest

Expand Down Expand Up @@ -46,3 +48,5 @@ class HangTests: XCTestCase {
XCTFail("Expected error but no error was thrown")
}
}

#endif
14 changes: 12 additions & 2 deletions Tests/Cancel/Utilities.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PromiseKit
import XCTest

// Workaround for error with missing libswiftContacts.dylib, this import causes the
// library to be included as needed
Expand All @@ -24,17 +25,26 @@ extension Thread {
}
}

import XCTest

extension XCTestCase {
func wait(for: [XCTestExpectation], timeout: TimeInterval, file: StaticString = #file, line: UInt = #line) {
waitForExpectations(timeout: timeout, file: file, line: Int(line))
}
}

#endif

#if os(Linux) || os(Windows)
extension XCTestExpectation {
func fulfill() {
fulfill(#file, line: #line)
}
}
#endif

#if os(Windows)
import class Foundation.Thread

func usleep(_ us: UInt32) {
Thread.sleep(forTimeInterval: Double(us) / 1_000_000.0)
}
#endif
4 changes: 4 additions & 0 deletions Tests/Core/HangTests.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if canImport(CoreFoundation)

import PromiseKit
import XCTest

Expand Down Expand Up @@ -36,3 +38,5 @@ class HangTests: XCTestCase {
XCTFail("Expected error but no error was thrown")
}
}

#endif
14 changes: 12 additions & 2 deletions Tests/Core/Utilities.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PromiseKit
import XCTest

extension Promise {
func silenceWarning() {}
Expand All @@ -18,17 +19,26 @@ extension Thread {
}
}

import XCTest

extension XCTestCase {
func wait(for: [XCTestExpectation], timeout: TimeInterval, file: StaticString = #file, line: UInt = #line) {
waitForExpectations(timeout: timeout, file: file, line: Int(line))
}
}

#endif

#if os(Linux) || os(Windows)
extension XCTestExpectation {
func fulfill() {
fulfill(#file, line: #line)
}
}
#endif

#if os(Windows)
import class Foundation.Thread

func usleep(_ us: UInt32) {
Thread.sleep(forTimeInterval: Double(us) / 1_000_000.0)
}
#endif
2 changes: 1 addition & 1 deletion Tests/PMKFoundation/TestNSObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
import PromiseKit
import XCTest

#if !os(Linux)
#if !os(Linux) && !os(Windows)

class NSObjectTests: XCTestCase {
func testKVO() {
Expand Down
2 changes: 1 addition & 1 deletion Tests/PMKFoundation/TestNSURLSession.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !os(Linux) && !os(watchOS)
#if !os(Linux) && !os(watchOS) && !os(Windows)

import OHHTTPStubsSwift
import PMKFoundation
Expand Down

0 comments on commit c8378a2

Please sign in to comment.