Files
iNaturalistReactNative/.github/workflows/e2e_ios.yml
Amanda Bullington a99cf212ba Update e2e workflows
2023-10-30 11:16:57 -07:00

129 lines
4.4 KiB
YAML

##
# Run e2e tests
##
name: e2e-iOS
on:
workflow_dispatch:
pull_request:
push:
branches:
- 'main'
jobs:
setup:
runs-on: macos-latest
steps:
- uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
cancel_others: true
checksecret:
name: check for oauth client
needs: setup
runs-on: macos-latest
outputs:
is_SECRETS_PRESENT_set: ${{ steps.checksecret_job.outputs.is_SECRETS_PRESENT_set }}
steps:
- name: Check whether unity activation requests should be done
id: checksecret_job
env:
SECRETS_PRESENT: ${{ secrets.OAUTH_CLIENT_SECRET }}
run: |
echo "is_SECRETS_PRESENT_set: ${{ env.SECRETS_PRESENT != '' }}"
echo "::set-output name=is_SECRETS_PRESENT_set::${{ env.SECRETS_PRESENT != '' }}"
test:
needs: checksecret
if: needs.checksecret.outputs.is_SECRETS_PRESENT_set == 'true'
runs-on: macos-latest
# Kill the task if not finished after 60 minutes
timeout-minutes: 60
steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version: 18
- name: Cache node modules
uses: actions/cache@v3
id: cache
with:
path: node_modules
key: node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Rebuild detox from cache
if: steps.cache.outputs.cache-hit == 'true'
run: npx detox clean-framework-cache && npx detox build-framework-cache
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
- name: Cache Pods
uses: actions/cache@v3
id: podcache
with:
path: ios/Pods
key: pods-${{ hashFiles('**/Podfile.lock') }}
- name: Update Pods
run: |
gem update cocoapods xcodeproj
cd ios && pod install && cd ..
# Generate the secret files needed for a release build
- name: Create .env file
env:
OAUTH_CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }}
OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}
E2E_TEST_USERNAME: ${{ secrets.E2E_TEST_USERNAME }}
E2E_TEST_PASSWORD: ${{ secrets.E2E_TEST_PASSWORD }}
JWT_ANONYMOUS_API_SECRET: ${{ secrets.JWT_ANONYMOUS_API_SECRET }}
run: printf 'API_URL=https://stagingapi.inaturalist.org/v2\nOAUTH_API_URL=https://staging.inaturalist.org\nJWT_ANONYMOUS_API_SECRET=%s\nOAUTH_CLIENT_ID=%s\nOAUTH_CLIENT_SECRET=%s\nE2E_TEST_USERNAME=%s\nE2E_TEST_PASSWORD=%s\nGMAPS_API_KEY=%s\nANDROID_MODEL_FILE_NAME=small_inception_tf1.tflite\nANDROID_TAXONOMY_FILE_NAME=small_export_tax.csv\nIOS_MODEL_FILE_NAME=small_inception_tf1.mlmodel\nIOS_TAXONOMY_FILE_NAME=small_export_tax.json\n' "JWT_ANONYMOUS_API_SECRET" "$OAUTH_CLIENT_ID" "$OAUTH_CLIENT_SECRET" "$E2E_TEST_USERNAME" "$E2E_TEST_PASSWORD" "$GMAPS_API_KEY" > .env
# Download all linked model files not included in the repository (otherwise build will error out), requires .env file
- name: Download the example cv model and taxonomy file into the ios folder
run: npm run add-example-model
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
# This will be available for all subsequent steps
- name: Set MOCK_MODE to e2e
run: echo "MOCK_MODE=e2e" >> "$GITHUB_ENV"
# Install prerequisites for detox and build app, and test
- run: brew tap wix/brew
- run: brew install applesimutils
- name: Build test app
run: npm run e2e:build:ios
- name: Run e2e test
run: npm run e2e:test:ios -- --cleanup --take-screenshots failing --record-videos failing -l debug
# The artifacts for the failing tests are available for download on github.com on the page of the individual actions run
- name: Store Detox artifacts on test failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: detox-artifacts
path: artifacts
notify:
name: Notify Slack
needs: test
if: ${{ success() || failure() }}
runs-on: macos-latest
steps:
- uses: iRoachie/slack-github-actions@v2.3.0
if: env.SLACK_WEBHOOK_URL != null
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_BUILDS_WEBHOOK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}