From 039d05a898d7b6e5232f9e86ea1504a0e279f3f1 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Thu, 8 Feb 2024 15:47:42 -0800 Subject: [PATCH 01/32] chore: Added initial Detox CI config for react-native. --- .github/workflows/react-native.yml | 30 +++++++++++++- .../react-native/example/build-run-detox.sh | 11 +++--- .../sdk/react-native/example/package.json | 20 +++++----- packages/sdk/react-native/example/yarn.lock | 39 +++++++++++++++++++ 4 files changed, 82 insertions(+), 18 deletions(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 4a3a3fc8a3..560333f205 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -14,11 +14,37 @@ jobs: build-test-react-native: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - 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: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - 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: Install and run tests + run: | + brew tap wix/brew + brew install applesimutils + cd packages/sdk/react-native/example + + # TODO: get mobileKey from secrets + echo "MOBILE_KEY=mob-xxx" > .env + + ./build-run-detox.sh + env: + HOMEBREW_NO_AUTO_UPDATE: 1 + HOMEBREW_NO_INSTALL_CLEANUP: 1 diff --git a/packages/sdk/react-native/example/build-run-detox.sh b/packages/sdk/react-native/example/build-run-detox.sh index 58bb1c5b39..9434057ce2 100755 --- a/packages/sdk/react-native/example/build-run-detox.sh +++ b/packages/sdk/react-native/example/build-run-detox.sh @@ -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 @@ -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 & - echo "===== Run ios tests" yarn detox-ios - -echo "===== Exit" -kill -9 $(lsof -t -i:8081) diff --git a/packages/sdk/react-native/example/package.json b/packages/sdk/react-native/example/package.json index 3dfe33ac9b..9100565aa1 100644 --- a/packages/sdk/react-native/example/package.json +++ b/packages/sdk/react-native/example/package.json @@ -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 ", "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", diff --git a/packages/sdk/react-native/example/yarn.lock b/packages/sdk/react-native/example/yarn.lock index 3186977eef..4fdc04cb16 100644 --- a/packages/sdk/react-native/example/yarn.lock +++ b/packages/sdk/react-native/example/yarn.lock @@ -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" @@ -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" @@ -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 From 2d1d098a383590c063adf7182d83e35f7fbf2738 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 10:58:58 -0800 Subject: [PATCH 02/32] chore: Get ssm mobile key. --- .github/workflows/react-native.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 560333f205..1007a84a47 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -22,7 +22,7 @@ jobs: with: workspace_name: '@launchdarkly/react-native-client-sdk' workspace_path: packages/sdk/react-native - detox: + detox-ios: runs-on: macos-latest steps: - uses: actions/checkout@v4 @@ -35,15 +35,17 @@ jobs: key: ${{ runner.os }}-detox-build restore-keys: | ${{ runner.os }}-detox-build + - 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: Install and run tests run: | brew tap wix/brew brew install applesimutils cd packages/sdk/react-native/example - - # TODO: get mobileKey from secrets - echo "MOBILE_KEY=mob-xxx" > .env - + echo "MOBILE_KEY=$MOBILE_KEY" > .env ./build-run-detox.sh env: HOMEBREW_NO_AUTO_UPDATE: 1 From f5c453b366a3d1c69599bf8948a87bc7088e8131 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 11:46:03 -0800 Subject: [PATCH 03/32] chore: Add instructions to test github actions locally. --- .github/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/README.md diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 0000000000..894f810412 --- /dev/null +++ b/.github/README.md @@ -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-latest=-self-hosted +``` From 0d424deddb07fe3ea2a861e930fabe47f2a4ce13 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 11:46:35 -0800 Subject: [PATCH 04/32] Update README.md --- .github/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/README.md b/.github/README.md index 894f810412..787a0bae7c 100644 --- a/.github/README.md +++ b/.github/README.md @@ -8,7 +8,7 @@ libraries in this monorepo. 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 +2. Install act. ```shell brew install act From 1a312b96f5e90f1e4c886f13708fedfd9c46f33a Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 12:09:50 -0800 Subject: [PATCH 05/32] Update react-native.yml --- .github/workflows/react-native.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 1007a84a47..cac1565611 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -24,6 +24,9 @@ jobs: workspace_path: packages/sdk/react-native detox-ios: runs-on: macos-latest + permissions: + id-token: write + contents: read steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 668b68e8ca225ec08aa34b1b0141d579d216af3a Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 16:08:49 -0800 Subject: [PATCH 06/32] chore: Hardcode xcode version to fix pod install glog error. --- .github/workflows/react-native.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index cac1565611..d6cdc59378 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -43,6 +43,9 @@ jobs: with: aws_assume_role: ${{ vars.AWS_ROLE_ARN }} ssm_parameter_pairs: '/sdk/detox/mobile-key = MOBILE_KEY' + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '15.2' - name: Install and run tests run: | brew tap wix/brew From e78d8ea35f11c7eedb47b14a18c059329ee2da28 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 16:11:18 -0800 Subject: [PATCH 07/32] Update react-native.yml --- .github/workflows/react-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index d6cdc59378..d03e4c0df5 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -45,7 +45,7 @@ jobs: ssm_parameter_pairs: '/sdk/detox/mobile-key = MOBILE_KEY' - uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: '15.2' + xcode-version: '14.2.0' - name: Install and run tests run: | brew tap wix/brew From 846d61747c0f678559ff889905436cd4c8605e9e Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 16:22:31 -0800 Subject: [PATCH 08/32] Update react-native.yml --- .github/workflows/react-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index d03e4c0df5..2bc733dea7 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -45,7 +45,7 @@ jobs: ssm_parameter_pairs: '/sdk/detox/mobile-key = MOBILE_KEY' - uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: '14.2.0' + xcode-version: '13.4' - name: Install and run tests run: | brew tap wix/brew From 2fad756bd257db3b748e1a7089095c925b5243e4 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 16:28:34 -0800 Subject: [PATCH 09/32] chore: Update osx runner to 14 to use latest xcode. --- .github/workflows/react-native.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 2bc733dea7..784eb7c8b8 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -23,7 +23,7 @@ jobs: workspace_name: '@launchdarkly/react-native-client-sdk' workspace_path: packages/sdk/react-native detox-ios: - runs-on: macos-latest + runs-on: macos-14 permissions: id-token: write contents: read @@ -43,9 +43,6 @@ jobs: with: aws_assume_role: ${{ vars.AWS_ROLE_ARN }} ssm_parameter_pairs: '/sdk/detox/mobile-key = MOBILE_KEY' - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '13.4' - name: Install and run tests run: | brew tap wix/brew From 95b161a8a45f7a31fcafaf4df9e9e6cb2a5b2a92 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 17:10:40 -0800 Subject: [PATCH 10/32] chore: Fixing visibility test failure. --- .github/workflows/react-native.yml | 2 ++ packages/sdk/react-native/example/e2e/starter.test.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 784eb7c8b8..11779d433d 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -23,6 +23,8 @@ jobs: 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 diff --git a/packages/sdk/react-native/example/e2e/starter.test.ts b/packages/sdk/react-native/example/e2e/starter.test.ts index af4f80c742..06fca10898 100644 --- a/packages/sdk/react-native/example/e2e/starter.test.ts +++ b/packages/sdk/react-native/example/e2e/starter.test.ts @@ -34,6 +34,9 @@ describe('Example', () => { }); test('variation', async () => { + await waitFor(element(by.id('flagKey'))) + .toBeVisible() + .withTimeout(2000); await element(by.id('flagKey')).replaceText('my-boolean-flag-2'); await waitFor(element(by.text(/my-boolean-flag-2: true/i))) From 03ccac03e72008c1f2c047dca4b023eb9566c91b Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 17:15:15 -0800 Subject: [PATCH 11/32] Update README.md --- .github/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/README.md b/.github/README.md index 787a0bae7c..b38a2cfe99 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,6 +1,6 @@ # LaunchDarkly Github Actions for JavaScript SDKs. -This directory contains Github Actions for building, deploying, releasing +This directory contains Github Actions for building, deploying, releasing libraries in this monorepo. ## Local testing using act @@ -18,5 +18,5 @@ brew install act ```shell # To run the react-native build/test/e2e -act -W '.github/workflows/react-native.yml' -P macos-latest=-self-hosted +act -W '.github/workflows/react-native.yml' -P macos-14=-self-hosted ``` From 5bfd752d0f505040f47d64aa354b19f443269d33 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 21:43:31 -0800 Subject: [PATCH 12/32] Update package.json --- packages/sdk/react-native/example/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/react-native/example/package.json b/packages/sdk/react-native/example/package.json index 9100565aa1..2eec8db221 100644 --- a/packages/sdk/react-native/example/package.json +++ b/packages/sdk/react-native/example/package.json @@ -17,7 +17,7 @@ "clean": "yarn expo-prebuild && yarn cache clean && rm -rf node_modules && rm -rf .expo", "link-dev": "(cd .. && yarn build)", "detox-build-ios": "detox build -c ios.sim.release", - "detox-run-ios": "detox test -c ios.sim.release --cleanup --headless ", + "detox-run-ios": "detox test -c ios.sim.release --cleanup --headless --record-logs all --take-screenshots failing", "detox-ios": "yarn detox-build-ios && yarn detox-run-ios", "test": "./build-run-detox.sh" }, From 84ae6e1fc2209bf6a71939c6442997b6214dff6a Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 22:07:06 -0800 Subject: [PATCH 13/32] Update package.json --- packages/sdk/react-native/example/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/react-native/example/package.json b/packages/sdk/react-native/example/package.json index 2eec8db221..dace4a498f 100644 --- a/packages/sdk/react-native/example/package.json +++ b/packages/sdk/react-native/example/package.json @@ -17,7 +17,7 @@ "clean": "yarn expo-prebuild && yarn cache clean && rm -rf node_modules && rm -rf .expo", "link-dev": "(cd .. && yarn build)", "detox-build-ios": "detox build -c ios.sim.release", - "detox-run-ios": "detox test -c ios.sim.release --cleanup --headless --record-logs all --take-screenshots failing", + "detox-run-ios": "detox test -c ios.sim.release --cleanup --headless --take-screenshots failing --record-videos failing -l trace", "detox-ios": "yarn detox-build-ios && yarn detox-run-ios", "test": "./build-run-detox.sh" }, From b26c65ac737575cc90317b61ae0c296eb1d3913c Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 22:55:10 -0800 Subject: [PATCH 14/32] Update .detoxrc.js --- packages/sdk/react-native/example/.detoxrc.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/sdk/react-native/example/.detoxrc.js b/packages/sdk/react-native/example/.detoxrc.js index d6b62c9e21..8882fb4897 100644 --- a/packages/sdk/react-native/example/.detoxrc.js +++ b/packages/sdk/react-native/example/.detoxrc.js @@ -54,6 +54,31 @@ module.exports = { }, }, }, + artifacts: { + rootDir: '.artifacts', + pathBuilder: './config/pathbuilder.js', + plugins: { + instruments: { enabled: false }, + log: { enabled: true }, + uiHierarchy: 'enabled', + screenshot: { + shouldTakeAutomaticSnapshots: true, + keepOnlyFailedTestsArtifacts: true, + takeWhen: { + testStart: false, + testDone: true, + }, + }, + video: { + android: { + bitRate: 4000000, + }, + simulator: { + codec: 'hevc', + }, + }, + }, + }, configurations: { 'ios.sim.debug': { device: 'simulator', From 95e6da1e27c8df94d3f2bc7b39cf832850dfc1f7 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 9 Feb 2024 22:58:11 -0800 Subject: [PATCH 15/32] Update starter.test.ts --- packages/sdk/react-native/example/e2e/starter.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/sdk/react-native/example/e2e/starter.test.ts b/packages/sdk/react-native/example/e2e/starter.test.ts index 06fca10898..52aa330f62 100644 --- a/packages/sdk/react-native/example/e2e/starter.test.ts +++ b/packages/sdk/react-native/example/e2e/starter.test.ts @@ -34,6 +34,7 @@ describe('Example', () => { }); test('variation', async () => { + await device.disableSynchronization(); await waitFor(element(by.id('flagKey'))) .toBeVisible() .withTimeout(2000); @@ -42,5 +43,6 @@ describe('Example', () => { await waitFor(element(by.text(/my-boolean-flag-2: true/i))) .toBeVisible() .withTimeout(2000); + await device.enableSynchronization(); }); }); From e7874af474a73e2adb17be5868ed966e5d0388e7 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 12 Feb 2024 11:48:56 -0800 Subject: [PATCH 16/32] chore: Attempt to fix broken variation test. --- .github/workflows/react-native.yml | 70 +++++++++++++------ packages/sdk/react-native/example/.detoxrc.js | 25 ------- .../react-native/example/e2e/starter.test.ts | 5 -- .../sdk/react-native/example/package.json | 2 +- 4 files changed, 50 insertions(+), 52 deletions(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 11779d433d..d28f9a5c06 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -11,17 +11,17 @@ on: - '**.md' jobs: - 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 + # 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 @@ -29,9 +29,28 @@ jobs: permissions: id-token: write contents: read + defaults: + run: + working-directory: packages/sdk/react-native/example steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + 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 @@ -40,18 +59,27 @@ jobs: key: ${{ runner.os }}-detox-build restore-keys: | ${{ runner.os }}-detox-build + + - name: Detox rebuild framework cache + run: 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: Install and run tests + + - name: Set mobile key + run: echo "MOBILE_KEY=$MOBILE_KEY" > .env + + - name: Expo prebuild run: | - brew tap wix/brew - brew install applesimutils - cd packages/sdk/react-native/example - echo "MOBILE_KEY=$MOBILE_KEY" > .env - ./build-run-detox.sh - env: - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_INSTALL_CLEANUP: 1 + 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 diff --git a/packages/sdk/react-native/example/.detoxrc.js b/packages/sdk/react-native/example/.detoxrc.js index 8882fb4897..d6b62c9e21 100644 --- a/packages/sdk/react-native/example/.detoxrc.js +++ b/packages/sdk/react-native/example/.detoxrc.js @@ -54,31 +54,6 @@ module.exports = { }, }, }, - artifacts: { - rootDir: '.artifacts', - pathBuilder: './config/pathbuilder.js', - plugins: { - instruments: { enabled: false }, - log: { enabled: true }, - uiHierarchy: 'enabled', - screenshot: { - shouldTakeAutomaticSnapshots: true, - keepOnlyFailedTestsArtifacts: true, - takeWhen: { - testStart: false, - testDone: true, - }, - }, - video: { - android: { - bitRate: 4000000, - }, - simulator: { - codec: 'hevc', - }, - }, - }, - }, configurations: { 'ios.sim.debug': { device: 'simulator', diff --git a/packages/sdk/react-native/example/e2e/starter.test.ts b/packages/sdk/react-native/example/e2e/starter.test.ts index 52aa330f62..af4f80c742 100644 --- a/packages/sdk/react-native/example/e2e/starter.test.ts +++ b/packages/sdk/react-native/example/e2e/starter.test.ts @@ -34,15 +34,10 @@ describe('Example', () => { }); test('variation', async () => { - await device.disableSynchronization(); - await waitFor(element(by.id('flagKey'))) - .toBeVisible() - .withTimeout(2000); await element(by.id('flagKey')).replaceText('my-boolean-flag-2'); await waitFor(element(by.text(/my-boolean-flag-2: true/i))) .toBeVisible() .withTimeout(2000); - await device.enableSynchronization(); }); }); diff --git a/packages/sdk/react-native/example/package.json b/packages/sdk/react-native/example/package.json index dace4a498f..1802b1a460 100644 --- a/packages/sdk/react-native/example/package.json +++ b/packages/sdk/react-native/example/package.json @@ -17,7 +17,7 @@ "clean": "yarn expo-prebuild && yarn cache clean && rm -rf node_modules && rm -rf .expo", "link-dev": "(cd .. && yarn build)", "detox-build-ios": "detox build -c ios.sim.release", - "detox-run-ios": "detox test -c ios.sim.release --cleanup --headless --take-screenshots failing --record-videos failing -l trace", + "detox-run-ios": "detox test -c ios.sim.release --cleanup --headless", "detox-ios": "yarn detox-build-ios && yarn detox-run-ios", "test": "./build-run-detox.sh" }, From 42c17bcb4b40b8b0306b1890b238b435f3095c99 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 12 Feb 2024 11:53:47 -0800 Subject: [PATCH 17/32] Update react-native.yml --- .github/workflows/react-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index d28f9a5c06..6ec2b9cd29 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -61,7 +61,7 @@ jobs: ${{ runner.os }}-detox-build - name: Detox rebuild framework cache - run: detox rebuild-framework-cache + run: yarn detox rebuild-framework-cache - uses: ./actions/release-secrets name: 'Get mobile key' From fe71d081906f80bdaa7bb62560b9746d19b4564b Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 12 Feb 2024 12:17:04 -0800 Subject: [PATCH 18/32] Update welcome.tsx --- packages/sdk/react-native/example/src/welcome.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sdk/react-native/example/src/welcome.tsx b/packages/sdk/react-native/example/src/welcome.tsx index 8bcc28e57d..4318ba7d4d 100644 --- a/packages/sdk/react-native/example/src/welcome.tsx +++ b/packages/sdk/react-native/example/src/welcome.tsx @@ -26,7 +26,6 @@ export default function Welcome() { {flagKey}: {`${flagValue}`} - context: {JSON.stringify(ldc.getContext(), null, 2)} Date: Mon, 12 Feb 2024 12:37:42 -0800 Subject: [PATCH 19/32] chore: Restore build-test job. --- .github/workflows/react-native.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 6ec2b9cd29..3a3c2698ba 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -11,17 +11,17 @@ on: - '**.md' jobs: - # 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 + 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 From 0ea0b57c1289f975208d13f52c6e1abae1476b57 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 12 Feb 2024 14:08:33 -0800 Subject: [PATCH 20/32] chore: Added scrollable output. --- packages/sdk/react-native/example/src/welcome.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/sdk/react-native/example/src/welcome.tsx b/packages/sdk/react-native/example/src/welcome.tsx index 4318ba7d4d..f5447f65df 100644 --- a/packages/sdk/react-native/example/src/welcome.tsx +++ b/packages/sdk/react-native/example/src/welcome.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native'; +import { ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native'; import { ConnectionMode } from '@launchdarkly/js-client-sdk-common'; import { useBoolVariation, useLDClient } from '@launchdarkly/react-native-client-sdk'; @@ -20,12 +20,17 @@ export default function Welcome() { ldc.setConnectionMode(m); }; + const context = ldc.getContext() ?? 'No context identified.'; + return ( Welcome to LaunchDarkly {flagKey}: {`${flagValue}`} + + Logging: {JSON.stringify(context, null, 2)} + Date: Fri, 16 Feb 2024 10:54:20 -0800 Subject: [PATCH 21/32] Update react-native.yml --- .github/workflows/react-native.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 3a3c2698ba..933e1051f3 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -34,11 +34,12 @@ jobs: working-directory: packages/sdk/react-native/example steps: - uses: actions/checkout@v4 + - name: Enable Corepack + run: corepack enable - name: Setup Node.js uses: actions/setup-node@v4 with: cache: yarn - cache-dependency-path: 'packages/sdk/react-native/example/yarn.lock' - name: Install Yarn dependencies run: yarn install --immutable From fdfabda88df515a9aa24aceea124474f63b2d560 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 16 Feb 2024 11:17:58 -0800 Subject: [PATCH 22/32] Update react-native.yml --- .github/workflows/react-native.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 933e1051f3..9eca33d0ed 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -38,9 +38,6 @@ jobs: run: corepack enable - name: Setup Node.js uses: actions/setup-node@v4 - with: - cache: yarn - - name: Install Yarn dependencies run: yarn install --immutable From 954a7ca2b1fd6b2c417466cc59133ef0e234fa9a Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 16 Feb 2024 11:20:35 -0800 Subject: [PATCH 23/32] Update react-native.yml --- .github/workflows/react-native.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 9eca33d0ed..dd592dfd02 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -39,8 +39,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 - name: Install Yarn dependencies - run: yarn install --immutable - + run: yarn - name: Install macOS dependencies run: | brew tap wix/brew From d776b85b88744c98bd2422eb6c695ac374854306 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 16 Feb 2024 14:57:24 -0800 Subject: [PATCH 24/32] Update package.json --- packages/sdk/react-native/example/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sdk/react-native/example/package.json b/packages/sdk/react-native/example/package.json index 14b313937c..572c65d662 100644 --- a/packages/sdk/react-native/example/package.json +++ b/packages/sdk/react-native/example/package.json @@ -41,5 +41,6 @@ "jest": "^29.7.0", "ts-jest": "^29.1.1", "typescript": "^5.2.2" - } + }, + "packageManager": "yarn@3.4.1" } From eacb54ed2662f7a60a2bd5c4f1253689f839d2f8 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 16 Feb 2024 15:53:05 -0800 Subject: [PATCH 25/32] Update react-native.yml --- .github/workflows/react-native.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index dd592dfd02..245afe6d68 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -34,12 +34,10 @@ jobs: working-directory: packages/sdk/react-native/example steps: - uses: actions/checkout@v4 - - name: Enable Corepack - run: corepack enable - name: Setup Node.js uses: actions/setup-node@v4 - name: Install Yarn dependencies - run: yarn + run: cd ../../../../ && yarn && yarn build - name: Install macOS dependencies run: | brew tap wix/brew From 017a574066782168002c6ba1586e1fa15e7d54f0 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Fri, 16 Feb 2024 15:56:33 -0800 Subject: [PATCH 26/32] Update react-native.yml --- .github/workflows/react-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 245afe6d68..6711df02d8 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -37,7 +37,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 - name: Install Yarn dependencies - run: cd ../../../../ && yarn && yarn build + run: cd ../../../../ && yarn --no-immutable && yarn build - name: Install macOS dependencies run: | brew tap wix/brew From 23190fb3be90702ac3e348c78861a1d0c8ef3f61 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 19 Feb 2024 21:19:31 -0800 Subject: [PATCH 27/32] fix: Set hoisting limits so example app uses its own external deps. --- packages/sdk/react-native/example/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sdk/react-native/example/package.json b/packages/sdk/react-native/example/package.json index 572c65d662..d9f4a7dfe2 100644 --- a/packages/sdk/react-native/example/package.json +++ b/packages/sdk/react-native/example/package.json @@ -42,5 +42,8 @@ "ts-jest": "^29.1.1", "typescript": "^5.2.2" }, - "packageManager": "yarn@3.4.1" + "packageManager": "yarn@3.4.1", + "installConfig": { + "hoistingLimits": "workspaces" + } } From 9c23a755e9aeca3ce73c6a2798a346dba95da095 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 19 Feb 2024 22:09:22 -0800 Subject: [PATCH 28/32] chore: Install only packages for example app. --- .github/workflows/react-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 6711df02d8..161a56705f 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -37,7 +37,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 - name: Install Yarn dependencies - run: cd ../../../../ && yarn --no-immutable && yarn build + run: yarn workspaces focus packages/sdk/react-native/example - name: Install macOS dependencies run: | brew tap wix/brew From 0b10bc8aa1c866864a8cc93cf49cc7bafb3c30a7 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 19 Feb 2024 22:15:56 -0800 Subject: [PATCH 29/32] Update react-native.yml --- .github/workflows/react-native.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 161a56705f..7f7608a502 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -71,6 +71,8 @@ jobs: run: | export NO_FLIPPER=1 yarn expo-prebuild + # HACK: this is needed to solve an xcode build issue with rn 0.73 + # https://github.com/facebook/react-native/issues/42112#issuecomment-1884536225 rm -rf ./ios/.xcode.env.local - name: Detox build From c3c6e1784cbb4093aa6ace3bc4a1cbc68e6f575d Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 19 Feb 2024 22:18:57 -0800 Subject: [PATCH 30/32] Update react-native.yml --- .github/workflows/react-native.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 7f7608a502..f07e765fe6 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -37,7 +37,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 - name: Install Yarn dependencies - run: yarn workspaces focus packages/sdk/react-native/example + run: yarn workspaces focus - name: Install macOS dependencies run: | brew tap wix/brew From 51bbe238873ab377d1a0c9cdf152d9a53b878657 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 19 Feb 2024 22:43:10 -0800 Subject: [PATCH 31/32] Update react-native.yml --- .github/workflows/react-native.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index f07e765fe6..7cd427406a 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -68,11 +68,11 @@ jobs: run: echo "MOBILE_KEY=$MOBILE_KEY" > .env - name: Expo prebuild + # HACK: Deleting ios/.xcode.env.local is needed to solve an xcode build issue with rn 0.73 + # https://github.com/facebook/react-native/issues/42112#issuecomment-1884536225 run: | export NO_FLIPPER=1 yarn expo-prebuild - # HACK: this is needed to solve an xcode build issue with rn 0.73 - # https://github.com/facebook/react-native/issues/42112#issuecomment-1884536225 rm -rf ./ios/.xcode.env.local - name: Detox build From 3c0aee8c3aa4c82d868382f4ec3591060d48a632 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 19 Feb 2024 23:02:09 -0800 Subject: [PATCH 32/32] Update react-native.yml --- .github/workflows/react-native.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 7cd427406a..6f5422c279 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -36,8 +36,10 @@ jobs: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 - - name: Install Yarn dependencies + - name: Install deps run: yarn workspaces focus + - name: Build + run: yarn workspaces foreach -pR --topological-dev --from 'react-native-example' run build - name: Install macOS dependencies run: | brew tap wix/brew