Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit e78af59

Browse files
authored
Completely rework CI build to not use hello-react-native (#109)
1 parent f38a2aa commit e78af59

File tree

11 files changed

+179
-115
lines changed

11 files changed

+179
-115
lines changed

.circleci/config.yml

Lines changed: 99 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,117 @@
11
version: 2.1
22

3-
orbs:
4-
android: circleci/[email protected]
5-
node: circleci/[email protected]
6-
7-
aliases:
8-
- &use_local_sdk
9-
name: Set hello application to use local SDK and RN version
10-
command: |
11-
cd ../hello-react-native
12-
TEMP_FILE=`mktemp -u` || exit 1
13-
sed 's/"launchdarkly-react-native-client-sdk" *: *"[^"]*" *, *$/"launchdarkly-react-native-client-sdk": "file:..\/project"\,/' 'package.json' > $TEMP_FILE
14-
mv $TEMP_FILE 'package.json'
15-
163
jobs:
17-
android:
4+
# This job simulates integrating the SDK into a freshly created React Native project template and
5+
# then builds Android and iOS applications using the template.
6+
build-applications-using-template:
187
parameters:
19-
hello-app-branch:
8+
rn-version:
9+
description: The React Native project template version
10+
type: string
11+
xcode-version:
12+
description: The Xcode version to build with
2013
type: string
2114

22-
executor:
23-
name: android/android-machine
24-
resource-class: large
15+
macos:
16+
xcode: <<parameters.xcode-version>>
17+
resource_class: macos.x86.medium.gen2
18+
19+
environment:
20+
ANDROID_SDK_ROOT: "/tmp/Android"
2521

2622
steps:
2723
- checkout
2824

29-
- run: cd .. && git clone --depth 1 https://github.com/launchdarkly/hello-react-native.git -b <<parameters.hello-app-branch>>
30-
- run: *use_local_sdk
31-
- node/install:
32-
lts: true
33-
install-yarn: true
3425
- run:
35-
name: Build bundle
26+
name: Download Android command line tools
3627
command: |
37-
cd ../hello-react-native
38-
npx yarn install
39-
npx react-native bundle --entry-file index.js --platform android --bundle-output android/main.jsbundle --assets-dest android
28+
mkdir -p $ANDROID_SDK_ROOT/cmdline-tools/latest
29+
curl https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip -o cmdline-tools.zip
30+
unzip cmdline-tools.zip
31+
mv cmdline-tools/* $ANDROID_SDK_ROOT/cmdline-tools/latest/
32+
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null || true
33+
4034
- run:
41-
name: Setup debug keystore
35+
name: Setup Android debug keystore
4236
command: |
4337
keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "cn=Unknown, ou=Unknown, o=Unknown, c=Unknown"
44-
cp debug.keystore ../hello-react-native/android/app/
4538
mkdir -p ~/.android
4639
cp debug.keystore ~/.android/
47-
- run: cd ../hello-react-native/android && ./gradlew packageDebug
4840
49-
ios:
50-
parameters:
51-
hello-app-branch:
52-
type: string
53-
macos:
54-
xcode: "12.4.0"
55-
steps:
56-
- checkout
57-
- run: cd .. && git clone --depth 1 https://github.com/launchdarkly/hello-react-native.git -b <<parameters.hello-app-branch>>
58-
- run: *use_local_sdk
59-
- run: cd ../hello-react-native && npx yarn install
41+
- restore_cache:
42+
name: Restore RN project template from cache
43+
key: v1-rn-template-cache-<<parameters.rn-version>>
44+
45+
- run:
46+
name: Create CI test application for RN <<parameters.rn-version>>
47+
command: |
48+
[ -d "CITest" ] || npx react-native init CITest --version <<parameters.rn-version>> --skip-install
49+
50+
- save_cache:
51+
name: Save RN project template to cache
52+
key: v1-rn-template-cache-<<parameters.rn-version>>
53+
paths:
54+
- CITest
55+
56+
# See the `patches` directory
6057
- run:
61-
name: Build bundle
58+
name: Do any necessary patching
6259
command: |
63-
cd ../hello-react-native
64-
npx yarn install
65-
npx react-native bundle --entry-file index.js --platform ios --bundle-output ios/main.jsbundle --assets-dest ios
60+
if [ -d ".circleci/patches/<<parameters.rn-version>>" ]; then cp -r .circleci/patches/<<parameters.rn-version>>/* CITest/; fi
61+
if [ -x "CITest/patch.sh" ] ; then cd CITest && ./patch.sh; fi
62+
63+
- run:
64+
name: Add LaunchDarkly dependency
65+
command: cd CITest && npx yarn add file:..
66+
67+
- restore_cache:
68+
name: Restore gem cache
69+
key: v1-gem-cache-<<parameters.xcode-version>>-
70+
71+
# Newer cocoapods fixes Swift library auto-linking errors
6672
- run:
67-
name: Build application
73+
name: Update CocoaPods
6874
command: |
69-
cd ../hello-react-native/ios
70-
# Newer cocoapods required for following pod install
7175
sudo gem install cocoapods
72-
# RN 0.64 has an issue with embedding absolute paths in the cocoapods generated build files, so must regenerate.
73-
# https://github.com/facebook/react-native/issues/31121
74-
pod update
75-
pod install
76-
xcodebuild build -workspace HelloReactNative.xcworkspace -configuration Release -scheme HelloReactNative -sdk iphonesimulator -arch x86_64 CODE_SIGN_IDENTITY=
76+
sudo gem cleanup
77+
# Used as cache key to prevent storing redundant caches
78+
gem list > /tmp/cache-key.txt
7779
78-
common:
80+
- save_cache:
81+
name: Save gem cache
82+
key: v1-gem-cache-<<parameters.xcode-version>>-{{ checksum "/tmp/cache-key.txt" }}
83+
paths:
84+
- ~/.gem
85+
86+
- run:
87+
name: Install iOS Pods
88+
command: cd CITest/ios && pod install
89+
90+
- run:
91+
name: Build application for iOS (Release)
92+
command: |
93+
mkdir -p artifacts
94+
cd CITest/ios
95+
xcodebuild -workspace CITest.xcworkspace -scheme CITest build -configuration Release -destination "generic/platform=iOS" CODE_SIGNING_ALLOWED=NO GCC_WARN_INHIBIT_ALL_WARNINGS=YES | tee '../../artifacts/xcb-<<parameters.rn-version>>.txt' | xcpretty
96+
97+
- when:
98+
# We only care to build Android application and debug iOS Build for a single XCode version
99+
condition:
100+
equal: [ 13.2.1, << parameters.xcode-version >> ]
101+
steps:
102+
- run:
103+
name: Build application for iOS (Debug)
104+
command: |
105+
cd CITest/ios
106+
xcodebuild -workspace CITest.xcworkspace -scheme CITest build -configuration Debug -destination "generic/platform=iOS" CODE_SIGNING_ALLOWED=NO GCC_WARN_INHIBIT_ALL_WARNINGS=YES | tee '../../artifacts/xcb-<<parameters.rn-version>>.txt' | xcpretty
107+
- run:
108+
name: Build application for Android
109+
command: cd CITest/android && ./gradlew packageRelease
110+
111+
- store_artifacts:
112+
path: artifacts
113+
114+
test-javascript:
79115
docker:
80116
- image: cimg/node:current
81117
steps:
@@ -95,26 +131,14 @@ jobs:
95131

96132
workflows:
97133
version: 2
98-
android-ios:
134+
all-tests:
99135
jobs:
100-
- common
101-
- android:
102-
name: Android + RN 0.63
103-
hello-app-branch: rn-0.63
104-
requires:
105-
- common
106-
- ios:
107-
name: iOS + RN 0.63
108-
hello-app-branch: rn-0.63
109-
requires:
110-
- common
111-
- android:
112-
name: Android + RN 0.64
113-
hello-app-branch: rn-0.64
114-
requires:
115-
- common
116-
- ios:
117-
name: iOS + RN 0.64
118-
hello-app-branch: rn-0.64
136+
- test-javascript
137+
- build-applications-using-template:
138+
name: rn<<matrix.rn-version>>-xc<<matrix.xcode-version>>-build-apps-using-template
139+
matrix:
140+
parameters:
141+
rn-version: ["0.64.3", "0.65.2", "0.66.4", "0.67.2"]
142+
xcode-version: ["12.2.0", "12.5.1", "13.2.1"]
119143
requires:
120-
- common
144+
- test-javascript

.circleci/patches/0.65.2/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Patch for React Native project template 0.65.2
2+
3+
After XCode 12.5, the `RCT-Folly` transitive dependency causes build errors. This patch overrides
4+
some of `RCT-Folly`'s build configurations by patching the template's `Podfile`. See
5+
[facebook/folly#1470](https://github.com/facebook/folly/issues/1470) for more details.

.circleci/patches/0.65.2/patch.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
patch -p0 -u < podfile.patch
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- ios/Podfile
2+
+++ ios/Podfile
3+
@@ -25,5 +25,13 @@
4+
5+
post_install do |installer|
6+
react_native_post_install(installer)
7+
+ installer.pods_project.targets.each do |target|
8+
+ if target.name == "RCT-Folly"
9+
+ target.build_configurations.each do |config|
10+
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
11+
+ config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'FOLLY_HAVE_CLOCK_GETTIME=1']
12+
+ end
13+
+ end
14+
+ end
15+
end
16+
end

.circleci/patches/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Patches for running React Native application templates in CI
2+
3+
Some versions of the React Native project templates no longer function without modification with
4+
newer XCode. We verify this library builds against supported versions of React Native in the
5+
[CircleCI configuration](../.circleci/config.yml) by building the project templates with the SDK
6+
added as a dependency. This directory contains the required files to patch each project template
7+
that we are testing that does not work without modification.
8+
9+
Before installing the dependencies and integrating the SDK into the project, the CI jobs checks here
10+
for a directory with the name of the React Native project template version that is being tested. If
11+
the directory exists, the files are copied into the project. Then, if an executable file called
12+
`patch.sh` now exists in the project template, it is run.
13+
14+
Further details of what patching is required is included in each version's subdirectory.

CONTRIBUTING.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,23 @@ Build instructions
1818

1919
### Prerequisites
2020

21-
This SDK requires that you have [`npm`](https://www.npmjs.com/) and [`react-native-cli`](https://www.npmjs.com/package/react-native-cli) installed in order to develop with it.
21+
Follow the [React Native development environment setup guide](https://reactnative.dev/docs/environment-setup) to install all required tools for contributing to the project.
2222

23-
### Building and running
23+
### Building and testing
2424

25-
You can modify and verify changes by developing within the LaunchDarkly React Native SDK sample application (`hello-react-native`).
25+
First, install the dependencies by running:
26+
```
27+
npm install
28+
```
2629

27-
1. Clone and setup the [`hello-react-native`](https://github.com/launchdarkly/hello-react-native) repository.
28-
2. In your `hello-react-native` directory, copy your `react-native-client-sdk` directory into `node_modules` as `launchdarkly-react-native-client-sdk`. Alternatively, you can use [wml](https://github.com/wix/wml) to monitor and copy files.
29-
3. Launch your emulator (`emulator -avd <NAME>` for Android) or connect your device.
30-
4. Test your changes in `hello-react-native` by running either `react-native run-ios` or `react-native run-android` depending on your desired runtime environment.
30+
To run tests of the JavaScript portion of the implementation:
31+
```
32+
npm test
33+
```
34+
35+
To validate the TypeScript module definition, run:
36+
```
37+
npm run check-typescript
38+
```
39+
40+
Testing the native module implementation must be done by integrating the SDK into an application, such as one created with `npx react-native init`.

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ LaunchDarkly overview
1414
Supported versions
1515
-------------------------
1616

17-
This SDK is currently compatible with React Native 0.63.x - 0.64.x and Xcode 12 and is tested in Android 30 and iOS 14. Earlier versions of this SDK are compatible with prior versions of React Native, Android, and iOS.
17+
This SDK is currently compatible with React Native versions `>=0.64 <0.68`, the minimum iOS deployment target is `10.0`, and the minimum Android SDK version is `21`. Builds are tested with XCode 12.2+.
1818

19-
| SDK version | React Native version |
20-
|----------------------------------|----------------------|
21-
| 4.1.x - current | 0.64.x |
22-
| 5.1.0 - current<br>3.2.x - 4.0.x | 0.63.x |
23-
| 3.1.x | 0.62.x |
19+
For React Native `0.63.x` support, use the latest [`5.1.x` release](https://github.com/launchdarkly/react-native-client-sdk/releases/tag/5.1.1).
2420

2521
Getting started
2622
---------------

ios/LaunchdarklyReactNativeClient.podspec

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'json'
2+
3+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4+
5+
Pod::Spec.new do |s|
6+
s.name = package["name"]
7+
s.version = package["version"]
8+
s.summary = package["description"]
9+
s.homepage = package["homepage"]
10+
s.license = { :type => "Apache-2.0", :file => "LICENSE" }
11+
s.author = { "author" => "[email protected]" }
12+
s.platform = :ios, "10.0"
13+
s.source = { :git => "https://github.com/launchdarkly/react-native-client-sdk.git", :tag => s.version }
14+
s.source_files = "ios/**/*.{h,m,swift}"
15+
s.swift_version = "5.0"
16+
17+
s.dependency "React-Core"
18+
s.dependency "LaunchDarkly", "5.4.4"
19+
20+
end

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)