Skip to content

Commit 7a90ac0

Browse files
authored
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
1 parent 56e1631 commit 7a90ac0

File tree

4 files changed

+88
-22
lines changed

4 files changed

+88
-22
lines changed

.github/workflows/build-and-test.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build and Test Package
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
10+
jobs:
11+
build:
12+
runs-on: macos-10.15
13+
steps:
14+
15+
- name: Checkout Repository
16+
uses: actions/checkout@v2
17+
18+
- name: Setup Xcode 12
19+
uses: maxim-lobanov/setup-xcode@v1
20+
with:
21+
xcode-version: '12.4'
22+
23+
- name: Export macOS SDK
24+
run: echo SDKROOT=$(xcrun --sdk macosx --show-sdk-path) >> $GITHUB_ENV
25+
26+
- name: Install gem dependencies
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: .ruby-version
30+
bundler-cache: true
31+
32+
- name: Cache cocoapods dependencies
33+
uses: actions/cache@v2
34+
id: cache-pods
35+
with:
36+
path: Pods
37+
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
38+
restore-keys: ${{ runner.os }}-pods-
39+
40+
- name: Install cocoapods dependencies
41+
if: steps.cache-pods.outputs.cache-hit != 'true'
42+
run: bundle exec pod install
43+
44+
- name: Test Framework on iOS and tvOS
45+
run: bundle exec fastlane ios test
46+
47+
- name: Test Framework on macOS
48+
run: bundle exec fastlane mac test
49+
50+
- name: Lint podspec
51+
run: bundle exec pod lib lint
52+
53+
- name: Build Swift Package
54+
run: swift build -v
55+
56+
- name: Test Swift Package
57+
run: swift test -v

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Changelog
33

44
## master
55

6+
- Add Github Action
67
- Added `.introspectTextView()`.
78
- Update CircleCI config to use Xcode 12.4.0
89

IntrospectTests/AppKitTests.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import SwiftUI
66

77
@available(macOS 10.15.0, *)
88
enum TestUtils {
9+
enum Constants {
10+
static let timeout: TimeInterval = 2
11+
}
12+
913
static func present<ViewType: View>(view: ViewType) {
1014

1115
let window = NSWindow(
@@ -155,7 +159,7 @@ class AppKitTests: XCTestCase {
155159
spy2: { expectation2.fulfill() }
156160
)
157161
TestUtils.present(view: view)
158-
wait(for: [expectation1, expectation2], timeout: 1)
162+
wait(for: [expectation1, expectation2], timeout: TestUtils.Constants.timeout)
159163
}
160164

161165
func testScrollView() {
@@ -167,7 +171,7 @@ class AppKitTests: XCTestCase {
167171
spy2: { expectation2.fulfill() }
168172
)
169173
TestUtils.present(view: view)
170-
wait(for: [expectation1, expectation2], timeout: 1)
174+
wait(for: [expectation1, expectation2], timeout: TestUtils.Constants.timeout)
171175
}
172176

173177
func testTextField() {
@@ -177,7 +181,7 @@ class AppKitTests: XCTestCase {
177181
expectation.fulfill()
178182
})
179183
TestUtils.present(view: view)
180-
wait(for: [expectation], timeout: 1)
184+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
181185
}
182186

183187
func testTextEditor() {
@@ -188,7 +192,7 @@ class AppKitTests: XCTestCase {
188192
expectation.fulfill()
189193
})
190194
TestUtils.present(view: view)
191-
wait(for: [expectation], timeout: 1)
195+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
192196
}
193197
}
194198

@@ -199,7 +203,7 @@ class AppKitTests: XCTestCase {
199203
expectation.fulfill()
200204
})
201205
TestUtils.present(view: view)
202-
wait(for: [expectation], timeout: 1)
206+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
203207
}
204208

205209
func testStepper() {
@@ -209,7 +213,7 @@ class AppKitTests: XCTestCase {
209213
expectation.fulfill()
210214
})
211215
TestUtils.present(view: view)
212-
wait(for: [expectation], timeout: 1)
216+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
213217
}
214218

215219
func testDatePicker() {
@@ -219,7 +223,7 @@ class AppKitTests: XCTestCase {
219223
expectation.fulfill()
220224
})
221225
TestUtils.present(view: view)
222-
wait(for: [expectation], timeout: 1)
226+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
223227
}
224228

225229
func testSegmentedControl() {
@@ -229,7 +233,7 @@ class AppKitTests: XCTestCase {
229233
expectation.fulfill()
230234
})
231235
TestUtils.present(view: view)
232-
wait(for: [expectation], timeout: 1)
236+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
233237
}
234238
}
235239
#endif

IntrospectTests/UIKitTests.swift

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import SwiftUI
66

77
@available(iOS 13.0, tvOS 13.0, macOS 10.15.0, *)
88
enum TestUtils {
9+
enum Constants {
10+
static let timeout: TimeInterval = 3
11+
}
12+
913
static func present<ViewType: View>(view: ViewType) {
1014

1115
let hostingController = UIHostingController(rootView: view)
@@ -253,7 +257,7 @@ class UIKitTests: XCTestCase {
253257
expectation.fulfill()
254258
})
255259
TestUtils.present(view: view)
256-
wait(for: [expectation], timeout: 1)
260+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
257261
}
258262

259263
func testViewController() {
@@ -263,7 +267,7 @@ class UIKitTests: XCTestCase {
263267
expectation.fulfill()
264268
})
265269
TestUtils.present(view: view)
266-
wait(for: [expectation], timeout: 1)
270+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
267271
}
268272

269273
func testTabView() {
@@ -273,7 +277,7 @@ class UIKitTests: XCTestCase {
273277
expectation.fulfill()
274278
})
275279
TestUtils.present(view: view)
276-
wait(for: [expectation], timeout: 1)
280+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
277281
}
278282

279283
func testTabViewRoot() {
@@ -283,7 +287,7 @@ class UIKitTests: XCTestCase {
283287
expectation.fulfill()
284288
})
285289
TestUtils.present(view: view)
286-
wait(for: [expectation], timeout: 1)
290+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
287291
}
288292

289293
func testList() {
@@ -295,7 +299,7 @@ class UIKitTests: XCTestCase {
295299
spy2: { expectation2.fulfill() }
296300
)
297301
TestUtils.present(view: view)
298-
wait(for: [expectation1, expectation2], timeout: 1)
302+
wait(for: [expectation1, expectation2], timeout: TestUtils.Constants.timeout)
299303
}
300304

301305
func testScrollView() {
@@ -307,7 +311,7 @@ class UIKitTests: XCTestCase {
307311
spy2: { expectation2.fulfill() }
308312
)
309313
TestUtils.present(view: view)
310-
wait(for: [expectation1, expectation2], timeout: 1)
314+
wait(for: [expectation1, expectation2], timeout: TestUtils.Constants.timeout)
311315
}
312316

313317
func testTextField() {
@@ -317,7 +321,7 @@ class UIKitTests: XCTestCase {
317321
expectation.fulfill()
318322
})
319323
TestUtils.present(view: view)
320-
wait(for: [expectation], timeout: 1)
324+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
321325
}
322326

323327
func testSegmentedControl() {
@@ -327,7 +331,7 @@ class UIKitTests: XCTestCase {
327331
expectation.fulfill()
328332
})
329333
TestUtils.present(view: view)
330-
wait(for: [expectation], timeout: 1)
334+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
331335
}
332336

333337
#if os(iOS)
@@ -338,7 +342,7 @@ class UIKitTests: XCTestCase {
338342
expectation.fulfill()
339343
})
340344
TestUtils.present(view: view)
341-
wait(for: [expectation], timeout: 1)
345+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
342346
}
343347

344348
func testToggle() {
@@ -348,7 +352,7 @@ class UIKitTests: XCTestCase {
348352
expectation.fulfill()
349353
})
350354
TestUtils.present(view: view)
351-
wait(for: [expectation], timeout: 1)
355+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
352356
}
353357

354358
func testSlider() {
@@ -358,7 +362,7 @@ class UIKitTests: XCTestCase {
358362
expectation.fulfill()
359363
})
360364
TestUtils.present(view: view)
361-
wait(for: [expectation], timeout: 1)
365+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
362366
}
363367

364368
func testStepper() {
@@ -368,7 +372,7 @@ class UIKitTests: XCTestCase {
368372
expectation.fulfill()
369373
})
370374
TestUtils.present(view: view)
371-
wait(for: [expectation], timeout: 1)
375+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
372376
}
373377

374378
func testDatePicker() {
@@ -378,7 +382,7 @@ class UIKitTests: XCTestCase {
378382
expectation.fulfill()
379383
})
380384
TestUtils.present(view: view)
381-
wait(for: [expectation], timeout: 1)
385+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
382386
}
383387

384388
@available(iOS 14.0, macCatalyst 14.0, macOS 15.0, *)
@@ -390,7 +394,7 @@ class UIKitTests: XCTestCase {
390394
expectation.fulfill()
391395
})
392396
TestUtils.present(view: view)
393-
wait(for: [expectation], timeout: 1)
397+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
394398
}
395399
#endif
396400
}

0 commit comments

Comments
 (0)