-
-
Notifications
You must be signed in to change notification settings - Fork 385
513 lines (453 loc) · 20.6 KB
/
build.yml
File metadata and controls
513 lines (453 loc) · 20.6 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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
name: Build
on:
push:
branches:
- main
- v8.x
- release/**
pull_request:
types: [opened, synchronize, reopened, labeled]
# Concurrency configuration:
# - We use workflow-specific concurrency groups to prevent multiple build runs of the same code,
# which would waste CI resources without providing additional value.
# - For pull requests, we cancel in-progress builds when new commits are pushed since only the
# latest commit's build results matter for merge decisions.
# - For main branch pushes, we never cancel builds to ensure all release and sample builds complete,
# as broken builds on main could block releases and affect downstream consumers.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
ready-to-merge-gate:
name: Ready-to-merge gate
uses: ./.github/workflows/ready-to-merge-workflow.yml
files-changed:
name: Detect File Changes
runs-on: ubuntu-latest
needs: ready-to-merge-gate
outputs:
run_build_for_prs: ${{ steps.changes.outputs.run_build_for_prs }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Get changed files
id: changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
# We had issues that the release build was broken on main.
# With this we catch potential issues already in the PR.
ios-swift-release:
name: Release Build of iOS Swift
# Run the job for PRs with related changes (including external contributors) or non-PR events.
# Don't run this on release branches, cause the SPM Package.swift points to the unreleased versions.
if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true')
needs: files-changed
runs-on: macos-26
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
# As the DistributionSample project uses local SPM, xcodebuild resolves SPM dependencies for all
# sample projects. The Package.swift references binary targets, which in release branch commits points
# to non-existent download URLs. This creates chicken-egg failures when building these sample apps for
# a release commit build. When building these sample apps for a release commit, xcodebuild tries to
# resolve all SPM dependencies, including the binary targets pointing to these non-existent URLs. The
# sample projects don't use SPM for including Sentry. Only the DistributionSample uses local SPM.
# Therefore, we only keep the local DistributionSample reference in the Package.swift as a workaround.
- name: Only keep distribution lib and target in Package.swift
run: ./scripts/prepare-package.sh --remove-binary-targets true
- run: ./scripts/ci-select-xcode.sh 26.2
- name: Setup Ruby
uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
with:
bundler-cache: true
- run: make init-ci-build
- run: make xcode-ci
- name: Run Fastlane
# We only need to archive, not package the IPA, so we skip codesigning.
run: bundle exec fastlane build_ios_swift_without_codesigning
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
build-sample:
name: Sample ${{ matrix.scheme }} ${{ matrix.config }}
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
needs: files-changed
runs-on: macos-15
strategy:
fail-fast: false
matrix:
# other sample projects are built in ui-tests
include:
- scheme: watchOS-Swift WatchKit App
config: Debug
- scheme: macOS-SwiftUI
config: Debug
- scheme: SessionReplay-CameraTest
config: Debug
- scheme: iOS-Swift
config: Debug
- scheme: macOS-Swift
config: Debug
- scheme: tvOS-Swift
config: Debug
- scheme: visionOS-Swift
config: Debug
- scheme: iOS-SwiftUI
config: Debug
- scheme: iOS-ObjectiveC
config: Debug
- scheme: SPM
config: Debug
- scheme: DistributionSample
config: Debug
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
# As the DistributionSample project uses local SPM, xcodebuild resolves SPM dependencies for all
# sample projects. The Package.swift references binary targets, which in release branch commits points
# to non-existent download URLs. This creates chicken-egg failures when building these sample apps for
# a release commit build. When building these sample apps for a release commit, xcodebuild tries to
# resolve all SPM dependencies, including the binary targets pointing to these non-existent URLs. The
# sample projects don't use SPM for including Sentry. Only the DistributionSample uses local SPM.
# Therefore, we only keep the local DistributionSample reference in the Package.swift as a workaround.
- name: Only keep distribution lib and target in Package.swift
run: ./scripts/prepare-package.sh --remove-binary-targets true
- run: ./scripts/ci-select-xcode.sh 16.4
- run: make init-ci-build
- run: make xcode-ci
# Note: Due to complexity in implementing the CODE_SIGNING_ALLOWED flag in the sentry-xcodebuild.sh script,
# we did not yet migrate this step to use the script yet.
- run: |
set -o pipefail && NSUnbufferedIO=YES xcodebuild \
-workspace Sentry.xcworkspace \
-scheme '${{matrix.scheme}}' \
-configuration '${{matrix.config}}' \
CODE_SIGNING_ALLOWED="NO" \
build 2>&1 | tee raw-build-output.log | xcbeautify --preserve-unbeautified
- name: Archiving Raw Build Logs
uses: actions/upload-artifact@v7
if: ${{ failure() || cancelled() }}
with:
name: raw-build-output-scheme-${{matrix.scheme}}
path: |
raw-build-output.log
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
build-sample-spm:
name: Sample SPM ${{ matrix.name }}
# Don't run this on release branches, cause the SPM Package.swift points to the unreleased versions.
if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true')
needs: files-changed
runs-on: macos-26
strategy:
fail-fast: false
matrix:
include:
- name: iOS
make-target: build-sample-iOS-SwiftUI-SPM
- name: watchOS
make-target: build-sample-watchOS-SwiftUI-SPM
- name: tvOS
make-target: build-sample-tvOS-SwiftUI-SPM
- name: macOS
make-target: build-sample-macOS-SwiftUI-SPM
- name: visionOS
make-target: build-sample-visionOS-SwiftUI-SPM
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Select Xcode
run: ./scripts/ci-select-xcode.sh 26.2
- name: Install xcodegen
run: brew install xcodegen
- name: Build Sample
run: make ${{ matrix.make-target }}
env:
IOS_SIMULATOR_OS: latest
IOS_DEVICE_NAME: iPhone 17 Pro
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
check-macOS-CLI-Xcode-no-UI-framework:
name: macOS CLI (NoUIFramework) builds and has no AppKit/UIKit
# Don't run this on release branches, cause the SPM Package.swift points to the unreleased versions.
if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true')
needs: files-changed
runs-on: macos-26
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Select Xcode
run: ./scripts/ci-select-xcode.sh 26.4
- name: Build macOS-CLI-Xcode sample
run: |
set -o pipefail && xcodebuild \
-project "Samples/macOS-CLI-Xcode/macOS-CLI-Xcode.xcodeproj" \
-scheme macOS-CLI-Xcode \
-configuration Debug \
-destination 'platform=macOS' \
-derivedDataPath "$GITHUB_WORKSPACE/cli-xcode-build" \
CODE_SIGNING_ALLOWED="NO" build | xcbeautify --preserve-unbeautified
- name: Ensure CLI binary does not link AppKit
run: ./scripts/check-ui-framework-linkage.sh --configuration Debug --derived-data "$GITHUB_WORKSPACE/cli-xcode-build" --linkage unlinked --module macOS-CLI-Xcode --framework AppKit
- name: Ensure CLI binary does not link UIKit
run: ./scripts/check-ui-framework-linkage.sh --configuration Debug --derived-data "$GITHUB_WORKSPACE/cli-xcode-build" --linkage unlinked --module macOS-CLI-Xcode --framework UIKit
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
build-distribution:
name: Build the distribution framework
runs-on: macos-15
# Don't run this on release branches, cause the SPM Package.swift points to the unreleased versions.
if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true')
needs: files-changed
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- run: ./scripts/ci-select-xcode.sh 16.4
shell: sh
- run: rm -r Sentry.xcodeproj && rm -r Sentry.xcworkspace
- run: |
set -o pipefail && NSUnbufferedIO=YES xcodebuild \
-scheme SentryDistribution \
-sdk iphoneos \
-destination 'generic/platform=iphoneos' \
build | tee raw-build-output-spm.log | xcbeautify --preserve-unbeautified
shell: sh
- name: Upload SPM Build Logs
uses: actions/upload-artifact@v7
if: ${{ failure() || cancelled() }}
with:
name: raw-build-output-spm
path: |
raw-build-output-spm.log
build-spm:
name: Build with SPM
runs-on: macos-15
# Don't run this on release branches, cause the SPM Package.swift points to the unreleased versions.
if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true')
needs: files-changed
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- run: ./scripts/ci-select-xcode.sh 16.4
shell: sh
- run: rm -r Sentry.xcodeproj && rm -r Sentry.xcworkspace
- run: |
set -o pipefail && NSUnbufferedIO=YES xcodebuild \
-scheme SentrySPM \
-sdk watchos \
-destination 'generic/platform=watchOS' \
build | tee raw-build-output-spm-watchos.log | xcbeautify --preserve-unbeautified
shell: sh
- run: |
set -o pipefail && NSUnbufferedIO=YES xcodebuild \
-scheme SentrySPM \
-sdk iphoneos \
-destination 'generic/platform=iphoneos' \
build | tee raw-build-output-spm-iphoneos.log | xcbeautify --preserve-unbeautified
shell: sh
- name: Upload SPM Build Logs
uses: actions/upload-artifact@v7
if: ${{ failure() || cancelled() }}
with:
name: raw-build-output-spm
path: |
raw-build-output-spm-watchos.log
raw-build-output-spm-iphoneos.log
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
check-debug-without-UIKit:
name: Check no UIKit linkage (DebugWithoutUIKit)
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
needs: files-changed
runs-on: macos-15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- run: ./scripts/ci-select-xcode.sh 16.4
- name: Build for Debug
run: |
./scripts/sentry-xcodebuild.sh \
--platform iOS \
--os 18.5 \
--ref ${{ github.ref }} \
--command build \
--device "iPhone 16 Pro" \
--configuration DebugWithoutUIKit \
--derived-data uikit-check-build
- name: Ensure UIKit is not linked
run: ./scripts/check-ui-framework-linkage.sh --configuration DebugWithoutUIKit --derived-data uikit-check-build --linkage unlinked --module SentryWithoutUIKit
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
check-release-without-UIKit:
name: Check no UIKit linkage (ReleaseWithoutUIKit)
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
needs: files-changed
runs-on: macos-15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- run: ./scripts/ci-select-xcode.sh 16.4
- name: Build for Release
run: |
./scripts/sentry-xcodebuild.sh \
--platform iOS \
--os 18.5 \
--ref ${{ github.ref }} \
--command build \
--device "iPhone 16 Pro" \
--configuration ReleaseWithoutUIKit \
--derived-data uikit-check-build
- name: Ensure UIKit is not linked
run: ./scripts/check-ui-framework-linkage.sh --configuration ReleaseWithoutUIKit --derived-data uikit-check-build --linkage unlinked --module SentryWithoutUIKit
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
check-debug-with-UIKit:
name: Check UIKit linkage (Debug)
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
needs: files-changed
runs-on: macos-15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- run: ./scripts/ci-select-xcode.sh 16.4
- name: Build for Debug
run: |
./scripts/sentry-xcodebuild.sh \
--platform iOS \
--os 18.5 \
--ref ${{ github.ref }} \
--command build \
--device "iPhone 16 Pro" \
--configuration Debug \
--derived-data uikit-check-build
- name: Ensure UIKit is linked
run: ./scripts/check-ui-framework-linkage.sh --configuration Debug --derived-data uikit-check-build --linkage linked --module Sentry
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
check-release-with-UIKit:
name: Check UIKit linkage (Release)
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
needs: files-changed
runs-on: macos-15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- run: ./scripts/ci-select-xcode.sh 16.4
- name: Build for Release
run: |
./scripts/sentry-xcodebuild.sh \
--platform iOS \
--os 18.5 \
--ref ${{ github.ref }} \
--command build \
--device "iPhone 16 Pro" \
--configuration Release \
--derived-data uikit-check-build
- name: Ensure UIKit is linked
run: ./scripts/check-ui-framework-linkage.sh --configuration Release --derived-data uikit-check-build --linkage linked --module Sentry
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
check-release-with-AppKit:
name: Check AppKit linkage (Release)
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
needs: files-changed
runs-on: macos-15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- run: ./scripts/ci-select-xcode.sh 16.4
- name: Build for Release
run: |
./scripts/sentry-xcodebuild.sh \
--platform macOS \
--os 15.0 \
--ref ${{ github.ref }} \
--command build \
--configuration Release \
--derived-data appkit-check-build
- name: Ensure AppKit is linked
run: ./scripts/check-ui-framework-linkage.sh --configuration Release --derived-data appkit-check-build --linkage linked --module Sentry --framework AppKit
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
check-release-without-AppKit:
name: Check no AppKit linkage (ReleaseWithoutUIKit)
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
needs: files-changed
runs-on: macos-15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- run: ./scripts/ci-select-xcode.sh 16.4
- name: Build for Release
run: |
./scripts/sentry-xcodebuild.sh \
--platform macOS \
--os 15.0 \
--ref ${{ github.ref }} \
--command build \
--configuration ReleaseWithoutUIKit \
--derived-data no-appkit-check-build
- name: Ensure AppKit is not linked
run: ./scripts/check-ui-framework-linkage.sh --configuration ReleaseWithoutUIKit --derived-data no-appkit-check-build --linkage unlinked --module SentryWithoutUIKit --framework AppKit
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
# The compiler only evaluates SentryAsyncSafeLogs that get printed based on the SENTRY_ASYNC_SAFE_LOG_LEVEL.
# So if the level is set to error, which is the default, and a SENTRY_ASYNC_SAFE_LOG_DEBUG has a compiler error,
# you only get the compiler error when setting the SENTRY_ASYNC_SAFE_LOG_LEVEL to SENTRY_ASYNC_SAFE_LOG_LEVEL_DEBUG or lower.
check-compiling-async-safe-logs:
name: Check compiling Async Safe Logs
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
needs: files-changed
runs-on: macos-15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
# If the SentryAsyncSafeLog doesn't contain the SENTRY_ASYNC_SAFE_LOG_LEVEL_ERROR this fails.
- name: Async Safe Log Level is Error
run: grep -c "SENTRY_ASYNC_SAFE_LOG_LEVEL SENTRY_ASYNC_SAFE_LOG_LEVEL_ERROR" Sources/Sentry/SentryAsyncSafeLog.h
- name: Set Async Safe Log Level to Debug
run: |
sed -i '' 's/#define SENTRY_ASYNC_SAFE_LOG_LEVEL SENTRY_ASYNC_SAFE_LOG_LEVEL_ERROR/#define SENTRY_ASYNC_SAFE_LOG_LEVEL SENTRY_ASYNC_SAFE_LOG_LEVEL_TRACE/' Sources/Sentry/SentryAsyncSafeLog.h
shell: bash
- run: ./scripts/ci-select-xcode.sh 16.4
- name: Build for Debug
run: |
./scripts/sentry-xcodebuild.sh \
--platform iOS \
--os 18.5 \
--ref ${{ github.ref }} \
--command build \
--device "iPhone 16 Pro" \
--configuration Debug
- name: Debug Xcode environment
if: ${{ failure() || cancelled() }}
run: ./scripts/ci-diagnostics.sh
build-required-check:
needs:
[
files-changed,
ios-swift-release,
build-sample,
build-sample-spm,
check-macOS-CLI-Xcode-no-UI-framework,
build-distribution,
build-spm,
check-debug-without-UIKit,
check-release-without-UIKit,
check-debug-with-UIKit,
check-release-with-UIKit,
check-release-with-AppKit,
check-release-without-AppKit,
check-compiling-async-safe-logs,
ready-to-merge-gate,
]
name: Build
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
if: always()
runs-on: ubuntu-latest
steps:
# If any jobs we depend on fails gets cancelled or times out, this job will fail.
# Skipped jobs are not considered failures.
- name: Check for failures
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "One of the build jobs has failed." && exit 1