-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
3,281 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Install test (React Native) | ||
|
||
on: | ||
# Any change to these files | ||
push: | ||
paths: | ||
- install-tests/react-native/** | ||
- .github/workflows/install-test-react-native.yml | ||
# Every day at 9:00 CET | ||
schedule: | ||
- cron: "0 8 * * *" | ||
# 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-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# See https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md#xcode | ||
xcode: | ||
# - 12.5 | ||
- 13.1 | ||
npm: | ||
- 7 | ||
node: | ||
- 14 | ||
env: | ||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- name: Install npm v7 | ||
run: npm install -g npm@7 | ||
- name: ccache | ||
uses: hendrikmuhs/ccache-action@v1 | ||
with: | ||
key: install-test | ||
- 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 }} | ||
- name: Invoke the simulator (making subsequent "open -a Simulator" calls work) | ||
run: open -a ${{ env.DEVELOPER_DIR }}/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
PACKAGE_NAME=realm-js | ||
VERSION=10.20.0-alpha.1 | ||
REALM_CORE_VERSION=11.6.0 | ||
REALM_CORE_VERSION=11.6.1 | ||
NAPI_VERSION=4 | ||
OPENSSL_VERSION=1.1.1g | ||
MDBREALM_TEST_SERVER_TAG=2021-06-01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": [ | ||
"@react-native-community", | ||
"../../.eslintrc" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2021 Realm Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////// | ||
|
||
import { useEffect } from "react"; | ||
import Realm from "realm"; | ||
|
||
const CALLBACK_HOST = "http://localhost:3000"; | ||
const DELAY = 5000; | ||
const schema = [{ name: "Person", properties: { name: "string" } }]; | ||
const App = () => { | ||
useEffect(() => { | ||
const realm = new Realm({ schema }); | ||
// Write persons into the database | ||
if (realm.empty) { | ||
realm.write(() => { | ||
realm.create("Person", { name: "Alice" }); | ||
realm.create("Person", { name: "Bob" }); | ||
realm.create("Person", { name: "Charlie" }); | ||
}); | ||
} | ||
// Read the persons out of the database again | ||
const message = | ||
"Persons are " + | ||
realm | ||
.objects("Person") | ||
.map((p) => p.name) | ||
.join(", "); | ||
console.log(`Sending '${message}'`); | ||
// Perform a request to signal a successful write & read | ||
setTimeout(() => { | ||
fetch(CALLBACK_HOST, { | ||
method: "POST", | ||
body: message, | ||
}).catch(console.error); | ||
}, DELAY); | ||
// Close the Realm when component unmounts | ||
return () => realm.close(); | ||
}, []); | ||
return null; | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
react_native_version="${1:-next}" | ||
realm_version="${2:-latest}" | ||
|
||
echo "Using React Native version = $react_native_version" | ||
echo "Using Realm version = $realm_version" | ||
|
||
APP_DIR="$PWD/`dirname $0`/app" | ||
|
||
# Manually delete any previously created app | ||
if [ -d "$APP_DIR" ]; then | ||
echo "Found an existing app directory: Skipping React Native init" | ||
else | ||
# Create a new React Native app using the desired version | ||
npx --yes react-native@$react_native_version init ReactNativeTestApp --version $react_native_version --directory $APP_DIR --npm | ||
fi | ||
|
||
cd $APP_DIR | ||
# Install CLI tools and Realm (using --force to ignore potential peerDependencies failures) | ||
npm install ios-simulator concurrently retry-cli pod-install realm@$realm_version --force | ||
# Run pod-install again | ||
npx pod-install | ||
# Overwrite the App.js | ||
cp ../App.js . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2021 Realm Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////// | ||
|
||
const { createServer } = require("http"); | ||
|
||
const TIMEOUT = 5 * 60 * 1000; // 5 minutes (although it shouldn't really take more than a minute) | ||
const PORT = 3000; | ||
const EXPECTED_MESSAGE = "Persons are Alice, Bob, Charlie"; | ||
|
||
createServer((req, res) => { | ||
console.log("Client connected"); | ||
req.on("data", (data) => { | ||
const message = data.toString("utf-8"); | ||
res.statusCode = 200; | ||
res.end(); | ||
console.log(`App sent "${message}"!`); | ||
if (message === EXPECTED_MESSAGE) { | ||
console.log("This was expected!"); | ||
process.exit(0); | ||
} else { | ||
console.log(`This was unexpected! (expected ${EXPECTED_MESSAGE})`); | ||
process.exit(1); | ||
} | ||
}); | ||
}).listen(PORT); | ||
|
||
setTimeout(() => { | ||
console.log("It took too long for the app to send the message"); | ||
process.exit(1); | ||
}, TIMEOUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "empty-package-to-avoid-react-native-cli-confusions", | ||
"see": "https://github.com/react-native-community/cli/issues/1493" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
APP_DIR="$PWD/`dirname $0`/app" | ||
PROJECT_ROOT=$APP_DIR/../../.. | ||
|
||
# Manually delete any app previously created | ||
if [ ! -d "$APP_DIR" ]; then | ||
echo "Couldn't locate an app directory, did you run install.sh?" | ||
exit 1 | ||
fi | ||
|
||
# Determine the simulator's UDID | ||
DEVICE_UDID=`npx ios-simulator -n 'iPhone 13'` | ||
# Open the simulator | ||
open -a Simulator --args -CurrentDeviceUDID $DEVICE_UDID | ||
# Await the boot of the device | ||
xcrun simctl bootstatus $DEVICE_UDID | ||
|
||
cd $APP_DIR | ||
|
||
# Build the app (ccache enabled) | ||
RCT_NO_LAUNCH_PACKAGER=1 xcodebuild \ | ||
-workspace ios/ReactNativeTestApp.xcworkspace \ | ||
-configuration Debug \ | ||
-scheme ReactNativeTestApp \ | ||
-derivedDataPath ./build \ | ||
-destination id=$DEVICE_UDID \ | ||
CC="$PROJECT_ROOT/scripts/ccache-clang.sh" \ | ||
CXX="$PROJECT_ROOT/scripts/ccache-clang++.sh" | ||
|
||
# Install the app onto the device | ||
APP_BUNDLE_ID=org.reactjs.native.example.ReactNativeTestApp | ||
APP_BUILD_PATH=./build/Build/Products/Debug-iphonesimulator/ReactNativeTestApp.app | ||
xcrun simctl install $DEVICE_UDID $APP_BUILD_PATH | ||
|
||
# Run the app: Starting the listening server, Metro bundler and delayed launch of the app. | ||
npx concurrently --kill-others --success "first" --names "listen,metro,app" \ | ||
"node ../listen.js" \ | ||
"react-native start" \ | ||
"sleep 5; xcrun simctl launch --console-pty $DEVICE_UDID $APP_BUNDLE_ID" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extension": ["ts"], | ||
"require": ["ts-node/register/transpile-only", "src/utils/inject-node-globals.ts"] | ||
} |
Oops, something went wrong.