Skip to content

ci: run iOS tests in GitHub Actions #2596

ci: run iOS tests in GitHub Actions

ci: run iOS tests in GitHub Actions #2596

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
pre-commit:
name: Run pre-commit to check formatting and linting
if: false
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
java: true
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# pre-commit/action@v3.0.1
- run: python -m pip install pre-commit
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: pre-commit run --show-diff-on-failure --color=always --all-files
test-android:
name: Test for Android
if: false
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
java: true
kotlin-cache: true
rsvg: true
- run: ./gradlew spotlessCheck
- name: shared checks & unit tests
run: ./gradlew shared:check
env:
MAPBOX_SECRET_TOKEN: ${{ secrets.MAPBOX_SECRET_TOKEN }}
MAPBOX_PUBLIC_TOKEN: ${{ secrets.MAPBOX_PUBLIC_TOKEN }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: android-shared-reports
path: shared/build/reports
- name: android checks & unit tests
run: ./gradlew androidApp:check
env:
MAPBOX_SECRET_TOKEN: ${{ secrets.MAPBOX_SECRET_TOKEN }}
MAPBOX_PUBLIC_TOKEN: ${{ secrets.MAPBOX_PUBLIC_TOKEN }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: android-android-reports
path: androidApp/build/reports
test-ios:
name: Test for iOS
runs-on: macos-14-large
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
java: true
kotlin-cache: true
ruby: true
- name: Configure Xcode version
run: |
sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer
- name: Install CocoaPods dependencies
run: |
./gradlew :shared:generateDummyFramework
pushd iosApp
bundle exec pod install
popd
bundle exec ./gradlew :shared:podInstallSyntheticIos
- name: shared checks & unit tests
run: ./gradlew shared:iosSimulatorArm64Test shared:iosX64Test
env:
MAPBOX_SECRET_TOKEN: ${{ secrets.MAPBOX_SECRET_TOKEN }}
MAPBOX_PUBLIC_TOKEN: ${{ secrets.MAPBOX_PUBLIC_TOKEN }}
GH_TOKEN: ${{ github.token }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ios-shared-reports
path: shared/build/reports
- name: Install SwiftLint
run: brew install swiftlint
- name: Configure Mapbox token
run: |
{
echo "machine api.mapbox.com"
echo "login mapbox"
echo "password ${MAPBOX_SECRET_TOKEN}"
} >> ~/.netrc
env:
MAPBOX_SECRET_TOKEN: ${{ secrets.MAPBOX_SECRET_TOKEN }}
- name: Add build environment variables
run: |
{
echo "export SENTRY_DSN=${SENTRY_DSN}"
echo "export SENTRY_ENVIRONMENT=${SENTRY_ENVIRONMENT}"
echo "export FIREBASE_KEY=${FIREBASE_KEY}"
echo "export GOOGLE_APP_ID=${GOOGLE_APP_ID}"
} >> .envrc
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_ENVIRONMENT: staging
FIREBASE_KEY: ${{ secrets.FIREBASE_KEY }}
GOOGLE_APP_ID: ${{ secrets.GOOGLE_APP_ID }}
- name: Select emulator
id: emulator
run: |
# pick a valid iOS/device from Installed Simulators under relevant Readme in
# https://github.com/actions/runner-images/tree/main/images/macos
RUNTIME=$(xcrun simctl list -j runtimes | jq --arg iOS "iOS $iOS" -r '.runtimes[] | select(.name == $iOS) | .identifier')
DEVICE=$(xcrun simctl list -j devices | jq --arg RUNTIME "$RUNTIME" --arg iPhone "iPhone $iPhone" -r '.devices[$RUNTIME][] | select(.name == $iPhone) | .udid')
echo SIMULATOR_UDID=$DEVICE >> "$GITHUB_ENV"
env:
iOS: "17.5"
iPhone: "15"
- name: Run emulator tests
run: |
xcrun xcodebuild test \
-destination "platform=iOS Simulator,id=$SIMULATOR_UDID" \
-resultBundleVersion 3 \
-resultBundlePath ~/xctest/resultbundle.xcresult \
-IDEPostProgressNotifications=YES \
-DTDKDisableSymbolCopying=YES \
-test-timeouts-enabled YES \
-maximum-test-execution-time-allowance 1800 \
-hideShellScriptEnvironment \
-maximum-parallel-testing-workers 8 \
-testProductsPath ~/xctest/TestProducts.xctestproducts \
-testPlan iosAppRetries
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ios-ios-results
path: ~/xctest/resultbundle.xcresult
emulator-test-android:
name: Run Android instrumented tests in emulator
if: false
runs-on: mobile_app_runner
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- api-level: 28
target: default
arch: x86
# - api-level: 33
# target: default
# arch: x86_64
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
java: true
kotlin-cache: true
rsvg: true
# full setup including AVD snapshot caching from https://github.com/ReactiveCircus/android-emulator-runner/blob/a3dcdb348bb02349cd939d168a74e31a9094b7f0/README.md
- 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 tests
uses: reactivecircus/android-emulator-runner@v2
timeout-minutes: 30
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
force-avd-creation: false
disable-animations: true
script: ./bin/android-instrumented-test-ci.sh
env:
MAPBOX_SECRET_TOKEN: ${{ secrets.MAPBOX_SECRET_TOKEN }}
MAPBOX_PUBLIC_TOKEN: ${{ secrets.MAPBOX_PUBLIC_TOKEN }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: android-connected-reports-${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }}
path: androidApp/build/reports
build-android:
name: Build for Android
if: github.actor != 'dependabot[bot]' && false
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
java: true
kotlin-cache: true
rsvg: true
ruby: true
gcp-provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
gcp-service-account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
- name: Fetch AWS secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
mobile-app-android-upload-key-passphrase
- name: Load code signing key
run: |
cd androidApp
aws secretsmanager get-secret-value --secret-id mobile-app-android-upload-key --output json | jq -r '.SecretBinary' | base64 --decode > upload-keystore.jks
- name: Build Android app
env:
KEYSTORE_FILE: "${{ github.workspace }}/androidApp/upload-keystore.jks"
KEYSTORE_PASSWORD: ${{ env.MOBILE_APP_ANDROID_UPLOAD_KEY_PASSPHRASE }}
KEY_ALIAS: "upload"
KEY_PASSWORD: ${{ env.MOBILE_APP_ANDROID_UPLOAD_KEY_PASSPHRASE }}
MAPBOX_SECRET_TOKEN: ${{ secrets.MAPBOX_SECRET_TOKEN }}
MAPBOX_PUBLIC_TOKEN: ${{ secrets.MAPBOX_PUBLIC_TOKEN }}
run: |
bundle exec fastlane android build
- uses: actions/upload-artifact@v4
with:
name: android-apk
path: androidApp/build/outputs/apk/release/androidApp-release.apk
- uses: actions/upload-artifact@v4
with:
name: android-aab
path: androidApp/build/outputs/bundle/release/androidApp-release.aab
deploy-android:
name: Upload to Google Play
if: github.event_name != 'pull_request' && false
concurrency:
group: deploy-android
cancel-in-progress: false
needs:
- build-android
- test-android
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: android-aab
path: androidApp/build/outputs/bundle/release
- uses: ./.github/actions/setup
with:
gcp-provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
gcp-service-account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
ruby: true
- name: Upload to Google Play
run: |
bundle exec fastlane android internal