Skip to content

Commit

Permalink
Install test refactored (#5085)
Browse files Browse the repository at this point in the history
* Refactored the install test

* Install CLI deps

* Test android

* Improved Slack message

* Installing and skipping ios on android

* Update install-test-react-native.yml

* Update cli.ts

* Update install-test-react-native.yml

* Update install-test-react-native.yml

* Update install-test-react-native.yml

* Update install-test-react-native.yml

* Update install-test-react-native.yml

* Update install-test-react-native.yml

* Update install-test-react-native.yml

* Update install-test-react-native.yml

* Applying a Podfile patch to use ccache

* Configuring ccache

* Make ccache key more specific to avoid cross contamination

* Printing timeout in error

* Announce on Slack only once pr run

* Tried downgrading Xcode

* Fixed syntax error

* Update install-test-react-native.yml

* Try failing when test fails

* Update install-test-react-native.yml

* Attempt to propagate result of all matrix jobs

* Cache CocoaPods

* Add --active-arch-only

* Re-arranged the matrix props

* Run earlier

* Adding an option run tests with JSC

* Adding engine to workflow matrix

* Update install-test-react-native.yml

* Cache CocoaPods only when testing on ios

* Update install-tests/react-native/cli.ts

* Apply patches only if files exists

* Upload result artifacts

* Moved App.js into patches

* Writing a local.properties for Android

* Upload result from install-tests/react-native

* Use CLI to generate Slack payload

* Update install-test-react-native.yml

* Assuming location of results

* Renamed command

* Resolving and printing output path

* Updated upload path

* Update install-test-react-native.yml

* Corrected the file path when loading result files

* Update install-test-react-native.yml

* Locating result.json recursively

* Update install-test-react-native.yml

* Update install-test-react-native.yml

* Reverted the custom slack message builder

* Adding a timeout the the emulator

* Rearranged options

* Throw instead of calling process.exit

* Remove old script from package.json

* Update install-tests/react-native/cli.ts

Co-authored-by: Kenneth Geisshirt <[email protected]>

Co-authored-by: Kenneth Geisshirt <[email protected]>
  • Loading branch information
kraenhansen and kneth authored Nov 10, 2022
1 parent c513666 commit 684f2b3
Show file tree
Hide file tree
Showing 13 changed files with 9,774 additions and 109 deletions.
129 changes: 96 additions & 33 deletions .github/workflows/install-test-react-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,126 @@ on:
paths:
- install-tests/react-native/**
- .github/workflows/install-test-react-native.yml
# Every day at 9:00 CET
# Every monday at 7:00 CET
schedule:
- cron: "0 8 * * *"
- cron: "0 6 * * 1"
# You can also activate this workflow manually from the Actions tab
workflow_dispatch:
inputs:
react-native-version:
description: The version of React Native to install
required: true
default: next
realm-version:
description: The version of Realm to install
required: true
default: latest

defaults:
run:
working-directory: install-tests/react-native

jobs:
install:
name: Installing Realm → React Native (using Xcode v${{matrix.xcode}}, node v${{ matrix.node }}, npm v${{ matrix.npm }})
runs-on: macos-11
runs-on: macos-12
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
# See https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md#xcode
platform:
- ios
- android
realm-version:
# - v10 # Enable if we feel the need
- latest
react-native-version:
- latest
- next
# - nightly # Enable if it's not too noizy
new-architecture:
- true
- false
engine:
- jsc
- hermes
# See https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md#xcode
xcode:
# - 14.0.1
- 13.1
npm:
- 7
node:
- 14
- 16
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install npm v7
run: npm install -g npm@8

- name: ccache
uses: hendrikmuhs/ccache-action@v1
uses: hendrikmuhs/ccache-action@v1.2
with:
key: install-test
key: install-test-${{ matrix.platform }}-r@${{ matrix.realm-version }}-rn@${{ matrix.react-native-version }}-${{ matrix.new-architecture && 'new' || 'old' }}-arch
max-size: '2.0G'
- name: Prepend ccache executables to the PATH
run: echo PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV
- name: Install React Native & Realm
run: ./install.sh ${{ github.event.inputs.react-native-version }} ${{ github.event.inputs.realm-version }}
run: echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
- name: Configure ccache
run: ccache --set-config="compiler_check=content"

# TODO: Remove if this becomes unneeded in the future
- name: Invoke the simulator (making subsequent "open -a Simulator" calls work)
if: ${{ matrix.platform == 'ios' }}
run: open -a ${{ env.DEVELOPER_DIR }}/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator

- name: Install dependencies of the CLI
run: npm ci

- name: Initialize app
# Using "--skip-bundle-install" to let the setup-ruby action install the bundle
# Using "--skip-pod-install" to ensure it happens after setup-ruby has executed
run: npm run init -- --skip-bundle-install --skip-pod-install --realm-version ${{ matrix.realm-version }} --react-native-version ${{ matrix.react-native-version }} --engine ${{ matrix.engine }}

- name: CocoaPod cache
if: ${{ matrix.platform == 'ios' }}
# Using another cache action to work around https://github.com/actions/cache/issues/92
uses: pat-s/[email protected]
with:
path: '**/Pods'
key: cocoa-pods-${{ matrix.platform }}-r@${{ matrix.realm-version }}-rn@${{ matrix.react-native-version }}-${{ matrix.new-architecture && 'new' || 'old' }}-arch

- uses: ruby/setup-ruby@v1
if: ${{ matrix.platform == 'ios' }}
with:
bundler-cache: true
working-directory: install-tests/react-native/app

- if: ${{ matrix.platform == 'ios' }}
run: pod install
working-directory: install-tests/react-native/app/ios

- uses: actions/setup-java@v3
if: ${{ matrix.platform == 'android' }}
with:
distribution: 'zulu'
java-version: '11'

- name: Run test (iOS)
run: ./run-ios.sh
# - name: Run test (Android)
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 29
# target: google_apis
# script: ./run-android.sh
if: ${{ matrix.platform == 'ios' }}
run: npm test -- --platform ios

- name: Run test (Android)
if: ${{ matrix.platform == 'android' }}
uses: reactivecircus/android-emulator-runner@v2
timeout-minutes: 30
with:
api-level: 29
target: google_apis
script: npm test -- --platform android
working-directory: install-tests/react-native

slack-workflow-status:
if: always()
name: Post Workflow Status To Slack
needs: install
runs-on: ubuntu-latest
permissions:
actions: 'read'
steps:
- name: Slack Workflow Notification
uses: Gamesight/slack-workflow-status@master
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
slack_webhook_url: ${{ secrets.SLACK_TEST_WEBHOOK }}
include_jobs: true
include_commit_message: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ examples/ReactExample/ios/Pods/
examples/ReactExample/ios/ReactExample.xcworkspace/
tests/mongodb-realm
install-tests/react-native/app/
install-tests/react-native/payload.json
install-tests/react-native/result-*

# Integration tests
integration-tests/environments/electron/dist/
Expand Down
Loading

0 comments on commit 684f2b3

Please sign in to comment.