Skip to content

Commit daeb716

Browse files
authored
chore(ci): Add required checks job for build (#5997)
1 parent 9cbff30 commit daeb716

File tree

2 files changed

+83
-15
lines changed

2 files changed

+83
-15
lines changed

.github/file-filters.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,27 @@ run_lint_xcode_analyze_for_prs: &run_lint_xcode_analyze_for_prs # Xcode linting
191191
- "Sentry.xcodeproj/**"
192192
- "*.podspec"
193193
- "Gemfile.lock"
194+
195+
run_build_for_prs: &run_build_for_prs # Build-related code
196+
- "Sources/**"
197+
- "test-server/**"
198+
- "Samples/**"
199+
200+
# GH Actions
201+
- ".github/workflows/build.yml"
202+
- ".github/file-filters.yml"
203+
204+
# Project files
205+
- "Sentry.xcworkspace/**"
206+
- "Sentry.xcodeproj/**"
207+
- "Package*.swift"
208+
209+
# Scripts
210+
- "scripts/ci-select-xcode.sh"
211+
- "scripts/ci-diagnostics.sh"
212+
213+
# Other
214+
- "fastlane/**"
215+
- "Gemfile.lock"
216+
- "Makefile" # Make commands used for CI build setup
217+
- "Brewfile*" # Dependency installation affects build environment

.github/workflows/build.yml

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,6 @@ on:
66
- release/**
77

88
pull_request:
9-
paths:
10-
- "Sources/**"
11-
- "test-server/**"
12-
- "Samples/**"
13-
- ".github/workflows/build.yml"
14-
- "fastlane/**"
15-
- "scripts/ci-select-xcode.sh"
16-
- "scripts/ci-diagnostics.sh"
17-
- Sentry.xcworkspace/**
18-
- Sentry.xcodeproj/**
19-
- Gemfile.lock
20-
- "Package*.swift"
21-
- "Makefile" # Make commands used for CI build setup
22-
- "Brewfile*" # Dependency installation affects build environment
239

2410
# Concurrency configuration:
2511
# - We use workflow-specific concurrency groups to prevent multiple build runs of the same code,
@@ -33,10 +19,27 @@ concurrency:
3319
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
3420

3521
jobs:
22+
files-changed:
23+
name: Detect File Changes
24+
runs-on: ubuntu-latest
25+
outputs:
26+
run_build_for_prs: ${{ steps.changes.outputs.run_build_for_prs }}
27+
steps:
28+
- uses: actions/checkout@v5
29+
- name: Get changed files
30+
id: changes
31+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
32+
with:
33+
token: ${{ github.token }}
34+
filters: .github/file-filters.yml
35+
3636
# We had issues that the release build was broken on main.
3737
# With this we catch potential issues already in the PR.
3838
ios-swift-release:
3939
name: Release Build of iOS Swift
40+
# Run the job only for PRs with related changes or non-PR events.
41+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
42+
needs: files-changed
4043
runs-on: macos-15
4144
steps:
4245
- uses: actions/checkout@v5
@@ -63,6 +66,8 @@ jobs:
6366

6467
build-sample:
6568
name: Sample ${{ matrix.scheme }} ${{ matrix.config }}
69+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
70+
needs: files-changed
6671
runs-on: macos-15
6772
strategy:
6873
fail-fast: false
@@ -127,7 +132,8 @@ jobs:
127132
name: Build with SPM
128133
runs-on: macos-15
129134
# Don't run this on release branches, cause the SPM Package.swift points to the unreleased versions.
130-
if: startsWith(github.ref, 'refs/heads/release/') == false
135+
if: startsWith(github.ref, 'refs/heads/release/') == false && (github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true')
136+
needs: files-changed
131137
steps:
132138
- uses: actions/checkout@v5
133139

@@ -154,6 +160,8 @@ jobs:
154160

155161
build-v9:
156162
name: Build SDK v9
163+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
164+
needs: files-changed
157165
runs-on: macos-15
158166
steps:
159167
- uses: actions/checkout@v5
@@ -178,6 +186,8 @@ jobs:
178186

179187
check-debug-without-UIKit:
180188
name: Check no UIKit linkage (DebugWithoutUIKit)
189+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
190+
needs: files-changed
181191
runs-on: macos-14
182192
steps:
183193
- uses: actions/checkout@v5
@@ -201,6 +211,8 @@ jobs:
201211

202212
check-release-without-UIKit:
203213
name: Check no UIKit linkage (ReleaseWithoutUIKit)
214+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
215+
needs: files-changed
204216
runs-on: macos-14
205217
steps:
206218
- uses: actions/checkout@v5
@@ -224,6 +236,8 @@ jobs:
224236

225237
check-debug-with-UIKit:
226238
name: Check UIKit linkage (Debug)
239+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
240+
needs: files-changed
227241
runs-on: macos-14
228242
steps:
229243
- uses: actions/checkout@v5
@@ -247,6 +261,8 @@ jobs:
247261

248262
check-release-with-UIKit:
249263
name: Check UIKit linkage (Release)
264+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
265+
needs: files-changed
250266
runs-on: macos-14
251267
steps:
252268
- uses: actions/checkout@v5
@@ -274,6 +290,8 @@ jobs:
274290

275291
check-compiling-async-safe-logs:
276292
name: Check compiling Async Safe Logs
293+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_build_for_prs == 'true'
294+
needs: files-changed
277295
runs-on: macos-15
278296
steps:
279297
- uses: actions/checkout@v5
@@ -302,3 +320,29 @@ jobs:
302320
- name: Debug Xcode environment
303321
if: ${{ failure() || cancelled() }}
304322
run: ./scripts/ci-diagnostics.sh
323+
324+
build-required-check:
325+
needs:
326+
[
327+
files-changed,
328+
ios-swift-release,
329+
build-sample,
330+
build-spm,
331+
build-v9,
332+
check-debug-without-UIKit,
333+
check-release-without-UIKit,
334+
check-debug-with-UIKit,
335+
check-release-with-UIKit,
336+
check-compiling-async-safe-logs,
337+
]
338+
name: Build
339+
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
340+
if: always()
341+
runs-on: ubuntu-latest
342+
steps:
343+
# If any jobs we depend on fails gets cancelled or times out, this job will fail.
344+
# Skipped jobs are not considered failures.
345+
- name: Check for failures
346+
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
347+
run: |
348+
echo "One of the build jobs has failed." && exit 1

0 commit comments

Comments
 (0)