From 2ac6aabe6687f69a210fc9398f1141e7fe6130f2 Mon Sep 17 00:00:00 2001 From: Conner Kasten Date: Thu, 30 Jan 2025 12:11:46 -0500 Subject: [PATCH] Update ci.yml to run iOS unit tests in CI (#17) Also add a comment for the right command to successfully run tests. Based on https://qualitycoding.org/github-actions-ci-xcode/ Uses git restore to clean up Podfile.lock changes after build completes. --- .github/workflows/ci.yml | 24 +++++++++++++++++++++-- example/ios/Podfile.lock | 8 ++++---- example/ios/RunnerTests/RunnerTests.swift | 3 ++- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ab5fc5..abca461 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v4 @@ -37,7 +37,7 @@ jobs: with: java-version: 17 distribution: 'temurin' - + - name: Set up Gradle uses: gradle/actions/setup-gradle@v4 @@ -62,6 +62,26 @@ jobs: - name: Run Android unit tests run: cd example/android && gradle test + + - name: Install Dependencies + run: cd example/ios && pod install + + - name: Run iOS unit tests + run: | + cd example/ios && \ + xcodebuild test \ + -workspace Runner.xcworkspace \ + -scheme Runner \ + -configuration Debug \ + -sdk iphonesimulator \ + -disableAutomaticPackageResolution \ + -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' \ + CODE_SIGNING_ALLOWED='NO' + + # Revert the file that get's mutated by pod install + # to avoid angering flutter pub publish + - name: iOS Cleanup + run: git restore example/ios/Podfile.lock - name: Test docs generation run: dart doc --dry-run diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 45f9588..f4d1f40 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -33,10 +33,10 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 FullStory: 621fce986e63959bc29a8864dfc05ea6a3fe6403 - fullstory_flutter: 76898492c1a251f9628bd52beca0b53db808f981 - integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573 - webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4 + fullstory_flutter: 82276b0edaf3d683dc45991adb0c39c0196a2a9e + integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e + webview_flutter_wkwebview: 44d4dee7d7056d5ad185d25b38404436d56c547c PODFILE CHECKSUM: 9c46fd01abff66081b39f5fa5767b3f1d0b11d76 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/example/ios/RunnerTests/RunnerTests.swift b/example/ios/RunnerTests/RunnerTests.swift index 7872e5d..c59115c 100644 --- a/example/ios/RunnerTests/RunnerTests.swift +++ b/example/ios/RunnerTests/RunnerTests.swift @@ -8,7 +8,8 @@ import XCTest // This demonstrates a simple unit test of the Swift portion of this plugin's implementation. // // See https://developer.apple.com/documentation/xctest for more information about using XCTest. - +// Run with: +// xcodebuild test -workspace Runner.xcworkspace -scheme Runner -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' class RunnerTests: XCTestCase { func testGetFsVersion() {