Skip to content

Update Codescanning for v7 #4085

Update Codescanning for v7

Update Codescanning for v7 #4085

Workflow file for this run

name: Tests
on: [pull_request]
concurrency:
group: tests-${{ github.event.number }}
cancel-in-progress: true
jobs:
unit_test_job:
name: Unit
runs-on: macos-15-xlarge
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Use Xcode 16.4
run: sudo xcode-select -switch /Applications/Xcode_16.4.0.app
- name: Install Package dependencies
run: swift package resolve
- name: Install CocoaPod dependencies
run: pod install
- name: Run Unit Tests
run: set -o pipefail && xcodebuild -workspace 'Braintree.xcworkspace' -sdk 'iphonesimulator' -configuration 'Debug' -scheme 'UnitTests' -destination 'name=iPhone 16 Pro,OS=18.5,platform=iOS Simulator' test | ./Pods/xcbeautify/xcbeautify
ui_test_job:
name: UI
runs-on: macos-15-xlarge
timeout-minutes: 20 # Add overall job timeout
strategy:
matrix:
test-suite:
- ThreeDSecure_V2_UITests
- PayPal_Checkout_UITests
- PayPal_Vault_UITests
- Venmo_UITests
fail-fast: false # Continue running other test suites if one fails
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Use Xcode 16.4
run: sudo xcode-select -switch /Applications/Xcode_16.4.0.app
- name: Install CocoaPod dependencies
run: pod install
- name: Boot Simulator
run: |
# Boot simulator ahead of time to reduce test startup time
xcrun simctl boot "iPhone 16" || true
# Wait for simulator to boot
xcrun simctl bootstatus "iPhone 16" -b || true
# Disable hardware keyboard to avoid input issues
defaults write com.apple.iphonesimulator ConnectHardwareKeyboard -bool false
- name: Clean Simulator State
run: |
# Reset simulator state to ensure clean environment
xcrun simctl shutdown all || true
xcrun simctl erase all || true
xcrun simctl boot "iPhone 16" || true
xcrun simctl bootstatus "iPhone 16" -b || true
- name: Run UI Tests - ${{ matrix.test-suite }}
id: test_attempt_1
continue-on-error: true
run: |
set -o pipefail
xcodebuild \
-workspace 'Braintree.xcworkspace' \
-sdk 'iphonesimulator' \
-configuration 'Release' \
-scheme 'UITests' \
-destination 'name=iPhone 16 Pro,OS=18.5,platform=iOS Simulator' \
-only-testing:UITests/${{ matrix.test-suite }} \
-maximum-concurrent-test-simulator-destinations 1 \
-disable-concurrent-testing \
test | ./Pods/xcbeautify/xcbeautify
- name: Retry UI Tests (if failed) - ${{ matrix.test-suite }}
if: steps.test_attempt_1.outcome == 'failure'
id: test_attempt_2
continue-on-error: true
run: |
echo "First attempt failed, retrying..."
# Clean simulator state before retry
xcrun simctl shutdown all || true
xcrun simctl erase all || true
xcrun simctl boot "iPhone 16" || true
xcrun simctl bootstatus "iPhone 16" -b || true
set -o pipefail
xcodebuild \
-workspace 'Braintree.xcworkspace' \
-sdk 'iphonesimulator' \
-configuration 'Release' \
-scheme 'UITests' \
-destination 'name=iPhone 16 Pro,OS=18.5,platform=iOS Simulator' \
-only-testing:UITests/${{ matrix.test-suite }} \
-maximum-concurrent-test-simulator-destinations 1 \
-disable-concurrent-testing \
test | ./Pods/xcbeautify/xcbeautify
- name: Final UI Test Result - ${{ matrix.test-suite }}
if: steps.test_attempt_1.outcome == 'failure'
run: |
if [ "${{ steps.test_attempt_2.outcome }}" == "failure" ]; then
echo "UI Tests failed after retry"
exit 1
else
echo "UI Tests passed on retry"
fi
integration_test_job:
name: Integration
runs-on: macos-15-xlarge
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Use Xcode 16.4
run: sudo xcode-select -switch /Applications/Xcode_16.4.0.app
- name: Install Package dependencies
run: swift package resolve
- name: Install CocoaPod dependencies
run: pod install
- name: Run Integration Tests
run: set -o pipefail && xcodebuild -workspace 'Braintree.xcworkspace' -sdk 'iphonesimulator' -configuration 'Release' -scheme 'IntegrationTests' -destination 'name=iPhone 16 Pro,OS=18.5,platform=iOS Simulator' test | ./Pods/xcbeautify/xcbeautify