Skip to content

Add GitHub action #78

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

Merged
merged 11 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 57 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog

## master

- Add Github Action
- Added `.introspectTextView()`.
- Update CircleCI config to use Xcode 12.4.0

Expand Down
20 changes: 12 additions & 8 deletions IntrospectTests/AppKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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)
}
}

Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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
32 changes: 18 additions & 14 deletions IntrospectTests/UIKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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)
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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, *)
Expand All @@ -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
}
Expand Down