Skip to content

Commit

Permalink
[CI] Create PR with SwiftUI snapshots when required (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple authored Oct 16, 2023
1 parent 72a93f3 commit 65015d9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
18 changes: 2 additions & 16 deletions .github/workflows/smoke-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,11 @@ jobs:
path: |
~/Library/Logs/scan
fastlane/test_output/snapshots
- run: bundle exec fastlane remove_snapshots only_unchanged:true scheme:StreamVideoSwiftUI
if: ${{ github.event.inputs.record_snapshots == 'true' }}
- uses: actions/upload-artifact@v3
if: ${{ github.event.inputs.record_snapshots == 'true' }}
with:
name: SwiftUI Snapshots
path: StreamVideoSwiftUITests/**/__Snapshots__/**/*.png
test-uikit-debug:
name: Test UIKit (Debug)
runs-on: macos-13
if: ${{ github.event_name != 'push' }}
if: ${{ github.event_name != 'push' && github.event.inputs.record_snapshots != 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_NUM: ${{ github.event.number }}
Expand All @@ -167,7 +160,7 @@ jobs:
env:
INSTALL_YEETD: true
- name: Run UI Tests (Debug)
run: bundle exec fastlane test_uikit device:"${{ env.IOS_SIMULATOR_DEVICE }}" record:${{ github.event.inputs.record_snapshots }}
run: bundle exec fastlane test_uikit device:"${{ env.IOS_SIMULATOR_DEVICE }}"
timeout-minutes: 40
- name: Parse xcresult
if: failure()
Expand All @@ -181,13 +174,6 @@ jobs:
path: |
~/Library/Logs/scan
fastlane/test_output/snapshots
- run: bundle exec fastlane remove_snapshots only_unchanged:true scheme:StreamVideoUIKit
if: ${{ github.event.inputs.record_snapshots == 'true' }}
- uses: actions/upload-artifact@v3
if: ${{ github.event.inputs.record_snapshots == 'true' }}
with:
name: UIKit Snapshots
path: StreamVideoUIKitTests/**/__Snapshots__/**/*.png
build-apps:
name: Build Demo Apps
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ GEM
bundler
fastlane
pry
fastlane-plugin-stream_actions (0.3.23)
fastlane-plugin-stream_actions (0.3.24)
xctest_list (= 1.2.1)
fastlane-plugin-versioning (0.5.2)
ffi (1.16.2)
Expand Down Expand Up @@ -411,7 +411,7 @@ DEPENDENCIES
fastlane
fastlane-plugin-emerge
fastlane-plugin-lizard
fastlane-plugin-stream_actions (= 0.3.23)
fastlane-plugin-stream_actions (= 0.3.24)
fastlane-plugin-versioning
jazzy
json
Expand Down
20 changes: 20 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,26 @@ private_lane :test_ui do |options|
xcargs: buildcache_xcargs,
fail_build: options[:record].to_s.empty?
)

if options[:record] && is_ci
next unless sh('git status --porcelain').include?('__Snapshots__')

title = "[CI] #{options[:scheme]} Snapshots"
base = current_branch
head = "#{base}/snapshots"
sh("git checkout -b #{head}")
sh('git add -A')
sh("git commit -m '#{title}'")
push_to_git_remote(tags: false)
create_pull_request(
api_token: params[:github_token],
repo: params[:github_repo],
title: title,
head: head,
base: base,
body: 'This PR was created automatically by CI.'
)
end
end

desc 'Starts Sinatra web server'
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Pluginfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
gem 'fastlane-plugin-versioning'
gem 'fastlane-plugin-emerge'
gem 'fastlane-plugin-stream_actions', '0.3.23'
gem 'fastlane-plugin-stream_actions', '0.3.24'

0 comments on commit 65015d9

Please sign in to comment.