Add GitHub CI workflow (#78)
* Add GitHub workflow * Use macOS 10.15 in workflow * Select proper Xcode CLT * Try using sudo for CLT selection * Add macOS SDK env * Add SDKROOT env * Try running without setting CLT * Run without setup-swift step * Update all timeouts * Improve check conditions * Update timeouts
This commit is contained in:
parent
56e1631e72
commit
7a90ac0712
|
@ -0,0 +1,57 @@
|
|||
name: Build and Test Package
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-10.15
|
||||
steps:
|
||||
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Xcode 12
|
||||
uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: '12.4'
|
||||
|
||||
- name: Export macOS SDK
|
||||
run: echo SDKROOT=$(xcrun --sdk macosx --show-sdk-path) >> $GITHUB_ENV
|
||||
|
||||
- name: Install gem dependencies
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: .ruby-version
|
||||
bundler-cache: true
|
||||
|
||||
- name: Cache cocoapods dependencies
|
||||
uses: actions/cache@v2
|
||||
id: cache-pods
|
||||
with:
|
||||
path: Pods
|
||||
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
|
||||
restore-keys: ${{ runner.os }}-pods-
|
||||
|
||||
- name: Install cocoapods dependencies
|
||||
if: steps.cache-pods.outputs.cache-hit != 'true'
|
||||
run: bundle exec pod install
|
||||
|
||||
- name: Test Framework on iOS and tvOS
|
||||
run: bundle exec fastlane ios test
|
||||
|
||||
- name: Test Framework on macOS
|
||||
run: bundle exec fastlane mac test
|
||||
|
||||
- name: Lint podspec
|
||||
run: bundle exec pod lib lint
|
||||
|
||||
- name: Build Swift Package
|
||||
run: swift build -v
|
||||
|
||||
- name: Test Swift Package
|
||||
run: swift test -v
|
|
@ -3,6 +3,7 @@ Changelog
|
|||
|
||||
## master
|
||||
|
||||
- Add Github Action
|
||||
- Added `.introspectTextView()`.
|
||||
- Update CircleCI config to use Xcode 12.4.0
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ import SwiftUI
|
|||
|
||||
@available(macOS 10.15.0, *)
|
||||
enum TestUtils {
|
||||
enum Constants {
|
||||
static let timeout: TimeInterval = 2
|
||||
}
|
||||
|
||||
static func present<ViewType: View>(view: ViewType) {
|
||||
|
||||
let window = NSWindow(
|
||||
|
@ -155,7 +159,7 @@ class AppKitTests: XCTestCase {
|
|||
spy2: { expectation2.fulfill() }
|
||||
)
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation1, expectation2], timeout: 1)
|
||||
wait(for: [expectation1, expectation2], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testScrollView() {
|
||||
|
@ -167,7 +171,7 @@ class AppKitTests: XCTestCase {
|
|||
spy2: { expectation2.fulfill() }
|
||||
)
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation1, expectation2], timeout: 1)
|
||||
wait(for: [expectation1, expectation2], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testTextField() {
|
||||
|
@ -177,7 +181,7 @@ class AppKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testTextEditor() {
|
||||
|
@ -188,7 +192,7 @@ class AppKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,7 +203,7 @@ class AppKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testStepper() {
|
||||
|
@ -209,7 +213,7 @@ class AppKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testDatePicker() {
|
||||
|
@ -219,7 +223,7 @@ class AppKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testSegmentedControl() {
|
||||
|
@ -229,7 +233,7 @@ class AppKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,10 @@ import SwiftUI
|
|||
|
||||
@available(iOS 13.0, tvOS 13.0, macOS 10.15.0, *)
|
||||
enum TestUtils {
|
||||
enum Constants {
|
||||
static let timeout: TimeInterval = 3
|
||||
}
|
||||
|
||||
static func present<ViewType: View>(view: ViewType) {
|
||||
|
||||
let hostingController = UIHostingController(rootView: view)
|
||||
|
@ -253,7 +257,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testViewController() {
|
||||
|
@ -263,7 +267,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testTabView() {
|
||||
|
@ -273,7 +277,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testTabViewRoot() {
|
||||
|
@ -283,7 +287,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testList() {
|
||||
|
@ -295,7 +299,7 @@ class UIKitTests: XCTestCase {
|
|||
spy2: { expectation2.fulfill() }
|
||||
)
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation1, expectation2], timeout: 1)
|
||||
wait(for: [expectation1, expectation2], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testScrollView() {
|
||||
|
@ -307,7 +311,7 @@ class UIKitTests: XCTestCase {
|
|||
spy2: { expectation2.fulfill() }
|
||||
)
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation1, expectation2], timeout: 1)
|
||||
wait(for: [expectation1, expectation2], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testTextField() {
|
||||
|
@ -317,7 +321,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testSegmentedControl() {
|
||||
|
@ -327,7 +331,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
|
@ -338,7 +342,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testToggle() {
|
||||
|
@ -348,7 +352,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testSlider() {
|
||||
|
@ -358,7 +362,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testStepper() {
|
||||
|
@ -368,7 +372,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testDatePicker() {
|
||||
|
@ -378,7 +382,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
@available(iOS 14.0, macCatalyst 14.0, macOS 15.0, *)
|
||||
|
@ -390,7 +394,7 @@ class UIKitTests: XCTestCase {
|
|||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: 1)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue