-
-
Notifications
You must be signed in to change notification settings - Fork 71
390 lines (323 loc) · 11.5 KB
/
build-test-and-docs.yml
File metadata and controls
390 lines (323 loc) · 11.5 KB
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
name: Build, test, and docs
on:
push:
branches-ignore:
- 'gh-pages'
pull_request:
branches-ignore:
- 'gh-pages'
workflow_dispatch:
jobs:
macos:
runs-on: macos-14
steps: # For swift-testing (everything else works with 5.10)
- name: Force Xcode 16.2
run: sudo xcode-select -switch /Applications/Xcode_16.2.app
- name: Swift version
run: swift --version
- uses: actions/checkout@v3
- name: Install Dependencies
run: brew install pkg-config gtk4 gtk+3 || echo "This step 'fails' every time but it's just a brew linking error - not important."
- name: Build SwiftCrossUI
run: swift build --target SwiftCrossUI
working-directory: ./Examples
- name: Build AppKitBackend and extract symbol graphs
uses: ./.github/actions/extract-symbol-graphs
with:
target: AppKitBackend
upload: true
working-directory: ./Examples
- name: Build other targets and examples
run: |
swift build --target GtkCodeGen && \
cd Examples && \
swift build --target GtkBackend && \
swift build --target Gtk3Backend && \
swift build --target CounterExample && \
swift build --target ControlsExample && \
swift build --target RandomNumberGeneratorExample && \
swift build --target WindowingExample && \
swift build --target GreetingGeneratorExample && \
swift build --target NavigationExample && \
swift build --target SplitExample && \
swift build --target StressTestExample && \
swift build --target SpreadsheetExample && \
swift build --target NotesExample && \
swift build --target GtkExample && \
swift build --target PathsExample
- name: Test
run: swift test --test-product swift-cross-uiPackageTests
uikit:
runs-on: macos-14
strategy:
matrix:
device-type:
- iPhone
- iPad
- TV
- Vision
steps:
- name: Force Xcode 15.4
run: sudo xcode-select -switch /Applications/Xcode_15.4.app
- name: Swift version
run: swift --version
- name: Install xcbeautify
run: brew install xcbeautify
- uses: actions/checkout@v3
- name: Build
run: |
set -uexo pipefail
device_type=${{ matrix.device-type }}
set +e
deviceid=$(xcrun simctl list devices $device_type available | grep -v -- -- | tail -n 1 | grep -oE '[0-9A-F\-]{36}')
if [ $? -eq 0 ]; then
(
buildtarget () {
# Use the same derived data path as DocC compilation so that we don't duplicate work.
xcodebuild -derivedDataPath /tmp/data -skipMacroValidation -scheme "$1" -destination "id=$deviceid" build | xcbeautify --renderer github-actions
}
buildtarget SwiftCrossUI
buildtarget UIKitBackend
cd Examples
buildtarget CounterExample
buildtarget GreetingGeneratorExample
buildtarget NavigationExample
buildtarget StressTestExample
buildtarget NotesExample
buildtarget PathsExample
if [ $device_type != TV ]; then
# Slider is not implemented for tvOS
buildtarget ControlsExample
buildtarget RandomNumberGeneratorExample
fi
if [ $device_type = iPad ]; then
# NavigationSplitView is only implemented for iPad
buildtarget SplitExample
fi
)
else
echo "No $device_type simulators found" >&2
fi
- name: Extract UIKitBackend symbol graphs
if: ${{ matrix.device-type == 'iPhone' }}
uses: ./.github/actions/extract-symbol-graphs
with:
target: UIKitBackend
upload: true
xcodebuild: true
xcodebuild-device-type: ${{ matrix.device-type }}
uikit-catalyst:
runs-on: macos-14
steps:
- name: Force Xcode 15.4
run: sudo xcode-select -switch /Applications/Xcode_15.4.app
- name: Swift version
run: swift --version
- name: Install xcbeautify
run: brew install xcbeautify
- uses: actions/checkout@v3
- name: Build
run: |
set -uxo pipefail
buildtarget () {
# Use the same derived data path as DocC compilation so that we don't duplicate work.
xcodebuild -derivedDataPath /tmp/data -skipMacroValidation -scheme "$1" -destination "variant=Mac Catalyst,arch=arm64,platform=macOS" build | xcbeautify --renderer github-actions
}
buildtarget SwiftCrossUI
buildtarget UIKitBackend
cd Examples
buildtarget CounterExample
buildtarget GreetingGeneratorExample
buildtarget NavigationExample
buildtarget StressTestExample
buildtarget NotesExample
buildtarget PathsExample
buildtarget ControlsExample
buildtarget RandomNumberGeneratorExample
# TODO test whether this works on Catalyst
# buildtarget SplitExample
windows:
runs-on: windows-latest
defaults:
run: # Use powershell because bash is not supported: https://github.com/compnerd/gha-setup-swift/issues/18#issuecomment-1705524890
shell: pwsh
steps:
- name: Setup VS Dev Environment
uses: seanmiddleditch/gha-setup-vsdevenv@v5
- name: Setup
uses: compnerd/gha-setup-swift@v0.3.0
with:
branch: swift-6.1-release
tag: 6.1-RELEASE
- name: Swift version
run: swift --version
- name: Compute vcpkg Triplet
id: triplet
uses: ASzc/change-string-case-action@v5
with:
string: ${{ runner.arch }}-${{ runner.os }}
- uses: actions/checkout@v3
- name: Restore Dependency Cache
id: cache
uses: actions/cache/restore@v3
with:
path: vcpkg_installed
key: vcpkg-${{ steps.triplet.outputs.lowercase }}-${{ hashFiles('vcpkg.json') }}
- name: Build and Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
env:
VCPKG_DEFAULT_TRIPLET: ${{ steps.triplet.outputs.lowercase }}
run: vcpkg install
- name: Save Dependency Cache
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: vcpkg_installed
key: vcpkg-${{ steps.triplet.outputs.lowercase }}-${{ hashFiles('vcpkg.json') }}
- name: Build SwiftCrossUI
env:
PKG_CONFIG_PATH: ${{ github.workspace }}/vcpkg_installed/${{ steps.triplet.outputs.lowercase }}/lib/pkgconfig
run: swift build --target SwiftCrossUI -v
- name: Build WinUIBackend and extract symbol graphs
uses: ./.github/actions/extract-symbol-graphs
with:
target: WinUIBackend
upload: true
linux:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
runs-on: ${{ matrix.os }}
steps:
# The Ubuntu image comes with Swift, but it's installed as root and DocC
# doesn't like that, so we install our own copy as a user.
# Related issue: https://github.com/swiftlang/swift-docc/issues/1136
- name: Install Swift
uses: SwiftyLab/setup-swift@latest
with:
swift-version: "6.1.0"
- name: Swift version
run: swift --version
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
sudo apt update && \
sudo apt install -y libgtk-4-dev libgtk-3-dev clang
- name: Build GtkCodeGen
run: swift build --target GtkCodeGen
- name: Build SwiftCrossUI
run: swift build --target SwiftCrossUI
working-directory: ./Examples
- name: Build GtkBackend and extract symbol graphs
if: ${{ matrix.os == 'ubuntu-24.04' }}
uses: ./.github/actions/extract-symbol-graphs
with:
target: GtkBackend
upload: true
working-directory: ./Examples
- name: Build GtkBackend
if: ${{ matrix.os != 'ubuntu-24.04' }}
run: swift build --target GtkBackend
working-directory: ./Examples
- name: Build Gtk3Backend and extract symbol graphs
if: ${{ matrix.os == 'ubuntu-24.04' }}
uses: ./.github/actions/extract-symbol-graphs
with:
target: Gtk3Backend
upload: true
working-directory: ./Examples
- name: Build Gtk3Backend
if: ${{ matrix.os != 'ubuntu-24.04' }}
run: swift build --target Gtk3Backend
working-directory: ./Examples
- name: Build examples
working-directory: ./Examples
run: |
swift build --target CounterExample && \
swift build --target ControlsExample && \
swift build --target RandomNumberGeneratorExample && \
swift build --target WindowingExample && \
swift build --target GreetingGeneratorExample && \
swift build --target NavigationExample && \
swift build --target SplitExample && \
swift build --target StressTestExample && \
swift build --target SpreadsheetExample && \
swift build --target NotesExample && \
swift build --target GtkExample
- name: Test
run: swift test --test-product swift-cross-uiPackageTests
update-docs:
runs-on: macos-15
needs: [macos, uikit, windows, linux]
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
steps:
- name: Setup Xcode version
uses: maxim-lobanov/setup-xcode@v1.6.0
with:
# Contains Swift 6.1. We need a recent DocC to have access to '--output-path'
# in the 'docc merge' command
xcode-version: '16.3'
- uses: actions/checkout@v3
- name: Swift Version
run: swift --version
- name: Compile SwiftCrossUI docs
uses: ./.github/actions/compile-docs
with:
target: SwiftCrossUI
use-swiftpm: true
- name: Compile AppKitBackend docs
uses: ./.github/actions/compile-docs
with:
target: AppKitBackend
use-symbol-graph-artifact: true
- name: Compile UIKitBackend docs
uses: ./.github/actions/compile-docs
with:
target: UIKitBackend
use-symbol-graph-artifact: true
- name: Compile GtkBackend docs
uses: ./.github/actions/compile-docs
with:
target: GtkBackend
use-symbol-graph-artifact: true
- name: Compile Gtk3Backend docs
uses: ./.github/actions/compile-docs
with:
target: Gtk3Backend
use-symbol-graph-artifact: true
- name: Compile WinUIBackend docs
uses: ./.github/actions/compile-docs
with:
target: WinUIBackend
use-symbol-graph-artifact: true
- name: Clone gh-pages branch
run: |
set -eux
git config user.email "stackotter@stackotter.dev"
git config user.name "stackotter"
git fetch
git worktree add --checkout gh-pages origin/gh-pages
- name: Merge DocC archives
run: |
rm -rf gh-pages/docs
xcrun docc merge \
SwiftCrossUI.doccarchive \
AppKitBackend.doccarchive \
UIKitBackend.doccarchive \
GtkBackend.doccarchive \
Gtk3Backend.doccarchive \
WinUIBackend.doccarchive \
--output-path gh-pages/docs
- name: Update docs if changed
run: |
set -eux
CURRENT_COMMIT_HASH=`git rev-parse --short HEAD`
cd gh-pages
git add docs
if [ -n "$(git status --porcelain)" ]; then
echo "Documentation changes found."
git commit -m "Update GitHub Pages documentation site to '$CURRENT_COMMIT_HASH'."
git push origin HEAD:gh-pages
else
echo "No documentation changes found."
fi