Skip to content

Commit 7bd90de

Browse files
authored
chore(ci): Add required checks job for UI tests (#6035)
1 parent 4f24617 commit 7bd90de

File tree

2 files changed

+79
-20
lines changed

2 files changed

+79
-20
lines changed

.github/file-filters.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,36 @@ run_build_for_prs: &run_build_for_prs # Build-related code
310310
- "Gemfile.lock"
311311
- "Makefile" # Make commands used for CI build setup
312312
- "Brewfile*" # Dependency installation affects build environment
313+
314+
run_ui_tests_for_prs: &run_ui_tests_for_prs # UI Tests
315+
- "Sources/**"
316+
- "Tests/**"
317+
318+
# GH Actions
319+
- ".github/workflows/ui-tests.yml"
320+
- ".github/workflows/ui-tests-common.yml"
321+
- ".github/file-filters.yml"
322+
323+
# Scripts
324+
- "scripts/ci-select-xcode.sh"
325+
- "scripts/build-xcframework-slice.sh"
326+
- "scripts/assemble-xcframework.sh"
327+
- "scripts/ci-diagnostics.sh"
328+
329+
# Project files
330+
- "**/*.xctestplan"
331+
332+
# Samples
333+
- "Samples/iOS-SwiftUI/**"
334+
- "Samples/iOS-Swift/**"
335+
- "Samples/iOS-Swift6/**"
336+
- "Samples/SentrySampleShared/**"
337+
- "Samples/Shared/**"
338+
339+
# Other
340+
- "fastlane/**"
341+
- ".sauce/config.yml"
342+
- ".github/workflows/build-xcframework-variant-slices.yml"
343+
- ".github/workflows/assemble-xcframework-variant.yml"
344+
- "Makefile" # Make commands used for UI test environment setup
345+
- "Brewfile*" # Dependency installation affects UI test environment

.github/workflows/ui-tests.yml

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,6 @@ on:
55
- main
66

77
pull_request:
8-
paths:
9-
- "Sources/**"
10-
- "Tests/**"
11-
- ".github/workflows/ui-tests.yml"
12-
- ".github/workflows/ui-tests-common.yml"
13-
- "fastlane/**"
14-
- ".sauce/config.yml"
15-
- "scripts/ci-select-xcode.sh"
16-
- "**/*.xctestplan"
17-
- "Samples/iOS-SwiftUI/**"
18-
- "Samples/iOS-Swift/**"
19-
- "Samples/iOS-Swift6/**"
20-
- "Samples/SentrySampleShared/**"
21-
- "Samples/Shared/**"
22-
- "scripts/build-xcframework-slice.sh"
23-
- "scripts/assemble-xcframework.sh"
24-
- ".github/workflows/build-xcframework-variant-slices.yml"
25-
- ".github/workflows/assemble-xcframework-variant.yml"
26-
- "Makefile" # Make commands used for UI test environment setup
27-
- "Brewfile*" # Dependency installation affects UI test environment
288

299
# Concurrency configuration:
3010
# - We use workflow-specific concurrency groups to prevent multiple UI test runs on the same code,
@@ -38,7 +18,23 @@ concurrency:
3818
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
3919

4020
jobs:
21+
files-changed:
22+
name: Detect File Changes
23+
runs-on: ubuntu-latest
24+
outputs:
25+
run_ui_tests_for_prs: ${{ steps.changes.outputs.run_ui_tests_for_prs }}
26+
steps:
27+
- uses: actions/checkout@v5
28+
- name: Get changed files
29+
id: changes
30+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
31+
with:
32+
token: ${{ github.token }}
33+
filters: .github/file-filters.yml
34+
4135
ui-tests:
36+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_ui_tests_for_prs == 'true'
37+
needs: files-changed
4238
name: Test ${{matrix.name}} V3 # Up the version with every change to keep track of flaky tests
4339
uses: ./.github/workflows/ui-tests-common.yml
4440
strategy:
@@ -59,6 +55,8 @@ jobs:
5955

6056
# SwiftUI only supports iOS 14+ so we run it in a separate matrix here
6157
ui-tests-swift-ui:
58+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_ui_tests_for_prs == 'true'
59+
needs: files-changed
6260
name: Test SwiftUI V4 # Up the version with every change to keep track of flaky tests
6361
uses: ./.github/workflows/ui-tests-common.yml
6462
with:
@@ -72,6 +70,8 @@ jobs:
7270
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7371

7472
ui-tests-swift:
73+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_ui_tests_for_prs == 'true'
74+
needs: files-changed
7575
name: Test Swift ${{matrix.name}} V5 # Up the version with every change to keep track of flaky tests
7676
uses: ./.github/workflows/ui-tests-common.yml
7777
strategy:
@@ -102,6 +102,8 @@ jobs:
102102
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
103103

104104
ui-tests-swift6:
105+
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_ui_tests_for_prs == 'true'
106+
needs: files-changed
105107
name: Test iOS Swift6 V3 # Up the version with every change to keep track of flaky tests
106108
uses: ./.github/workflows/ui-tests-common.yml
107109
with:
@@ -113,3 +115,27 @@ jobs:
113115
codecov_test_analytics: true
114116
secrets:
115117
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
118+
119+
# This check validates that either UI tests passed or were skipped, which allows us
120+
# to make UI tests a required check with only running the UI tests when required.
121+
# So, we don't have to run UI tests, for example, for unrelated changes.
122+
ui_tests-required-check:
123+
needs:
124+
[
125+
files-changed,
126+
ui-tests,
127+
ui-tests-swift-ui,
128+
ui-tests-swift,
129+
ui-tests-swift6,
130+
]
131+
name: UI Tests
132+
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
133+
if: always()
134+
runs-on: ubuntu-latest
135+
steps:
136+
# If any jobs we depend on fails gets cancelled or times out, this job will fail.
137+
# Skipped jobs are not considered failures.
138+
- name: Check for failures
139+
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
140+
run: |
141+
echo "One of the UI test jobs has failed." && exit 1

0 commit comments

Comments
 (0)