Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.

Commit b7350b7

Browse files
authored
Merge pull request #2 from gperdomor/feature/gitlab-ci
add gitlab ci
2 parents 97d0fe4 + e5f5aee commit b7350b7

File tree

4 files changed

+317
-11
lines changed

4 files changed

+317
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@ fastlane/test_output
7171

7272
# End of https://www.gitignore.io/api/swift
7373

74+
.DS_Store
75+
.vscode/
76+
.idea/

.gitlab-ci.yml

Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
############################################
2+
# GLOBAL VARS
3+
4+
variables:
5+
XCODE_PROJECT: MoyaUnbox.xcodeproj
6+
GIT_STRATEGY: fetch
7+
8+
############################################
9+
# STAGES
10+
11+
stages:
12+
- moya
13+
- reactive
14+
- podlint
15+
- after_success
16+
17+
############################################
18+
# JOBS
19+
20+
before_script:
21+
- brew update
22+
# Cocoapod
23+
- brew outdated cocoapods || brew upgrade cocoapods
24+
# SwiftLint
25+
- brew outdated swiftlint || brew upgrade swiftlint
26+
# Carthage tools
27+
- brew outdated carthage || brew upgrade carthage
28+
# - curl -L -O https://github.com/YPlan/CartfileDiff/releases/download/0.1/CartfileDiff.pkg
29+
# - sudo installer -pkg CartfileDiff.pkg -target /
30+
# xcpretty
31+
- if ! gem list xcpretty -i > /dev/null 2>&1; then
32+
gem install xcpretty;
33+
fi
34+
35+
- if ! gem list danger -i > /dev/null 2>&1; then
36+
gem install danger;
37+
fi
38+
39+
- if ! gem list danger-swiftlint -i > /dev/null 2>&1; then
40+
gem install danger-swiftlint;
41+
fi
42+
# bootstrap the dependencies for the project
43+
# you can remove if you don't have dependencies
44+
- PLATFORM=$PLATFORM ./scripts/bootstrap-if-needed
45+
46+
after_script:
47+
- osascript -e 'tell app "Simulator" to quit'
48+
49+
############################################
50+
# TEMPLATES
51+
52+
.cache: &cache_paths
53+
paths:
54+
- Carthage
55+
56+
.script_template: &script_definition
57+
script:
58+
- set -o pipefail
59+
- xcodebuild -version
60+
- xcodebuild -showsdks
61+
62+
- SCHEME="$PREFIX$BASE_SCHEME"
63+
64+
- xcodebuild clean -project "$XCODE_PROJECT" -scheme "$SCHEME" | xcpretty
65+
66+
# Build Framework in Debug and Run Tests if specified
67+
- echo "BUILD FOR DEBUG"
68+
- if [ $RUN_TESTS == "YES" ]; then
69+
xcodebuild -project "$XCODE_PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty;
70+
else
71+
xcodebuild -project "$XCODE_PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty;
72+
fi
73+
74+
- xcodebuild clean -project "$XCODE_PROJECT" -scheme "$SCHEME" | xcpretty
75+
76+
# Build Framework in Release and Run Tests if specified
77+
- echo "BUILD FOR RELEASE"
78+
- if [ $RUN_TESTS == "YES" ]; then
79+
xcodebuild -project "$XCODE_PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty;
80+
else
81+
xcodebuild -project "$XCODE_PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO build | xcpretty;
82+
fi
83+
84+
.iOS_vars: &iOS_vars
85+
PLATFORM: iOS
86+
BASE_SCHEME: MoyaUnbox-iOS
87+
SDK: iphonesimulator10.2
88+
RUN_TESTS: "YES"
89+
90+
.macOS_vars: &macOS_vars
91+
PLATFORM: macOS
92+
BASE_SCHEME: MoyaUnbox-macOS
93+
SDK: macosx10.12
94+
RUN_TESTS: "YES"
95+
DESTINATION: "platform=OS X,arch=x86_64"
96+
97+
.tvOS_vars: &tvOS_vars
98+
PLATFORM: tvOS
99+
BASE_SCHEME: MoyaUnbox-tvOS
100+
SDK: appletvsimulator10.1
101+
RUN_TESTS: "YES"
102+
103+
.watchOS_vars: &watchOS_vars
104+
PLATFORM: watchOS
105+
BASE_SCHEME: MoyaUnbox-watchOS
106+
SDK: watchsimulator3.1
107+
RUN_TESTS: "NO"
108+
109+
############################################
110+
# JOBS - STAGE: TEST
111+
112+
# iPhone 7
113+
iPhone 7 - OS 10.2:
114+
stage: moya
115+
cache:
116+
<<: *cache_paths
117+
key: iOS
118+
tags:
119+
- xcode
120+
- iOS
121+
<<: *script_definition
122+
variables:
123+
<<: *iOS_vars
124+
DESTINATION: "platform=iOS Simulator,OS=10.2,name=iPhone 7"
125+
126+
Rx iPhone 7 - OS 10.2:
127+
stage: reactive
128+
cache:
129+
<<: *cache_paths
130+
key: iOS
131+
tags:
132+
- xcode
133+
- iOS
134+
<<: *script_definition
135+
variables:
136+
<<: *iOS_vars
137+
PREFIX: Rx
138+
DESTINATION: "platform=iOS Simulator,OS=10.2,name=iPhone 7"
139+
140+
Reactive iPhone 7 - OS 10.2:
141+
stage: reactive
142+
cache:
143+
<<: *cache_paths
144+
key: iOS
145+
tags:
146+
- xcode
147+
- iOS
148+
<<: *script_definition
149+
variables:
150+
<<: *iOS_vars
151+
PREFIX: Reactive
152+
DESTINATION: "platform=iOS Simulator,OS=10.2,name=iPhone 7"
153+
154+
# macOS
155+
macOS - OS 10.12:
156+
stage: moya
157+
cache:
158+
<<: *cache_paths
159+
key: macOS
160+
tags:
161+
- xcode
162+
- macOS
163+
<<: *script_definition
164+
variables:
165+
<<: *macOS_vars
166+
167+
Rx macOS - OS 10.12:
168+
stage: reactive
169+
cache:
170+
<<: *cache_paths
171+
key: macOS
172+
tags:
173+
- xcode
174+
- macOS
175+
<<: *script_definition
176+
variables:
177+
<<: *macOS_vars
178+
PREFIX: Rx
179+
180+
Reactive macOS - OS 10.12:
181+
stage: reactive
182+
cache:
183+
<<: *cache_paths
184+
key: macOS
185+
tags:
186+
- xcode
187+
- macOS
188+
<<: *script_definition
189+
variables:
190+
<<: *macOS_vars
191+
PREFIX: Reactive
192+
193+
# tvOS
194+
Apple TV 1080p - OS 10.1:
195+
stage: moya
196+
cache:
197+
<<: *cache_paths
198+
key: tvOS
199+
tags:
200+
- xcode
201+
- tvOS
202+
<<: *script_definition
203+
variables:
204+
<<: *tvOS_vars
205+
DESTINATION: "OS=10.1,name=Apple TV 1080p"
206+
207+
Rx Apple TV 1080p - OS 10.1:
208+
stage: reactive
209+
cache:
210+
<<: *cache_paths
211+
key: tvOS
212+
tags:
213+
- xcode
214+
- tvOS
215+
<<: *script_definition
216+
variables:
217+
<<: *tvOS_vars
218+
PREFIX: Rx
219+
DESTINATION: "OS=10.1,name=Apple TV 1080p"
220+
221+
Reactive Apple TV 1080p - OS 10.1:
222+
stage: reactive
223+
cache:
224+
<<: *cache_paths
225+
key: tvOS
226+
tags:
227+
- xcode
228+
- tvOS
229+
<<: *script_definition
230+
variables:
231+
<<: *tvOS_vars
232+
PREFIX: Reactive
233+
DESTINATION: "OS=10.1,name=Apple TV 1080p"
234+
235+
# watchOS
236+
Apple Watch Series 2 - OS 3.1:
237+
stage: moya
238+
allow_failure: true
239+
cache:
240+
<<: *cache_paths
241+
key: watchOS
242+
tags:
243+
- xcode
244+
- watchOS
245+
<<: *script_definition
246+
variables:
247+
<<: *watchOS_vars
248+
DESTINATION: "platform=watchOS Simulator,OS=3.1,name=Apple Watch Series 2 - 42mm"
249+
250+
Rx Apple Watch Series 2 - OS 3.1:
251+
stage: reactive
252+
allow_failure: true
253+
cache:
254+
<<: *cache_paths
255+
key: watchOS
256+
tags:
257+
- xcode
258+
- watchOS
259+
<<: *script_definition
260+
variables:
261+
<<: *watchOS_vars
262+
PREFIX: Rx
263+
DESTINATION: "platform=watchOS Simulator,OS=3.1,name=Apple Watch Series 2 - 42mm"
264+
265+
Reactive Apple Watch Series 2 - OS 3.1:
266+
stage: reactive
267+
allow_failure: true
268+
cache:
269+
<<: *cache_paths
270+
key: watchOS
271+
tags:
272+
- xcode
273+
- watchOS
274+
<<: *script_definition
275+
variables:
276+
<<: *watchOS_vars
277+
PREFIX: Reactive
278+
DESTINATION: "platform=watchOS Simulator,OS=3.1,name=Apple Watch Series 2 - 42mm"
279+
280+
############################################
281+
# JOBS - STAGE: PODLINT
282+
283+
podlint:
284+
stage: podlint
285+
when: on_success
286+
tags:
287+
- xcode
288+
before_script:
289+
- echo "Podlint"
290+
script:
291+
- pod lib lint --allow-warnings
292+
293+
############################################
294+
# JOBS - STAGE: AFTER SUCCESS
295+
296+
danger:
297+
stage: after_success
298+
when: on_success
299+
tags:
300+
- xcode
301+
before_script:
302+
- echo "Danger"
303+
script:
304+
- danger
305+
306+
#codecov:
307+
# stage: after_success
308+
# when: on_success
309+
# script:
310+
# - bash <(curl -s https://codecov.io/bash)

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,14 @@ before_script:
8181
- PLATFORM=${PLATFORM} ./scripts/bootstrap-if-needed
8282

8383
script:
84-
- printenv
8584
- set -o pipefail
8685
- xcodebuild -version
8786
- xcodebuild -showsdks
8887

8988
- xcodebuild clean -project "${TRAVIS_XCODE_PROJECT}" -scheme "${SCHEME}" | xcpretty
9089

9190
# Build Framework in Debug and Run Tests if specified
92-
- echo "BUILD FOR DEBUG ---> RUN_TESTS = ${RUN_TESTS}"
91+
- echo "BUILD FOR DEBUG"
9392
- if [ ${RUN_TESTS} == "YES" ]; then
9493
xcodebuild -project "${TRAVIS_XCODE_PROJECT}" -scheme "${SCHEME}" -sdk "${SDK}" -destination "${DESTINATION}" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty;
9594
else
@@ -99,7 +98,7 @@ script:
9998
- xcodebuild clean -project "$TRAVIS_XCODE_PROJECT" -scheme "$SCHEME" | xcpretty
10099

101100
# Build Framework in Release and Run Tests if specified
102-
- echo "BUILD FOR RELEASE ---> RUN_TESTS = ${RUN_TESTS}"
101+
- echo "BUILD FOR RELEASE"
103102
- if [ ${RUN_TESTS} == "YES" ]; then
104103
xcodebuild -project "${TRAVIS_XCODE_PROJECT}" -scheme "${SCHEME}" -sdk "${SDK}" -destination "${DESTINATION}" -configuration Release ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty;
105104
else

Sources/MoyaUnbox/Response+Unbox.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ public extension Response {
5353
public func map<T: Unboxable>(to type: T.Type, fromKey keyPath: String?) throws -> T {
5454
guard let keyPath = keyPath else { return try map(to: type) }
5555

56-
guard let json = try mapJSON() as? UnboxableDictionary else {
57-
throw MoyaError.jsonMapping(self)
58-
}
59-
6056
do {
57+
let json = try mapJSON() as! UnboxableDictionary
6158
return try unbox(dictionary: json, atKey: keyPath)
6259
} catch {
6360
throw MoyaError.jsonMapping(self)
@@ -87,11 +84,8 @@ public extension Response {
8784
public func map<T: Unboxable>(to type: [T.Type], fromKey keyPath: String? = nil) throws -> [T] {
8885
guard let keyPath = keyPath else { return try map(to: type) }
8986

90-
guard let jsonArray = try mapJSON() as? UnboxableDictionary else {
91-
throw MoyaError.jsonMapping(self)
92-
}
93-
9487
do {
88+
let jsonArray = try mapJSON() as! UnboxableDictionary
9589
return try unbox(dictionary: jsonArray, atKey: keyPath)
9690
} catch {
9791
throw MoyaError.jsonMapping(self)

0 commit comments

Comments
 (0)