-
-
Notifications
You must be signed in to change notification settings - Fork 334
248 lines (217 loc) · 8.49 KB
/
ios-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
name: ios-ci
on:
workflow_dispatch:
inputs:
release:
required: false
type: boolean
description: Makes a release with version platform/ios/VERSION
push:
branches:
- main
tags:
- 'ios-*'
pull_request:
branches:
- '*'
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: github.event_name != 'workflow_dispatch' && steps.changed-files-yaml.outputs.ios_any_changed != 'true'
steps:
- uses: actions/checkout@v4
if: github.event_name == 'push'
- name: Get all iOS files that have changed
if: github.event_name != 'workflow_dispatch'
id: changed-files-yaml
uses: tj-actions/changed-files@v39
with:
files_yaml: |
ios:
- 'platform/ios/**'
- 'platform/darwin/**'
- '.github/workflows/ios-ci.yml'
- 'bin/**'
- 'expression-test/**'
- 'include/**'
- 'metrics/**'
- 'platform/default/**'
- 'render-test/**'
- 'scripts/**'
- 'src/**'
- 'test/**'
- 'vendor/**'
- '.gitmodules'
- '!**/*.md'
- 'WORKSPACE'
- 'BUILD.bazel'
- '.bazelrc'
- '.bazelversion'
- name: Run step if test file(s) change
if: steps.changed-files-yaml.outputs.ios_any_changed == 'true'
run: |
echo "One or more iOS file(s) has changed."
echo "List of changes: ${{ steps.changed-files-yaml.outputs.ios_all_changed_files }}"
ios-build:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
strategy:
fail-fast: false
matrix:
renderer: [legacy, drawable, metal]
runs-on: [self-hosted, macOS, ARM64]
concurrency:
# cancel jobs on PRs only
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.renderer }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
BUILDTYPE: Debug
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
defaults:
run:
working-directory: platform/ios
shell: bash
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: /user/local/lib/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache Bazel
uses: actions/cache@v3
with:
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
path: ~/.cache/bazel
- uses: actions/setup-node@v3
with:
node-version: 18
- name: npm install
run: npm ci --ignore-scripts
- run: cp bazel/example_config.bzl bazel/config.bzl
- name: Check debug symbols
run: bazel run //platform:check-public-symbols --//:renderer=${{ matrix.renderer }}
- name: Lint plist files
run: bazel run //platform/ios:lint-plists --//:renderer=${{ matrix.renderer }}
- name: Running iOS tests
if: matrix.renderer != 'metal'
run: bazel test //platform/ios/test:ios_test --test_output=errors --//:renderer=${{ matrix.renderer }}
- name: Running iOS UI tests
run: bazel test //platform/ios/iosapp-UITests:uitest --test_output=errors --//:renderer=${{ matrix.renderer }}
# size test
- name: Build app for size test & output size
if: matrix.renderer == 'legacy'
working-directory: ./
run: |
bazel build --compilation_mode=opt //platform/ios:size --//:maplibre_platform=ios
cp "$(bazel cquery --compilation_mode=opt --output=files //platform/ios:size --//:maplibre_platform=ios)" ./size
- name: Upload size test result
if: matrix.renderer == 'legacy'
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: size-test-result
path: |
./size
# render test
- name: Build RenderTest .ipa and .xctest for AWS Device Farm
if: matrix.renderer == 'legacy'
run: |
set -e
bazel run //platform/ios:xcodeproj
build_dir="$(mktemp -d)"
xcodebuild build-for-testing -scheme RenderTest -project MapLibre.xcodeproj -derivedDataPath "$build_dir"
render_test_app_dir="$(dirname "$(find "$build_dir" -name RenderTestApp.app)")"
cd "$render_test_app_dir"
mkdir Payload
mv RenderTestApp.app Payload
zip -r RenderTestApp.zip Payload
mv RenderTestApp.zip RenderTestApp.ipa
cd Payload/RenderTestApp.app/PlugIns
zip -r "$render_test_app_dir"/RenderTest.xctest.zip RenderTest.xctest
echo render_test_artifacts_dir="$render_test_app_dir" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v3
if: matrix.renderer == 'legacy'
with:
name: ios-render-test
retention-days: 3
if-no-files-found: error
path: |
${{ env.render_test_artifacts_dir }}/RenderTest.xctest.zip
${{ env.render_test_artifacts_dir }}/RenderTestApp.ipa
# C++ unit tests
- name: Build CppUnitTests .ipa and .xctest for AWS Device Farm
if: matrix.renderer == 'legacy'
run: |
set -e
bazel run //platform/ios:xcodeproj
build_dir="$(mktemp -d)"
xcodebuild build-for-testing -scheme CppUnitTests -project MapLibre.xcodeproj -derivedDataPath "$build_dir"
ios_cpp_test_app_dir="$(dirname "$(find "$build_dir" -name CppUnitTestsApp.app)")"
cd "$ios_cpp_test_app_dir"
mkdir Payload
mv CppUnitTestsApp.app Payload
zip -r CppUnitTestsApp.zip Payload
mv CppUnitTestsApp.zip CppUnitTestsApp.ipa
cd Payload/CppUnitTestsApp.app/PlugIns
zip -r "$ios_cpp_test_app_dir"/CppUnitTests.xctest.zip CppUnitTests.xctest
echo ios_cpp_test_artifacts_dir="$ios_cpp_test_app_dir" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v3
if: matrix.renderer == 'legacy'
with:
name: ios-cpp-unit-tests
retention-days: 3
if-no-files-found: error
path: |
${{ env.ios_cpp_test_artifacts_dir }}/CppUnitTests.xctest.zip
${{ env.ios_cpp_test_artifacts_dir }}/CppUnitTestsApp.ipa
# Make Metal XCFramework release
- name: Should make release?
if: ${{ github.ref == 'refs/heads/main' && matrix.renderer == 'metal' }}
run: echo make_release=true >> "$GITHUB_ENV"
- name: Build XCFramework
run: |
bazel build --compilation_mode=opt --//:renderer=${{ matrix.renderer }} --//:maplibre_platform=ios //platform/ios:MapLibre.dynamic
echo xcframework="$(bazel info execution_root)"/"$(bazel cquery --output=files --compilation_mode=opt --//:renderer=${{ matrix.renderer }} --//:maplibre_platform=ios //platform/ios:MapLibre.dynamic)" >> "$GITHUB_ENV"
- name: Get version (release)
if: env.make_release && github.event.inputs.release
run: echo version="$(cat VERSION)" >> "$GITHUB_ENV"
- name: Get version (pre-release)
if: env.make_release && !github.event.inputs.release
run: echo version="$(cat VERSION)"-pre${{ github.sha }} >> "$GITHUB_ENV"
- name: Create tag
if: env.make_release
run: |
git tag -a ios-v${{ env.version }} -m "Publish ios-v${{ env.version }}" ${{ github.sha }}
git push origin ios-v${{ env.version }}
- name: Release
if: env.make_release
uses: softprops/action-gh-release@v1
with:
name: ios-v${{ env.version }}
files: ${{ env.xcframework }}
tag_name: ios-v${{ env.version }}
prerelease: ${{ !github.event.inputs.release }}
ios-ci-result:
runs-on: ubuntu-latest
if: needs.pre_job.outputs.should_skip != 'true' && always()
needs:
- pre_job
- ios-build
steps:
- name: Mark result as failed
if: needs.ios-build.result != 'success'
run: exit 1