1
1
// This build configuration requires the following to be installed:
2
- // Git, Xcode, XCode Command-line Tools, Cocoapods, Xcodebuild, Xcresultparser , pip
2
+ // Git, Xcode, XCode Command-line Tools, Cocoapods, xcbeautify, xcresultparser , pip
3
3
4
4
// Log a bunch of version information to make it easier for debugging
5
5
local version_info = {
6
6
name: 'Version Information' ,
7
+ environment: { LANG: 'en_US.UTF-8' },
7
8
commands: [
8
9
'git --version' ,
9
10
'pod --version' ,
10
- 'xcodebuild -version'
11
- ]
11
+ 'xcodebuild -version' ,
12
+ 'xcbeautify --version' ,
13
+ 'xcresultparser --version' ,
14
+ 'pip --version' ,
15
+ ],
12
16
};
13
17
14
18
// Intentionally doing a depth of 2 as libSession-util has it's own submodules (and libLokinet likely will as well)
15
19
local clone_submodules = {
16
20
name: 'Clone Submodules' ,
17
- commands: ['git fetch --tags' , 'git submodule update --init --recursive --depth=2 --jobs=4' ]
21
+ commands: ['git submodule update --init --recursive --depth=2 --jobs=4' ],
18
22
};
19
23
20
24
// cmake options for static deps mirror
21
25
local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https://oxen.rocks/deps ' else '' );
22
26
23
- // Output some information about the built tools in case specific combinations break the build
24
- local machine_info = {
25
- name: 'Machine info' ,
26
- commands: [
27
- 'xcodebuild -version' ,
28
- 'LANG=en_US.UTF-8 pod --version'
29
- ]
30
- };
31
-
32
27
// Cocoapods
33
- //
28
+ //
34
29
// Unfortunately Cocoapods has a dumb restriction which requires you to use UTF-8 for the
35
30
// 'LANG' env var so we need to work around the with https://github.com/CocoaPods/CocoaPods/issues/6333
36
31
local install_cocoapods = {
37
32
name: 'Install CocoaPods' ,
38
- commands: ['
39
- LANG=en_US.UTF-8 pod install || rm -rf ./Pods && LANG=en_US.UTF-8 pod install
40
- ' ],
33
+ environment: { LANG: 'en_US.UTF-8' },
34
+ commands: [
35
+ 'pod install || (rm -rf ./Pods && pod install)' ,
36
+ ],
41
37
depends_on: [
42
- 'Load CocoaPods Cache'
43
- ]
38
+ 'Load CocoaPods Cache' ,
39
+ ],
44
40
};
45
41
46
42
// Load from the cached CocoaPods directory (to speed up the build)
@@ -49,26 +45,26 @@ local load_cocoapods_cache = {
49
45
commands: [
50
46
|||
51
47
LOOP_BREAK=0
52
- while test -e /Users/drone /.cocoapods_cache.lock; do
48
+ while test -e /Users/$USER /.cocoapods_cache.lock; do
53
49
sleep 1
54
50
LOOP_BREAK=$((LOOP_BREAK + 1))
55
51
56
52
if [[ $LOOP_BREAK -ge 600 ]]; then
57
- rm -f /Users/drone /.cocoapods_cache.lock
53
+ rm -f /Users/$USER /.cocoapods_cache.lock
58
54
fi
59
55
done
60
56
||| ,
61
- 'touch /Users/drone /.cocoapods_cache.lock' ,
57
+ 'touch /Users/$USER /.cocoapods_cache.lock' ,
62
58
|||
63
- if [[ -d /Users/drone /.cocoapods_cache ]]; then
64
- cp -r /Users/drone /.cocoapods_cache ./Pods
59
+ if [[ -d /Users/$USER /.cocoapods_cache ]]; then
60
+ cp -r /Users/$USER /.cocoapods_cache ./Pods
65
61
fi
66
62
||| ,
67
- 'rm -f /Users/drone /.cocoapods_cache.lock'
63
+ 'rm -f /Users/$USER /.cocoapods_cache.lock' ,
68
64
],
69
65
depends_on: [
70
- 'Clone Submodules'
71
- ]
66
+ 'Clone Submodules' ,
67
+ ],
72
68
};
73
69
74
70
// Override the cached CocoaPods directory (to speed up the next build)
@@ -77,107 +73,125 @@ local update_cocoapods_cache(depends_on) = {
77
73
commands: [
78
74
|||
79
75
LOOP_BREAK=0
80
- while test -e /Users/drone /.cocoapods_cache.lock; do
76
+ while test -e /Users/$USER /.cocoapods_cache.lock; do
81
77
sleep 1
82
78
LOOP_BREAK=$((LOOP_BREAK + 1))
83
79
84
80
if [[ $LOOP_BREAK -ge 600 ]]; then
85
- rm -f /Users/drone /.cocoapods_cache.lock
81
+ rm -f /Users/$USER /.cocoapods_cache.lock
86
82
fi
87
83
done
88
84
||| ,
89
- 'touch /Users/drone /.cocoapods_cache.lock' ,
85
+ 'touch /Users/$USER /.cocoapods_cache.lock' ,
90
86
|||
91
87
if [[ -d ./Pods ]]; then
92
- rm -rf /Users/drone/.cocoapods_cache
93
- cp -r ./Pods /Users/drone/.cocoapods_cache
88
+ rsync -a --delete ./Pods/ /Users/$USER/.cocoapods_cache
94
89
fi
95
90
||| ,
96
- 'rm -f /Users/drone /.cocoapods_cache.lock'
91
+ 'rm -f /Users/$USER /.cocoapods_cache.lock' ,
97
92
],
98
93
depends_on: depends_on,
99
94
};
100
95
96
+ local boot_simulator(device_type) = {
97
+ name: 'Boot Test Simulator' ,
98
+ commands: [
99
+ 'devname="Test-iPhone-${DRONE_COMMIT:0:9}-${DRONE_BUILD_EVENT}"' ,
100
+ 'xcrun simctl create "$devname" ' + device_type,
101
+ 'sim_uuid=$(xcrun simctl list devices -je | jq -re \' [.devices[][] | select(.name == "\' $devname\' ").udid][0]\' )' ,
102
+ 'xcrun simctl boot $sim_uuid' ,
103
+
104
+ 'mkdir -p build/artifacts' ,
105
+ 'echo $sim_uuid > ./build/artifacts/sim_uuid' ,
106
+ 'echo $devname > ./build/artifacts/device_name' ,
107
+
108
+ 'xcrun simctl list -je devices $sim_uuid | jq -r \' .devices[][0] | "\\ u001b[32;1mSimulator " + .state + ": \\ u001b[34m" + .name + " (\\ u001b[35m" + .deviceTypeIdentifier + ", \\ u001b[36m" + .udid + "\\ u001b[34m)\\ u001b[0m"\' ' ,
109
+ ],
110
+ };
111
+ local sim_keepalive = {
112
+ name: '(Simulator keep-alive)' ,
113
+ commands: [
114
+ '/Users/$USER/sim-keepalive/keepalive.sh $(<./build/artifacts/sim_uuid)' ,
115
+ ],
116
+ depends_on: ['Boot Test Simulator' ],
117
+ };
118
+ local sim_delete_cmd = 'if [ -f build/artifacts/sim_uuid ]; then rm -f /Users/$USER/sim-keepalive/$(<./build/artifacts/sim_uuid); fi' ;
119
+
101
120
[
102
121
// Unit tests (PRs only)
103
122
{
104
123
kind: 'pipeline' ,
105
124
type: 'exec' ,
106
125
name: 'Unit Tests' ,
107
- platform: { os: 'darwin' , arch: 'amd64 ' },
108
- trigger: { event: { exclude: [ 'push' ] } },
126
+ platform: { os: 'darwin' , arch: 'arm64 ' },
127
+ trigger: { event: { exclude: ['push' ] } },
109
128
steps: [
110
129
version_info,
111
130
clone_submodules,
112
131
load_cocoapods_cache,
113
132
install_cocoapods,
114
- {
115
- name: 'Pre-Boot Test Simulator' ,
116
- commands: [
117
- 'mkdir -p build/artifacts' ,
118
- 'echo "Test-iPhone14-${DRONE_COMMIT:0:9}-${DRONE_BUILD_EVENT}" > ./build/artifacts/device_name' ,
119
- 'xcrun simctl create "$(cat ./build/artifacts/device_name)" com.apple.CoreSimulator.SimDeviceType.iPhone-14' ,
120
- 'echo $(xcrun simctl list devices | grep -m 1 $(cat ./build/artifacts/device_name) | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})") > ./build/artifacts/sim_uuid' ,
121
- 'xcrun simctl boot $(cat ./build/artifacts/sim_uuid)' ,
122
- 'echo "[32mPre-booting simulator complete: $(xcrun simctl list | sed "s/^[[:space:]]*//" | grep -o ".*$(cat ./build/artifacts/sim_uuid).*")[0m"' ,
123
- ]
124
- },
133
+
134
+ boot_simulator('com.apple.CoreSimulator.SimDeviceType.iPhone-15' ),
135
+ sim_keepalive,
125
136
{
126
137
name: 'Build and Run Tests' ,
127
138
commands: [
128
- 'NSUnbufferedIO=YES set -o pipefail && xcodebuild test -workspace Session.xcworkspace -scheme Session -derivedDataPath ./build/derivedData -resultBundlePath ./build/artifacts/testResults.xcresult -parallelizeTargets -destination "platform=iOS Simulator,id=$(cat ./build/artifacts/sim_uuid)" -parallel-testing-enabled NO -test-timeouts-enabled YES -maximum-test-execution-time-allowance 10 -collect-test-diagnostics never 2>&1 | xcbeautify --is-ci' ,
139
+ 'NSUnbufferedIO=YES set -o pipefail && xcodebuild test -workspace Session.xcworkspace -scheme Session -derivedDataPath ./build/derivedData -resultBundlePath ./build/artifacts/testResults.xcresult -parallelizeTargets -destination "platform=iOS Simulator,id=$(< ./build/artifacts/sim_uuid)" -parallel-testing-enabled NO -test-timeouts-enabled YES -maximum-test-execution-time-allowance 10 -collect-test-diagnostics never 2>&1 | xcbeautify --is-ci' ,
129
140
],
130
141
depends_on: [
131
- 'Pre- Boot Test Simulator' ,
132
- 'Install CocoaPods'
142
+ 'Boot Test Simulator' ,
143
+ 'Install CocoaPods' ,
133
144
],
134
145
},
135
146
{
136
147
name: 'Unit Test Summary' ,
137
148
commands: [
138
- 'xcresultparser --output-format cli --failed-tests-only ./build/artifacts/testResults.xcresult' ,
149
+ sim_delete_cmd,
150
+ |||
151
+ if [[ -d ./build/artifacts/testResults.xcresult ]]; then
152
+ xcresultparser --output-format cli --failed-tests-only ./build/artifacts/testResults.xcresult
153
+ else
154
+ echo -e "\n\n\n\e[31;1mUnit test results not found\e[0m"
155
+ fi
156
+ ||| ,
139
157
],
140
158
depends_on: ['Build and Run Tests' ],
141
159
when: {
142
- status: ['failure' , 'success' ]
143
- }
144
- },
145
- {
146
- name: 'Delete Test Simulator' ,
147
- commands: [
148
- 'xcrun simctl delete $(cat ./build/artifacts/sim_uuid)'
149
- ],
150
- depends_on: [
151
- 'Build and Run Tests' ,
152
- ],
153
- when: {
154
- status: ['failure' , 'success' ]
155
- }
160
+ status: ['failure' , 'success' ],
161
+ },
156
162
},
157
163
update_cocoapods_cache(['Build and Run Tests' ]),
158
164
{
159
165
name: 'Install Codecov CLI' ,
160
166
commands: [
167
+ 'mkdir -p build/artifacts' ,
161
168
'pip3 install codecov-cli' ,
162
- '~/Library/Python/3.9/bin/codecovcli --version'
169
+ 'find $HOME/Library/Python -name codecovcli -print -quit > ./build/artifacts/codecov_path' ,
170
+ |||
171
+ if [[ ! -s ./build/artifacts/codecov_path ]]; then
172
+ which codecovcli > ./build/artifacts/codecov_path
173
+ fi
174
+ ||| ,
175
+ '$(<./build/artifacts/codecov_path) --version' ,
163
176
],
164
177
},
165
178
{
166
179
name: 'Convert xcresult to xml' ,
167
180
commands: [
168
181
'xcresultparser --output-format cobertura ./build/artifacts/testResults.xcresult > ./build/artifacts/coverage.xml' ,
169
182
],
170
- depends_on: ['Build and Run Tests' ]
183
+ depends_on: ['Build and Run Tests' ],
171
184
},
172
185
{
186
+ // No token needed for public repos
173
187
name: 'Upload coverage to Codecov' ,
174
188
commands: [
175
- '~/Library/Python/3.9/bin/codecovcli upload-process --fail-on-error -f ./build/artifacts/coverage.xml' ,
189
+ '$(<./build/artifacts/codecov_path) upload-process --fail-on-error -f ./build/artifacts/coverage.xml' ,
176
190
],
177
191
depends_on: [
178
192
'Convert xcresult to xml' ,
179
- 'Install Codecov CLI'
180
- ]
193
+ 'Install Codecov CLI' ,
194
+ ],
181
195
},
182
196
],
183
197
},
@@ -186,24 +200,24 @@ local update_cocoapods_cache(depends_on) = {
186
200
kind: 'pipeline' ,
187
201
type: 'exec' ,
188
202
name: 'Check Build Artifact Existence' ,
189
- platform: { os: 'darwin' , arch: 'amd64 ' },
190
- trigger: { event: { exclude: [ 'push' ] } },
203
+ platform: { os: 'darwin' , arch: 'arm64 ' },
204
+ trigger: { event: { exclude: ['push' ] } },
191
205
steps: [
192
206
{
193
207
name: 'Poll for build artifact existence' ,
194
208
commands: [
195
- './Scripts/drone-upload-exists.sh'
196
- ]
197
- }
198
- ]
209
+ './Scripts/drone-upload-exists.sh' ,
210
+ ],
211
+ },
212
+ ],
199
213
},
200
214
// Simulator build (non-PRs only)
201
215
{
202
216
kind: 'pipeline' ,
203
217
type: 'exec' ,
204
218
name: 'Simulator Build' ,
205
- platform: { os: 'darwin' , arch: 'amd64 ' },
206
- trigger: { event: { exclude: [ 'pull_request' ] } },
219
+ platform: { os: 'darwin' , arch: 'arm64 ' },
220
+ trigger: { event: { exclude: ['pull_request' ] } },
207
221
steps: [
208
222
version_info,
209
223
clone_submodules,
@@ -213,22 +227,22 @@ local update_cocoapods_cache(depends_on) = {
213
227
name: 'Build' ,
214
228
commands: [
215
229
'mkdir build' ,
216
- 'xcodebuild archive -workspace Session.xcworkspace -scheme Session -derivedDataPath ./build/derivedData -parallelizeTargets -configuration "App Store Release" -sdk iphonesimulator -archivePath ./build/Session_sim.xcarchive -destination "generic/platform=iOS Simulator" | xcbeautify --is-ci'
230
+ 'NSUnbufferedIO=YES set -o pipefail && xcodebuild archive -workspace Session.xcworkspace -scheme Session -derivedDataPath ./build/derivedData -parallelizeTargets -configuration "App Store Release" -sdk iphonesimulator -archivePath ./build/Session_sim.xcarchive -destination "generic/platform=iOS Simulator" | xcbeautify --is-ci' ,
217
231
],
218
232
depends_on: [
219
- 'Install CocoaPods'
233
+ 'Install CocoaPods' ,
220
234
],
221
235
},
222
236
update_cocoapods_cache(['Build' ]),
223
237
{
224
238
name: 'Upload artifacts' ,
225
239
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
226
240
commands: [
227
- './Scripts/drone-static-upload.sh'
241
+ './Scripts/drone-static-upload.sh' ,
228
242
],
229
243
depends_on: [
230
- 'Build'
231
- ]
244
+ 'Build' ,
245
+ ],
232
246
},
233
247
],
234
248
},
0 commit comments