Skip to content

Commit f45ead6

Browse files
[CI] Snapshots recording improvement (#752)
1 parent 5a7e399 commit f45ead6

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Record Snapshots
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
remove_and_record_snapshots:
7+
description: 'Reset all the snapshots on CI?'
8+
type: boolean
9+
required: false
10+
default: false
11+
12+
jobs:
13+
record:
14+
name: Record
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/[email protected]
18+
- run: gh workflow run smoke-checks.yml --ref "${GITHUB_REF#refs/heads/}" -f record_snapshots=true -f remove_and_record_snapshots=${{ github.event.inputs.remove_and_record_snapshots }}
19+
timeout-minutes: 5
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/smoke-checks.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ on:
88

99
workflow_dispatch:
1010
inputs:
11-
snapshots:
12-
description: 'Should Snapshots be recorded on CI?'
11+
record_snapshots:
12+
description: 'Record missing snapshots on CI?'
13+
type: boolean
14+
required: false
15+
default: false
16+
remove_and_record_snapshots:
17+
description: 'Reset all the snapshots on CI?'
1318
type: boolean
1419
required: false
1520
default: false
@@ -47,7 +52,7 @@ jobs:
4752
automated-code-review:
4853
name: Automated Code Review
4954
runs-on: macos-15
50-
if: ${{ github.event.inputs.snapshots != 'true' }}
55+
if: ${{ github.event.inputs.record_snapshots != 'true' && github.event.inputs.remove_and_record_snapshots != 'true' }}
5156
env:
5257
XCODE_VERSION: "15.4"
5358
steps:
@@ -66,7 +71,7 @@ jobs:
6671
build-xcode15:
6772
name: Build SDKs (Xcode 15.0)
6873
runs-on: macos-15
69-
if: ${{ github.event.inputs.snapshots != 'true' }}
74+
if: ${{ github.event.inputs.record_snapshots != 'true' && github.event.inputs.remove_and_record_snapshots != 'true' }}
7075
env:
7176
XCODE_VERSION: "15.4"
7277
steps:
@@ -99,7 +104,7 @@ jobs:
99104
INSTALL_YEETD: true
100105
INSTALL_SONAR: true
101106
- name: Run UI Tests (Debug)
102-
run: bundle exec fastlane test_ui device:"${{ env.IOS_SIMULATOR_DEVICE }}" record:${{ github.event.inputs.snapshots }}
107+
run: bundle exec fastlane test_ui device:"${{ env.IOS_SIMULATOR_DEVICE }}" record:"${{ github.event.inputs.record_snapshots }}" remove_and_record:"${{ github.event.inputs.remove_and_record_snapshots }}"
103108
timeout-minutes: 120
104109
env:
105110
GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }} # to open a PR
@@ -134,7 +139,7 @@ jobs:
134139
allure_testops_launch:
135140
name: Launch Allure TestOps
136141
runs-on: macos-13
137-
if: ${{ github.event.inputs.snapshots != 'true' }}
142+
if: ${{ github.event.inputs.record_snapshots != 'true' && github.event.inputs.remove_and_record_snapshots != 'true' }}
138143
needs: build-test-app-and-frameworks
139144
outputs:
140145
launch_id: ${{ steps.get_launch_id.outputs.launch_id }}
@@ -153,7 +158,7 @@ jobs:
153158
test-e2e-debug:
154159
name: Test E2E UI (Debug)
155160
runs-on: macos-15
156-
if: ${{ github.event.inputs.snapshots != 'true' }}
161+
if: ${{ github.event.inputs.record_snapshots != 'true' && github.event.inputs.remove_and_record_snapshots != 'true' }}
157162
needs:
158163
- allure_testops_launch
159164
- build-test-app-and-frameworks
@@ -208,7 +213,7 @@ jobs:
208213
build-apps:
209214
name: Build Demo App
210215
runs-on: macos-14
211-
if: ${{ github.event.inputs.snapshots != 'true' }}
216+
if: ${{ github.event.inputs.record_snapshots != 'true' && github.event.inputs.remove_and_record_snapshots != 'true' }}
212217
needs: build-test-app-and-frameworks
213218
steps:
214219
- uses: actions/[email protected]

fastlane/Fastfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ desc 'Runs tests in Debug config'
222222
lane :test_ui do |options|
223223
next unless is_check_required(sources: sources_matrix[:ui], force_check: @force_check)
224224

225-
record_mode = !options[:record].to_s.empty?
226-
remove_snapshots if record_mode
225+
soft_record_mode = options[:record].to_s == 'true'
226+
hard_record_mode = options[:remove_and_record].to_s == 'true'
227+
record_mode = soft_record_mode || hard_record_mode
228+
remove_snapshots if hard_record_mode
227229

228230
update_testplan_on_ci(path: 'StreamChatSwiftUITests/Tests/StreamChatSwiftUI.xctestplan')
229231

@@ -257,7 +259,7 @@ lane :test_ui do |options|
257259
pr_create(
258260
title: '[CI] Snapshots',
259261
base_branch: current_branch,
260-
head_branch: "#{current_branch}-snapshots"
262+
head_branch: "#{current_branch}-snapshots-#{Time.now.to_i}"
261263
)
262264
else
263265
slather unless options[:build_for_testing]

0 commit comments

Comments
 (0)