Fix Maestro iOS tests #131
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lightsaber CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
concurrency: | |
group: lightsaber-ci-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-shared: | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-lightsaber-ci | |
- name: Build Shared | |
run: ./gradlew shared:assemble | |
build-androidApp: | |
runs-on: macos-14 | |
needs: build-shared | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-lightsaber-ci | |
- name: Build Android App | |
run: ./gradlew androidApp:build | |
build-iosApp: | |
runs-on: macos-14 | |
strategy: | |
matrix: | |
configuration: [Debug, Release] | |
target: [iphonesimulator, iphoneos] | |
needs: build-shared | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-lightsaber-ci | |
# Signing Xcode applications | |
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development | |
- name: Install the Apple certificate and provisioning profile | |
env: | |
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} | |
P12_PASSWORD: ${{ secrets.P12_PASSWORD }} | |
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} | |
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | |
run: | | |
# create variables | |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | |
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | |
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | |
# import certificate and provisioning profile from secrets | |
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH | |
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH | |
# create temporary keychain | |
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | |
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
# import certificate to keychain | |
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | |
security list-keychain -d user -s $KEYCHAIN_PATH | |
# apply provisioning profile | |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | |
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles | |
- name: Shared Pod Install | |
run: ./gradlew podInstall | |
- name: iosApp Pod Install | |
run: | | |
cd iosApp | |
pod install | |
cd - | |
- name: Build iOS App | |
env: | |
LIGHTSABER_TEAM_ID: ${{ secrets.LIGHTSABER_TEAM_ID }} | |
run: | | |
xcodebuild -workspace ${{ github.workspace }}/iosApp/iosApp.xcworkspace \ | |
-scheme iosApp \ | |
-configuration ${{ matrix.configuration }} \ | |
-xcconfig ${{ github.workspace }}/iosApp/Configuration/Config.xcconfig \ | |
OBJROOT=${{ github.workspace }}/iosApp/build/ios SYMROOT=${{ github.workspace }}/iosApp/build/ios \ | |
-sdk ${{ matrix.target }} | |
- name: Clean up keychain and provisioning profile | |
if: ${{ always() }} | |
run: | | |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db | |
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision | |
test-shared: | |
runs-on: macos-14 | |
needs: build-shared | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-lightsaber-ci | |
- name: Unit Test Shared | |
run: ./gradlew shared:cleanAllTests shared:allTests | |
ui-test-ios-shared: | |
runs-on: macos-14 | |
needs: build-shared | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-lightsaber-ci | |
- uses: futureware-tech/simulator-action@v3 | |
id: ios-simulator | |
with: | |
model: 'iPhone 15' | |
os: iOS | |
os_version: 17.0 | |
- name: Wait for the simulator to be ready | |
run: xcrun simctl bootstatus "${{ steps.ios-simulator.outputs.udid }}" -b | |
- name: iOS UI Tests | |
run: ./gradlew :shared:iosSimulatorArm64Test | |
ui-test-android-shared: | |
runs-on: ubuntu-latest | |
needs: build-shared | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-lightsaber-ci | |
- name: Enable KVM | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Android UI Tests | |
uses: reactivecircus/[email protected] | |
with: | |
api-level: 27 | |
script: | | |
./gradlew :shared:connectedAndroidTest | |
e2e-test-androidApp: | |
runs-on: ubuntu-latest | |
needs: build-androidApp | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-lightsaber-ci | |
- uses: ./.github/actions/setup-maestro | |
- name: Enable KVM | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Run Maestro tests | |
uses: reactivecircus/[email protected] | |
with: | |
api-level: 27 | |
script: | | |
adb install androidApp/build/outputs/apk/debug/androidApp-debug.apk | |
maestro test .maestro | |
e2e-test-iosApp: | |
runs-on: macos-14 | |
needs: build-iosApp | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-lightsaber-ci | |
- uses: ./.github/actions/setup-maestro | |
- uses: futureware-tech/simulator-action@v3 | |
id: ios-simulator | |
with: | |
model: 'iPhone 15' | |
os: iOS | |
os_version: 17.0 | |
- name: Wait for the simulator to be ready | |
run: xcrun simctl bootstatus "${{ steps.ios-simulator.outputs.udid }}" -b | |
- name: Install app | |
run: xcrun simctl install "${{ steps.ios-simulator.outputs.udid }}" iosApp/build/ios/Debug-iphonesimulator/Lightsaber.app | |
- name: Launch the app | |
run: xcrun simctl launch "${{ steps.ios-simulator.outputs.udid }}" xyz.alaniz.aaron.Lightsaber | |
- name: Run Maestro tests | |
run: | | |
export MAESTRO_DRIVER_STARTUP_TIMEOUT=60000 | |
maestro test .maestro | |
- name: Collect logs | |
if: failure() | |
run: xcrun simctl spawn "${{ steps.ios-simulator.outputs.udid }}" log collect --output ${{ github.workspace }}/${{ steps.ios-simulator.outputs.udid }}.logarchive | |
- name: Archive the device logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: device-logs | |
path: ${{ github.workspace }}/*.logarchive |