From 280663a2ae5c3130632142b6b4aeaaaaf860fe5f Mon Sep 17 00:00:00 2001 From: Rita Zerrizuela Date: Thu, 23 Nov 2023 15:45:23 +0000 Subject: [PATCH] Add CI job for running macOS unit tests --- .../{setup-ios => setup-darwin}/action.yml | 4 +- .github/actions/unit-tests-darwin/action.yml | 32 ++++++++++++ .github/workflows/main.yml | 52 +++++++++++++------ 3 files changed, 70 insertions(+), 18 deletions(-) rename .github/actions/{setup-ios => setup-darwin}/action.yml (97%) create mode 100644 .github/actions/unit-tests-darwin/action.yml diff --git a/.github/actions/setup-ios/action.yml b/.github/actions/setup-darwin/action.yml similarity index 97% rename from .github/actions/setup-ios/action.yml rename to .github/actions/setup-darwin/action.yml index d9edbba6..3296bc47 100644 --- a/.github/actions/setup-ios/action.yml +++ b/.github/actions/setup-darwin/action.yml @@ -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: diff --git a/.github/actions/unit-tests-darwin/action.yml b/.github/actions/unit-tests-darwin/action.yml new file mode 100644 index 00000000..64e85fde --- /dev/null +++ b/.github/actions/unit-tests-darwin/action.yml @@ -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' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f29033bd..a9f728b0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -147,7 +143,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 }} @@ -155,8 +151,10 @@ jobs: 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 @@ -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 @@ -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 }} @@ -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