Skip to content

Commit

Permalink
Merge from ms/hermes
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck Franck committed Nov 19, 2021
2 parents 95c9781 + 8e7be75 commit 57507e5
Show file tree
Hide file tree
Showing 40 changed files with 3,281 additions and 600 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/install-test-react-native.yml
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ crash.log
examples/ReactExample/ios/Pods/
examples/ReactExample/ios/ReactExample.xcworkspace/
tests/mongodb-realm
install-tests/react-native/app/

# Integration tests
integration-tests/environments/electron/dist/
Expand Down
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@
],
"cwd": "${workspaceFolder}/tests"
},
{
"type": "lldb",
"request": "launch",
"name": "LLDB Debug Integration Tests",
"program": "node",
"args": [
"--expose_gc",
"node_modules/mocha/bin/mocha",
"--require",
"ts-node/register/transpile-only",
"--require",
"src/utils/inject-node-globals.ts",
"src/index.ts",
"--grep",
"${input:integrationTestFilter}"
],
"cwd": "${workspaceFolder}/integration-tests/tests"
}
],
"compounds": [
{
Expand All @@ -112,6 +130,12 @@
"type": "promptString",
"default": ".",
"description": "Filtering used to limit what tests are run"
},
{
"id": "integrationTestFilter",
"type": "promptString",
"default": "",
"description": "Filtering used to limit what tests are run"
}
]
}
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ NOTE: This is an early (alpha) release with Hermes/JSI support. Only iOS is supp
* <Using Realm Core vX.Y.Z>
* <Upgraded Realm Core from vX.Y.Z to vA.B.C>

10.10.1 Release notes (2021-11-18)
=============================================================
### Enhancements
* None.

### Fixed
* A sync user's Realm was not deleted when the user was removed if the Realm path was too long such that it triggered the fallback hashed name (this is OS dependant but is 300 characters on linux). ([realm/realm-core#4187](https://github.com/realm/realm-core/issues/4187), since v10.0.0-beta.10)
* Fixed a bug where opening a synced Realm would hang if the device's clock is more than 30 minutes fast. ([realm/realm-core#4941](https://github.com/realm/realm-core/issues/4941), since v10.0.0)
* Fixed a bug where an app hangs if it tries to connect after being offline for more than 30 minutes. ([#3882](https://github.com/realm/realm-js/issues/3882), since v10.0.0)


### Compatibility
* MongoDB Realm Cloud.
* Realm Studio v11.0.0.
* APIs are backwards compatible with all previous releases of Realm JavaScript in the 10.5.x series.
* File format: generates Realms with format v22 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

### Internal
* Upgraded Realm Core from v11.6.0 to v11.6.1.

10.10.0 Release notes (2021-11-11)
=============================================================

Expand Down
2 changes: 1 addition & 1 deletion dependencies.list
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
6 changes: 6 additions & 0 deletions install-tests/react-native/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"@react-native-community",
"../../.eslintrc"
]
}
57 changes: 57 additions & 0 deletions install-tests/react-native/App.js
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;
27 changes: 27 additions & 0 deletions install-tests/react-native/install.sh
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 .
45 changes: 45 additions & 0 deletions install-tests/react-native/listen.js
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);
4 changes: 4 additions & 0 deletions install-tests/react-native/package.json
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"
}
42 changes: 42 additions & 0 deletions install-tests/react-native/run-ios.sh
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"
6 changes: 6 additions & 0 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ When running the environments individually the test suite's TypeScript is not au
npm run build:watch --prefix tests
```

## Running tests with a C++ debugger attached

In order to debug the tests with `lldb` attached to debug C++, you can use the VS Code launch configuration `LLDB Debug Integration Tests`.

This bypasses the usual startup script (as this spawns a child process for the tests, which stops `lldb` working), so you need to have the app importer running separately when doing this: `npm run app-importer` from the `integration-tests/tests` directory.

### Environment variables

// TODO: Provide an explanation of the environment variables.
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/tests/.mocharc.json
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"]
}
Loading

0 comments on commit 57507e5

Please sign in to comment.