Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add Detox e2e tests for RN SDK. #376

Merged
merged 33 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
039d05a
chore: Added initial Detox CI config for react-native.
yusinto Feb 8, 2024
2d1d098
chore: Get ssm mobile key.
yusinto Feb 9, 2024
f5c453b
chore: Add instructions to test github actions locally.
yusinto Feb 9, 2024
0d424de
Update README.md
yusinto Feb 9, 2024
1a312b9
Update react-native.yml
yusinto Feb 9, 2024
668b68e
chore: Hardcode xcode version to fix pod install glog error.
yusinto Feb 10, 2024
e78d8ea
Update react-native.yml
yusinto Feb 10, 2024
846d617
Update react-native.yml
yusinto Feb 10, 2024
2fad756
chore: Update osx runner to 14 to use latest xcode.
yusinto Feb 10, 2024
95b161a
chore: Fixing visibility test failure.
yusinto Feb 10, 2024
03ccac0
Update README.md
yusinto Feb 10, 2024
5bfd752
Update package.json
yusinto Feb 10, 2024
84ae6e1
Update package.json
yusinto Feb 10, 2024
b26c65a
Update .detoxrc.js
yusinto Feb 10, 2024
95e6da1
Update starter.test.ts
yusinto Feb 10, 2024
e7874af
chore: Attempt to fix broken variation test.
yusinto Feb 12, 2024
42c17bc
Update react-native.yml
yusinto Feb 12, 2024
fe71d08
Update welcome.tsx
yusinto Feb 12, 2024
16ecb60
chore: Restore build-test job.
yusinto Feb 12, 2024
0ea0b57
chore: Added scrollable output.
yusinto Feb 12, 2024
f55a8b6
Merge branch 'main' into yus/sc-228487/detox-in-ci
yusinto Feb 16, 2024
2d0d4a7
Update react-native.yml
yusinto Feb 16, 2024
fdfabda
Update react-native.yml
yusinto Feb 16, 2024
954a7ca
Update react-native.yml
yusinto Feb 16, 2024
d776b85
Update package.json
yusinto Feb 16, 2024
eacb54e
Update react-native.yml
yusinto Feb 16, 2024
017a574
Update react-native.yml
yusinto Feb 16, 2024
23190fb
fix: Set hoisting limits so example app uses its own external deps.
yusinto Feb 20, 2024
9c23a75
chore: Install only packages for example app.
yusinto Feb 20, 2024
0b10bc8
Update react-native.yml
yusinto Feb 20, 2024
c3c6e17
Update react-native.yml
yusinto Feb 20, 2024
51bbe23
Update react-native.yml
yusinto Feb 20, 2024
3c0aee8
Update react-native.yml
yusinto Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# LaunchDarkly Github Actions for JavaScript SDKs.

This directory contains Github Actions for building, deploying, releasing
libraries in this monorepo.

## Local testing using act

You can use [act](https://nektosact.com/usage/index.html) to run github actions locally for testing.

1. Install and run Docker.
2. Install act.

```shell
brew install act
```

3. Run a workflow file.

```shell
# To run the react-native build/test/e2e
act -W '.github/workflows/react-native.yml' -P macos-14=-self-hosted
```
79 changes: 70 additions & 9 deletions .github/workflows/react-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,75 @@ on:
- '**.md'

jobs:
build-test-react-native:
runs-on: ubuntu-latest
# build-test-react-native:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# - id: shared
# name: Shared CI Steps
# uses: ./actions/ci
# with:
# workspace_name: '@launchdarkly/react-native-client-sdk'
# workspace_path: packages/sdk/react-native
detox-ios:
# macos-latest uses macos-12 and we need macos-14 to get xcode 15.
# https://github.com/actions/runner-images/blob/main/README.md
runs-on: macos-14
permissions:
id-token: write
contents: read
defaults:
run:
working-directory: packages/sdk/react-native/example
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- id: shared
name: Shared CI Steps
uses: ./actions/ci
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
workspace_name: '@launchdarkly/react-native-client-sdk'
workspace_path: packages/sdk/react-native
cache: yarn
cache-dependency-path: 'packages/sdk/react-native/example/yarn.lock'

- name: Install Yarn dependencies
run: yarn install --immutable

- name: Install macOS dependencies
run: |
brew tap wix/brew
brew install applesimutils
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1

- name: Cache Detox build
id: cache-detox-build
uses: actions/cache@v4
with:
path: ios/build
key: ${{ runner.os }}-detox-build
restore-keys: |
${{ runner.os }}-detox-build

- name: Detox rebuild framework cache
run: yarn detox rebuild-framework-cache

- uses: ./actions/release-secrets
name: 'Get mobile key'
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/sdk/detox/mobile-key = MOBILE_KEY'

- name: Set mobile key
run: echo "MOBILE_KEY=$MOBILE_KEY" > .env

- name: Expo prebuild
run: |
export NO_FLIPPER=1
yarn expo-prebuild
rm -rf ./ios/.xcode.env.local

- name: Detox build
run: yarn detox build --configuration ios.sim.release

- name: Detox test
run: yarn detox test --configuration ios.sim.release --cleanup --headless --record-logs all --take-screenshots failing
11 changes: 5 additions & 6 deletions packages/sdk/react-native/example/build-run-detox.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/bash

export NO_FLIPPER=1

echo "===== Installing all dependencies"
yarn

echo "===== Rebuild detox cache"
yarn detox rebuild-framework-cache

echo "===== Building native code"
yarn expo-prebuild

Expand All @@ -12,11 +17,5 @@ yarn expo-prebuild
echo "===== Delete .xcode.env.local"
rm -rf ./ios/.xcode.env.local

echo "===== Start metro in background"
yarn start &

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metro no longer needed in release builds when running e2e.

echo "===== Run ios tests"
yarn detox-ios

echo "===== Exit"
kill -9 $(lsof -t -i:8081)
20 changes: 10 additions & 10 deletions packages/sdk/react-native/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
"scripts": {
"start": "expo start --reset-cache",
"expo-prebuild": "CI=1 expo prebuild --clean",
"android": "yarn link-dev && expo run:android",
"android-release": "yarn link-dev && expo run:android --variant release",
"android-go": "yarn link-dev && expo start --android --clear",
"android": "expo run:android",
"android-release": "expo run:android --variant release",
"android-go": "expo start --android --clear",
"android-log": "react-native log-android",
"ios": "yarn link-dev && expo run:ios",
"ios-release": "yarn link-dev && expo run:ios --configuration Release",
"ios-go": "yarn link-dev && expo start --ios --clear",
"ios": "expo run:ios",
"ios-release": "expo run:ios --configuration Release",
"ios-go": "expo start --ios --clear",
"ios-log": "react-native log-ios",
"web": "yarn link-dev && expo start --web --clear",
"web": "expo start --web --clear",
"clean": "yarn expo-prebuild && yarn cache clean && rm -rf node_modules && rm -rf .expo",
"link-dev": "(cd .. && yarn build)",
"postinstall": "yarn link-dev",
"detox-build-ios": "detox build -c ios.sim.debug",
"detox-run-ios": "detox test -c ios.sim.debug",
"detox-build-ios": "detox build -c ios.sim.release",
"detox-run-ios": "detox test -c ios.sim.release --cleanup --headless",
Comment on lines +18 to +19
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use release builds for e2e tests instead of debug builds.

"detox-ios": "yarn detox-build-ios && yarn detox-run-ios",
"test": "./build-run-detox.sh"
},
"dependencies": {
"@launchdarkly/react-native-client-sdk": "^10.0.0",
"@react-native-async-storage/async-storage": "^1.21.0",
"expo": "~50.0.6",
"expo-splash-screen": "~0.26.4",
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/react-native/example/src/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default function Welcome() {
<Text>
{flagKey}: {`${flagValue}`}
</Text>
<Text>context: {JSON.stringify(ldc.getContext(), null, 2)}</Text>
<TextInput
style={styles.input}
autoCapitalize="none"
Expand Down
39 changes: 39 additions & 0 deletions packages/sdk/react-native/example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2623,6 +2623,37 @@ __metadata:
languageName: node
linkType: hard

"@launchdarkly/js-client-sdk-common@npm:1.0.0":
version: 1.0.0
resolution: "@launchdarkly/js-client-sdk-common@npm:1.0.0"
dependencies:
"@launchdarkly/js-sdk-common": 2.2.0
checksum: 64f0ed92441e47abe76431ccf627550f107ab0b2a769f80151b180f2b7b5ba88531ba7c5c184bd9aa8f99b06ce9f77e6b955b7c47c125e186d8fb93353290b70
languageName: node
linkType: hard

"@launchdarkly/js-sdk-common@npm:2.2.0":
version: 2.2.0
resolution: "@launchdarkly/js-sdk-common@npm:2.2.0"
checksum: 7fdbd06165e39c2e6ff7318a1c187555e34fb96e9c91eb25c6d633bb1917b03e945444c0e934960e1a19bf7d4c22276be72e39affaecaeb249633afd04040b3f
languageName: node
linkType: hard

"@launchdarkly/react-native-client-sdk@npm:^10.0.0":
version: 10.0.0
resolution: "@launchdarkly/react-native-client-sdk@npm:10.0.0"
dependencies:
"@launchdarkly/js-client-sdk-common": 1.0.0
"@react-native-async-storage/async-storage": ^1.21.0
base64-js: ^1.5.1
event-target-shim: ^6.0.2
peerDependencies:
react: "*"
react-native: "*"
checksum: f116c058c8dec120300704dfbb7ca8a644873cc96109bcc574a797f3e86967095f3205c3e64d064acf8902b92c3bdbc23a4c466f22897874b778337470351a08
languageName: node
linkType: hard

"@nodelib/fs.scandir@npm:2.1.5":
version: 2.1.5
resolution: "@nodelib/fs.scandir@npm:2.1.5"
Expand Down Expand Up @@ -5226,6 +5257,13 @@ __metadata:
languageName: node
linkType: hard

"event-target-shim@npm:^6.0.2":
version: 6.0.2
resolution: "event-target-shim@npm:6.0.2"
checksum: 9be93437e5b84056a7dc70af8b8962f4ef7f6fd41a988efcd39dfa2853e33242a4058e0dac9cc589cb16ed7409010590ac8cbcc2e3f823100cd337e13be953a0
languageName: node
linkType: hard

"exec-async@npm:^2.2.0":
version: 2.2.0
resolution: "exec-async@npm:2.2.0"
Expand Down Expand Up @@ -8997,6 +9035,7 @@ __metadata:
resolution: "react-native-example@workspace:."
dependencies:
"@babel/core": ^7.20.0
"@launchdarkly/react-native-client-sdk": ^10.0.0
"@react-native-async-storage/async-storage": ^1.21.0
"@types/detox": ^18.1.0
"@types/jest": ^29.5.11
Expand Down
Loading