Skip to content

Update ci.yml to run iOS unit tests in CI #87

Update ci.yml to run iOS unit tests in CI

Update ci.yml to run iOS unit tests in CI #87

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: ["main"]
tags:
# must align with the tag-pattern configured on pub.dev, often just replace
- "v[0-9]+.[0-9]+.[0-9]+" # tag-pattern on pub.dev: 'v{{version}}'
pull_request:
branches: ["main"]
jobs:
test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
# Note: This workflow uses the latest stable version of the Dart SDK.
# You can specify other versions if desired, see documentation here:
# https://github.com/dart-lang/setup-dart/blob/main/README.md
# - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
- uses: dart-lang/setup-dart@v1
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.x
- run: flutter --version
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set up local.properties
run: bash .github/workflows/create_properties.sh
- name: Install dependencies
run: flutter pub get
- name: Verify formatting
run: dart format --output=none --set-exit-if-changed .
# Optionally remove '--fatal-infos' for less strict analysis.
- name: Analyze project source
run: dart analyze --fatal-infos
- name: Run library tests
run: flutter test
- name: Run example app tests
run: cd example && flutter test
- 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 \
-allowProvisioningUpdates \
-destination 'platform=iOS Simulator,name=iPhone 16,OS=18.2'
- name: Test docs generation
run: dart doc --dry-run
# dry run publish
- run: ./generate_example_md.sh > example/example.md
- run: cat example/example.md
- run: flutter pub publish --dry-run
publish:
# only run tags, after the tests have passed
if: startsWith(github.ref, 'refs/tags/v')
needs: [test]
permissions:
id-token: write # Required for authentication using OIDC
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# This creates the OIDC token that the publish step uses
- uses: dart-lang/setup-dart@v1
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.x
- run: flutter --version
- name: Install dependencies
run: flutter pub get
# create an example/example.md file with all of the example code
# otherwise pub.dev defaults to the contents of lib/main.md which is fairly unhelpful
- run: ./generate_example_md.sh > example/example.md
- name: Publish
# --force is required because otherwise it asks for a confirmation and times out waiting
run: flutter pub publish --force