Skip to content

Commit 03cbf96

Browse files
authored
Merge pull request #159 from devxoul/feature/update-github-actions-ci
Fix Unit Tests
2 parents 37bc2b0 + 5951e5b commit 03cbf96

File tree

9 files changed

+139
-121
lines changed

9 files changed

+139
-121
lines changed

.github/workflows/cd.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ jobs:
1414
build:
1515
runs-on: macOS-latest
1616
steps:
17-
- uses: actions/checkout@v1
17+
- uses: actions/checkout@v1
1818

19-
- name: Generate Xcode Project
20-
run: swift package generate-xcodeproj
19+
- name: Generate Xcode Project
20+
run: swift package generate-xcodeproj
2121

22-
- name: Carthage Build
23-
run: carthage build --no-skip-current --platform $CARTHAGE_PLATFORMS
22+
- name: Carthage Build
23+
run: carthage build --no-skip-current --platform $CARTHAGE_PLATFORMS
2424

25-
- name: Carthage Archive
26-
run: carthage archive $CARTHAGE_FRAMEWORKS
25+
- name: Carthage Archive
26+
run: carthage archive $CARTHAGE_FRAMEWORKS
2727

28-
- name: Upload Carthage Framework
29-
uses: actions/upload-release-asset@v1
30-
env:
31-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
with:
33-
upload_url: ${{ github.event.release.upload_url }}
34-
asset_path: ${{ env.CARTHAGE_FRAMEWORK_NAME }}
35-
asset_name: ${{ env.CARTHAGE_FRAMEWORK_NAME }}
36-
asset_content_type: application/zip
28+
- name: Upload Carthage Framework
29+
uses: actions/upload-release-asset@v1
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
upload_url: ${{ github.event.release.upload_url }}
34+
asset_path: ${{ env.CARTHAGE_FRAMEWORK_NAME }}
35+
asset_name: ${{ env.CARTHAGE_FRAMEWORK_NAME }}
36+
asset_content_type: application/zip

.github/workflows/ci.yml

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@ name: CI
22

33
on:
44
push:
5+
branches:
6+
- master
57
pull_request:
68

79
jobs:
810
test:
911
runs-on: macOS-latest
1012
env:
11-
PROJECT: URLNavigator.xcodeproj
1213
SCHEME: URLNavigator-Package
1314
CODECOV_PACKAGE_NAME: URLNavigator
1415
strategy:
1516
matrix:
1617
env:
1718
- sdk: iphonesimulator
18-
destination: platform=iOS Simulator,name=iPhone 11 Pro,OS=latest
19+
destination: platform=iOS Simulator,name=iPhone 13 Pro,OS=latest
1920

2021
- sdk: macosx
2122
destination: arch=x86_64
@@ -24,32 +25,32 @@ jobs:
2425
destination: platform=tvOS Simulator,name=Apple TV,OS=latest
2526

2627
steps:
27-
- uses: actions/checkout@v1
28-
29-
- name: List SDKs and Devices
30-
run: xcodebuild -showsdks; instruments -s
31-
32-
- name: Generate Xcode Project
33-
run: swift package generate-xcodeproj --enable-code-coverage
34-
35-
- name: Build and Test
36-
run: |
37-
set -o pipefail && xcodebuild clean build test \
38-
-project "$PROJECT" \
39-
-scheme "$SCHEME" \
40-
-sdk "$SDK" \
41-
-destination "$DESTINATION" \
42-
-configuration Debug \
43-
-enableCodeCoverage YES \
44-
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c;
45-
env:
46-
SDK: ${{ matrix.env.sdk }}
47-
DESTINATION: ${{ matrix.env.destination }}
48-
49-
- name: Upload Code Coverage
50-
run: |
51-
bash <(curl -s https://codecov.io/bash) \
52-
-X xcodeplist \
53-
-J "$CODECOV_PACKAGE_NAME"
54-
env:
55-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
28+
- uses: actions/checkout@v3
29+
30+
- name: List SDKs and Devices
31+
run: xcodebuild -showsdks; xcrun xctrace list devices
32+
33+
- uses: maxim-lobanov/setup-xcode@v1
34+
with:
35+
xcode-version: latest
36+
37+
- name: Build and Test
38+
run: |
39+
set -o pipefail && xcodebuild clean build test \
40+
-scheme "$SCHEME" \
41+
-sdk "$SDK" \
42+
-destination "$DESTINATION" \
43+
-configuration Debug \
44+
-enableCodeCoverage YES \
45+
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c;
46+
env:
47+
SDK: ${{ matrix.env.sdk }}
48+
DESTINATION: ${{ matrix.env.destination }}
49+
50+
- name: Upload Code Coverage
51+
run: |
52+
bash <(curl -s https://codecov.io/bash) \
53+
-X xcodeplist \
54+
-J "$CODECOV_PACKAGE_NAME"
55+
env:
56+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@
66
**/xcshareddata
77
Pods/
88
Carthage/
9+
10+
# spm
11+
.build/
12+
Packages/
13+
.swiftpm

Package.resolved

Lines changed: 20 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.4
22

33
import PackageDescription
44

55
let package = Package(
66
name: "URLNavigator",
77
platforms: [
8-
.iOS(.v8), .tvOS(.v9),
8+
.iOS(.v9), .tvOS(.v9),
99
],
1010
products: [
1111
.library(name: "URLMatcher", targets: ["URLMatcher"]),
1212
.library(name: "URLNavigator", targets: ["URLNavigator"]),
1313
],
1414
dependencies: [
15-
.package(url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "2.1.0")),
16-
.package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "8.0.2")),
17-
.package(url: "https://github.com/devxoul/Stubber.git", .upToNextMajor(from: "1.4.0")),
15+
.package(url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "5.0.0")),
16+
.package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "10.0.0")),
1817
],
1918
targets: [
2019
.target(name: "URLMatcher"),
2120
.target(name: "URLNavigator", dependencies: ["URLMatcher"]),
2221
.testTarget(name: "URLMatcherTests", dependencies: ["URLMatcher", "Quick", "Nimble"]),
23-
.testTarget(name: "URLNavigatorTests", dependencies: ["URLNavigator", "Quick", "Nimble", "Stubber"]),
22+
.testTarget(name: "URLNavigatorTests", dependencies: ["URLNavigator", "Quick", "Nimble"]),
2423
]
2524
)

Sources/URLNavigator/UIViewControllerType.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#if os(iOS) || os(tvOS)
22
import UIKit
33

4-
public protocol UINavigationControllerType {
4+
public protocol UINavigationControllerType: AnyObject {
55
func pushViewController(_ viewController: UIViewController, animated: Bool)
66
}
77

8-
public protocol UIViewControllerType {
8+
public protocol UIViewControllerType: AnyObject {
99
func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?)
1010
}
1111

Tests/URLNavigatorTests/NavigatorSpec.swift

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import UIKit
33

44
import Nimble
55
import Quick
6-
import Stubber
76

87
import URLNavigator
98

@@ -88,20 +87,18 @@ final class NavigatorSpec: QuickSpec {
8887
let navigationController = StubNavigationController()
8988
navigator.push("myapp://article/123", from: navigationController)
9089

91-
let executions = Stubber.executions(navigationController.pushViewController)
92-
expect(executions.count) == 1
93-
expect(executions[0].arguments.0).to(beAKindOf(ArticleViewController.self))
94-
expect(executions[0].arguments.1) == true
90+
expect(navigationController.pushViewControllerCallCount) == 1
91+
expect(navigationController.pushViewControllerParams?.viewController).to(beAKindOf(ArticleViewController.self))
92+
expect(navigationController.pushViewControllerParams?.animated) == true
9593
}
9694

9795
it("executes pushViewController() with given arguments") {
9896
let navigationController = StubNavigationController()
9997
navigator.push("myapp://article/123", from: navigationController, animated: false)
10098

101-
let executions = Stubber.executions(navigationController.pushViewController)
102-
expect(executions.count) == 1
103-
expect(executions[0].arguments.0).to(beAKindOf(ArticleViewController.self))
104-
expect(executions[0].arguments.1) == false
99+
expect(navigationController.pushViewControllerCallCount) == 1
100+
expect(navigationController.pushViewControllerParams?.viewController).to(beAKindOf(ArticleViewController.self))
101+
expect(navigationController.pushViewControllerParams?.animated) == false
105102
}
106103
}
107104

@@ -131,11 +128,10 @@ final class NavigatorSpec: QuickSpec {
131128
let rootViewController = StubViewController()
132129
navigator.present("myapp://article/123", from: rootViewController)
133130

134-
let executions = Stubber.executions(rootViewController.present)
135-
expect(executions.count) == 1
136-
expect(executions[0].arguments.0).to(beAKindOf(ArticleViewController.self))
137-
expect(executions[0].arguments.1) == true
138-
expect(executions[0].arguments.2).to(beNil())
131+
expect(rootViewController.presentCallCount) == 1
132+
expect(rootViewController.presentParams?.viewControllerToPresent).to(beAKindOf(ArticleViewController.self))
133+
expect(rootViewController.presentParams?.animated) == true
134+
expect(rootViewController.presentParams?.completion).to(beNil())
139135
}
140136

141137
it("executes present() with given arguments") {
@@ -145,12 +141,10 @@ final class NavigatorSpec: QuickSpec {
145141
completionExecutionCount += 1
146142
})
147143

148-
let executions = Stubber.executions(rootViewController.present)
149-
expect(executions.count) == 1
150-
expect(executions[0].arguments.0).to(beAKindOf(MyNavigationController.self))
151-
expect(executions[0].arguments.1) == false
152-
expect(executions[0].arguments.2).notTo(beNil())
153-
expect(completionExecutionCount) == 1
144+
expect(rootViewController.presentCallCount) == 1
145+
expect(rootViewController.presentParams?.viewControllerToPresent).to(beAKindOf(MyNavigationController.self))
146+
expect(rootViewController.presentParams?.animated) == false
147+
expect(rootViewController.presentParams?.completion).notTo(beNil())
154148
}
155149
}
156150

@@ -266,32 +260,31 @@ final class NavigatorSpec: QuickSpec {
266260
context("on push()") {
267261
it("doesn't get called for a not matching url") {
268262
navigator.push("myapp://user/10", from: fromNavigationController)
269-
expect(Stubber.executions(delegate.shouldPush).count) == 0
263+
expect(delegate.shouldPushCallCount) == 0
270264
}
271265

272266
it("doesn't get called when the factory returns nil") {
273267
navigator.push("myapp://article/-1", from: fromNavigationController)
274-
expect(Stubber.executions(delegate.shouldPush).count) == 0
268+
expect(delegate.shouldPushCallCount) == 0
275269
}
276270

277271
it("gets called for a valid url") {
278272
navigator.push("myapp://article/123", from: fromNavigationController)
279-
let executions = Stubber.executions(delegate.shouldPush)
280-
expect(executions.count) == 1
281-
expect(executions[0].arguments.0).to(beAKindOf(ArticleViewController.self))
282-
expect(executions[0].arguments.1) === fromNavigationController
273+
expect(delegate.shouldPushCallCount) == 1
274+
expect(delegate.shouldPushParams?.viewController).to(beAKindOf(ArticleViewController.self))
275+
expect(delegate.shouldPushParams?.from) === fromNavigationController
283276
}
284277

285278
it("doesn't prevent from pushing when returns true") {
286-
Stubber.register(delegate.shouldPush) { _ in true }
279+
delegate.shouldPushStub = true
287280
navigator.push("myapp://article/123", from: fromNavigationController)
288-
expect(Stubber.executions(fromNavigationController.pushViewController).count) == 1
281+
expect(fromNavigationController.pushViewControllerCallCount) == 1
289282
}
290283

291284
it("prevents from pushing when returns false") {
292-
Stubber.register(delegate.shouldPush) { _ in false }
285+
delegate.shouldPushStub = false
293286
navigator.push("myapp://article/123", from: fromNavigationController)
294-
expect(Stubber.executions(fromNavigationController.pushViewController).count) == 0
287+
expect(fromNavigationController.pushViewControllerCallCount) == 0
295288
}
296289
}
297290

@@ -312,32 +305,31 @@ final class NavigatorSpec: QuickSpec {
312305
context("on present()") {
313306
it("doesn't get called for a not matching url") {
314307
navigator.present("myapp://user/10", from: fromViewController)
315-
expect(Stubber.executions(delegate.shouldPresent).count) == 0
308+
expect(delegate.shouldPresentCallCount) == 0
316309
}
317310

318311
it("doesn't get called when the factory returns nil") {
319312
navigator.present("myapp://article/-1", from: fromViewController)
320-
expect(Stubber.executions(delegate.shouldPresent).count) == 0
313+
expect(delegate.shouldPresentCallCount) == 0
321314
}
322315

323316
it("gets called for a valid url") {
324317
navigator.present("myapp://article/123", from: fromViewController)
325-
let executions = Stubber.executions(delegate.shouldPresent)
326-
expect(executions.count) == 1
327-
expect(executions[0].arguments.0).to(beAKindOf(ArticleViewController.self))
328-
expect(executions[0].arguments.1) === fromViewController
318+
expect(delegate.shouldPresentCallCount) == 1
319+
expect(delegate.shouldPresentParams?.viewController).to(beAKindOf(ArticleViewController.self))
320+
expect(delegate.shouldPresentParams?.from) === fromViewController
329321
}
330322

331323
it("doesn't prevent from presenting when returns true") {
332-
Stubber.register(delegate.shouldPresent) { _ in true }
324+
delegate.shouldPresentStub = true
333325
navigator.present("myapp://article/123", from: fromViewController)
334-
expect(Stubber.executions(fromViewController.present).count) == 1
326+
expect(fromViewController.presentCallCount) == 1
335327
}
336328

337329
it("prevents from presenting when returns false") {
338-
Stubber.register(delegate.shouldPresent) { _ in false }
330+
delegate.shouldPresentStub = false
339331
navigator.present("myapp://article/123", from: fromViewController)
340-
expect(Stubber.executions(fromViewController.present).count) == 0
332+
expect(fromViewController.presentCallCount) == 0
341333
}
342334
}
343335
}

0 commit comments

Comments
 (0)