Skip to content

Commit

Permalink
Add CI job for running macOS unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Nov 23, 2023
1 parent 19afea6 commit 280663a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Set up iOS environment
description: Set up the environment for building and testing the library on iOS
name: Set up iOS/macOS environment
description: Set up the environment for building and testing the library on iOS/macOS

inputs:
flutter:
Expand Down
32 changes: 32 additions & 0 deletions .github/actions/unit-tests-darwin/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run iOS/macOS unit tests
description: Execute the unit test suite on iOS/macOS

inputs:
platform:
description: Either iOS or macOS
required: true

destination:
description: The destination string for xcodebuild
required: true

runs:
using: composite

steps:
- name: Lowercase platform value
id: lowercase-platform
run: echo platform=$(echo ${{ inputs.platform }}) | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
shell: bash

- name: Run iOS unit tests
working-directory: auth0_flutter/example/${{ steps.lowercase-platform.outputs.platform }}
run: xcodebuild test -scheme Runner -workspace Runner.xcworkspace -destination '${{ inputs.destination }}' -resultBundlePath unit-tests.xcresult -skip-testing:RunnerUITests
shell: bash

- name: Upload xcresult bundles
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: ${{ failure() }}
with:
name: '${{ inputs.platform }} xcresult bundles [unit tests]'
path: 'auth0_flutter/example/${{ steps.lowercase-platform.outputs.platform }}/*.xcresult'
52 changes: 36 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ jobs:
runs-on: macos-latest
environment: ${{ github.event.pull_request.head.repo.fork && 'external' || 'internal' }}

env:
USER_EMAIL: ${{ secrets.USER_EMAIL }}
USER_PASSWORD: ${{ secrets.USER_PASSWORD }}

strategy:
matrix:
xcode:
Expand All @@ -147,16 +143,18 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Set up environment
uses: ./.github/actions/setup-ios
uses: ./.github/actions/setup-darwin
with:
flutter: ${{ env.flutter }}
xcode: ${{ matrix.xcode }}
auth0-domain: ${{ vars.AUTH0_DOMAIN }}
auth0-client-id: ${{ vars.AUTH0_CLIENT_ID }}

- name: Run iOS unit tests
working-directory: auth0_flutter/example/ios
run: xcodebuild test -scheme Runner -workspace Runner.xcworkspace -destination '${{ format('{0}{1}', 'platform=iOS Simulator,name=', env.ios-simulator) }}' -resultBundlePath unit-tests.xcresult -skip-testing:RunnerUITests
uses: ./.github/actions/unit-tests-darwin
with:
platform: iOS
destination: ${{ format('{0}{1}', 'platform=iOS Simulator,name=', env.ios-simulator) }}

- name: Convert coverage report
working-directory: auth0_flutter/example/ios
Expand All @@ -168,13 +166,6 @@ jobs:
name: iOS coverage
path: auth0_flutter/example/ios/cobertura

- name: Upload xcresult bundles
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: ${{ failure() }}
with:
name: xcresult bundles
path: 'auth0_flutter/example/ios/*.xcresult'

test-ios-smoke:
name: Run native iOS smoke tests using Xcode ${{ matrix.xcode }}
needs: authorize
Expand All @@ -195,7 +186,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Set up environment
uses: ./.github/actions/setup-ios
uses: ./.github/actions/setup-darwin
with:
flutter: ${{ env.flutter }}
xcode: ${{ matrix.xcode }}
Expand All @@ -213,9 +204,38 @@ jobs:
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: ${{ failure() }}
with:
name: 'iOS - xcresult bundles'
name: 'iOS xcresult bundles [smoke tests]'
path: 'auth0_flutter/example/ios/*.xcresult'

test-macos-unit:
name: Run native macOS unit tests using Xcode ${{ matrix.xcode }}
needs: authorize
runs-on: macos-latest
environment: ${{ github.event.pull_request.head.repo.fork && 'external' || 'internal' }}

strategy:
matrix:
xcode:
- '14.2'

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Set up environment
uses: ./.github/actions/setup-darwin
with:
flutter: ${{ env.flutter }}
xcode: ${{ matrix.xcode }}
auth0-domain: ${{ vars.AUTH0_DOMAIN }}
auth0-client-id: ${{ vars.AUTH0_CLIENT_ID }}

- name: Run macOS unit tests
uses: ./.github/actions/unit-tests-darwin
with:
platform: macOS
destination: platform=macOS,arch=x86_64

test-android-unit:
name: Run native Android unit tests
needs: authorize
Expand Down

0 comments on commit 280663a

Please sign in to comment.