Skip to content

Commit

Permalink
ci: run iOS tests in GitHub Actions (#791)
Browse files Browse the repository at this point in the history
* ci: run iOS tests in GitHub Actions

* fix firebase configuration

this changed after the first draft of this code

* also upload failed results the way Fastlane provides them
  • Loading branch information
boringcactus authored Feb 25, 2025
1 parent f93a055 commit e20b691
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 4 deletions.
23 changes: 21 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ runs:
android-test)
tools="java kotlin-cache rsvg"
;;
ios-test)
tools="java kotlin-cache ruby xcode"
;;
android-build)
tools="java kotlin-cache rsvg ruby aws-secrets-android"
;;
Expand Down Expand Up @@ -67,8 +70,8 @@ runs:
if: steps.settings.outputs.kotlin-cache == 'true'
with:
path: ~/.konan
key: konan-${{ runner.os }}-${{ hashFiles('build.gradle.kts') }}
restore-keys: konan-${{ runner.os }}
key: konan-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('build.gradle.kts') }}
restore-keys: konan-${{ runner.os }}-${{ runner.arch }}
- run: sudo apt-get install librsvg2-bin
if: steps.settings.outputs.rsvg == 'true'
shell: bash
Expand Down Expand Up @@ -106,3 +109,19 @@ runs:
if: steps.settings.outputs.ruby == 'true'
run: bin/patch-fastlane.sh
shell: bash
- name: Configure Xcode version
if: steps.settings.outputs.xcode == 'true'
shell: bash
run: |
sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer
- name: Cache CocoaPods dependencies
if: steps.settings.outputs.xcode == 'true'
uses: actions/cache@v4
with:
path: iosApp/Pods
key: cocoapods-${{ hashFiles('iosApp/Podfile.lock') }}
restore-keys: cocoapods-
- name: Install SwiftLint and xcbeautify
if: steps.settings.outputs.xcode == 'true'
shell: bash
run: brew install swiftlint xcbeautify
48 changes: 48 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,54 @@ jobs:
with:
name: android-android-reports
path: androidApp/build/reports
test-ios:
name: Test for iOS
runs-on: macos-14-xlarge
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
for: ios-test
- 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:
GH_TOKEN: ${{ github.token }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ios-shared-reports
path: shared/build/reports
- 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_IOS=${GOOGLE_APP_ID_IOS}"
} >> .envrc
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_ENVIRONMENT: staging
FIREBASE_KEY: ${{ secrets.FIREBASE_KEY }}
GOOGLE_APP_ID_IOS: ${{ secrets.GOOGLE_APP_ID_IOS_STAGING }}
- name: Run emulator tests
run: |
bundle exec fastlane ios test \
xcodebuild_formatter:"xcbeautify --renderer github-actions"
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ios-ios-results
path: fastlane/test_output/*
emulator-test-android:
name: Run Android instrumented tests in emulator
runs-on: mobile_app_runner
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ xcuserdata
.kotlin

fastlane/report.xml
fastlane/test_output

/iosApp/secrets/*
/iosApp/Pods/*
Expand Down
15 changes: 15 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,18 @@ platform :android do
)
end
end

platform :ios do
desc "Run tests"
lane :test do |options|
run_tests(
workspace: "iosApp/iosApp.xcworkspace",
scheme: "Staging",
device: "iPhone 15 (17.5)",
testplan: "iosAppRetries",
output_directory: options[:output_directory],
xcodebuild_formatter: options[:xcodebuild_formatter],
number_of_retries: 3
)
end
end
13 changes: 13 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ Deploy a new version to Google Play for internal testing

----


## iOS

### ios test

```sh
[bundle exec] fastlane ios test
```

Run tests

----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.

More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).
Expand Down
8 changes: 6 additions & 2 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,17 @@ if (DefaultNativePlatform.getCurrentOperatingSystem().isMacOsX) {
tasks.getByName("compileKotlinIosSimulatorArm64").dependsOn("bomCodegenIos")
}

if (System.getenv("CI_XCODE_CLOUD") != "TRUE") {
// don't run Android BOM codegen for iOS-only CI
if (
!(System.getenv("CI")?.lowercase() == "true" &&
DefaultNativePlatform.getCurrentOperatingSystem().isMacOsX)
) {
tasks.getByName("preBuild").dependsOn("bomCodegenAndroid")
}

task<DependencyCodegenTask>("bomCodegenAndroid") {
dependsOn("bomAndroid")
mustRunAfter("spotlessKotlin")
mustRunAfter("spotlessKotlin", "cyclonedxBom")
inputPath = layout.buildDirectory.file("boms/bom-android.json")
outputPath =
layout.projectDirectory.file(
Expand Down

0 comments on commit e20b691

Please sign in to comment.