Skip to content

Commit

Permalink
Add CI step to build and test swift ui example using maestro
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Oct 3, 2024
1 parent 4eea4d1 commit 94da44e
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 4 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/eval-maestro-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: UI Tests
on:
push:
branches:
- main

pull_request:
paths:
- 'Sources/**'
- 'Tests/**'
- '.github/workflows/ui-tests.yml'
- 'fastlane/**'
- '.sauce/config.yml'
- 'scripts/ci-select-xcode.sh'
- 'Samples/iOS-Swift/**'


# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build-swift-ui:
name: Maestro Build SwiftUI for UI Tests Simulator
runs-on: macos-13

steps:
- uses: actions/checkout@v4
- run: ./scripts/ci-select-xcode.sh 14.3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec fastlane build_ios_swift_ui_for_tests
- uses: actions/upload-artifact@v4
with:
name: maestro-ios-swift-ui-for-tests
path: DerivedData/Build/Products/Debug-iphonesimulator/iOS-SwiftUI.app

eval-maestro-swift-ui-tests:
name: Maestro UI Tests for SwiftUI on ${{matrix.device}} Simulator
needs: [build-swift-ui]
runs-on: ${{matrix.runs-on}}
strategy:
fail-fast: false
matrix:
include:
# - runs-on: macos-12
# xcode: "13.4.1"

- runs-on: macos-13
xcode: "14.3"

steps:
- uses: actions/checkout@v4
- run: ./scripts/ci-select-xcode.sh ${{matrix.xcode}}
- run: which maestro || brew tap mobile-dev-inc/tap && brew install maestro
- run: brew tap facebook/fb && brew install idb-companion
- uses: actions/download-artifact@v4
with:
name: maestro-ios-swift-ui-for-tests
path: iOS-SwiftUI.app
- run: maestro start-device --platform ios --os-version 16
- run: maestro test crash.yaml
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
fail_fast: true
args:
- "check-versions"

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
Expand All @@ -20,6 +20,7 @@ repos:
- id: check-symlinks
- id: check-xml
- id: check-yaml
args: [--allow-multiple-documents]
- id: detect-private-key
- id: end-of-file-fixer
- id: no-commit-to-branch
Expand All @@ -30,7 +31,7 @@ repos:
- id: check-github-actions
- id: check-github-workflows
args: [--verbose]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
Expand All @@ -45,7 +46,7 @@ repos:
types_or: ["objective-c", "objective-c++", "c", "c++"]
args:
- "format-clang"

- id: format-swift
name: Format Swift
entry: make
Expand Down
19 changes: 18 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ platform :ios do
)
new_version = version.split("-", -1)[0]

# We also need to replace the MARKETING_VERSION otherwise the build will fail with
# We also need to replace the MARKETING_VERSION otherwise the build will fail with
# error: The CFBundleShortVersionString of an App Clip ('8.9.0-beta.1') must match that of its containing parent app ('8.9.0').
sh "sed -i '' 's/MARKETING_VERSION = #{version}/MARKETING_VERSION = #{new_version}/g' ../Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj"

Expand Down Expand Up @@ -120,6 +120,23 @@ platform :ios do
delete_keychain(name: "fastlane_tmp_keychain") unless is_ci
end

lane :build_ios_swift_ui_for_tests do

setup_ci(
force: true
)

build_app(
workspace: "Sentry.xcworkspace",
scheme: "iOS-SwiftUI",
configuration: "Debug",
derived_data_path: "DerivedData",
destination: "generic/platform=iOS Simulator",
xcargs: "-sdk 'iphonesimulator'",
skip_archive: true
)
end

lane :build_ios_swift_ui_test do

setup_ci(
Expand Down
5 changes: 5 additions & 0 deletions maestro/crash.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
appId: io.sentry.iOS-SwiftUI
---
- launchApp
- tapOn: "Crash"
- launchApp

0 comments on commit 94da44e

Please sign in to comment.