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

Enable testing on Windows (node and electron) #6067

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
51 changes: 28 additions & 23 deletions .github/workflows/pr-realm-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ jobs:
fail-fast: false
matrix:
variant:
- { os: linux, runner: ubuntu-latest, arch: x64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: linux, runner: ubuntu-latest, arch: arm, artifact-path: packages/realm/prebuilds }
- { os: linux, runner: ubuntu-latest, arch: arm64, artifact-path: packages/realm/prebuilds }
# - { os: linux, runner: ubuntu-latest, arch: x64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
# - { os: linux, runner: ubuntu-latest, arch: arm, artifact-path: packages/realm/prebuilds }
# - { os: linux, runner: ubuntu-latest, arch: arm64, artifact-path: packages/realm/prebuilds }
- { os: windows, runner: windows-latest, arch: x64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: windows, runner: windows-2019, arch: ia32, artifact-path: packages/realm/prebuilds }
- { os: android, runner: ubuntu-latest, arch: x86_64, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
- { os: android, runner: ubuntu-latest, arch: armeabi-v7a, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
- { os: android, runner: ubuntu-latest, arch: arm64-v8a, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
- { os: android, runner: ubuntu-latest, arch: x86, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
- { os: darwin, runner: macos-latest, arch: x64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: darwin, runner: macos-latest, arch: arm64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: ios, runner: macos-latest, arch: simulator, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
- { os: ios, runner: macos-latest, arch: catalyst, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
- { os: ios, runner: macos-latest, arch: ios, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
# - { os: android, runner: ubuntu-latest, arch: x86_64, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
# - { os: android, runner: ubuntu-latest, arch: armeabi-v7a, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
# - { os: android, runner: ubuntu-latest, arch: arm64-v8a, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
# - { os: android, runner: ubuntu-latest, arch: x86, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
# - { os: darwin, runner: macos-latest, arch: x64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
# - { os: darwin, runner: macos-latest, arch: arm64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
# - { os: ios, runner: macos-latest, arch: simulator, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
# - { os: ios, runner: macos-latest, arch: catalyst, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
# - { os: ios, runner: macos-latest, arch: ios, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -250,17 +250,17 @@ jobs:
fail-fast: false
matrix:
variant:
- { os: linux, target: "test:ci", runner: ubuntu-latest, environment: node }
- { os: linux, target: "test:ci:main", runner: ubuntu-latest, environment: electron }
- { os: linux, target: "test:ci:renderer", runner: ubuntu-latest, environment: electron }
#- { os: windows, target: "test:ci", runner: windows-latest, environment: node}
#- { os: windows, target: "test:ci:main", runner: windows-latest, environment: electron }
#- { os: windows, target: "test:ci:renderer", runner: windows-latest, environment: electron }
- { os: darwin, target: "test:ci:main", runner: macos-latest, environment: electron }
- { os: darwin, target: "test:ci:renderer", runner: macos-latest, environment: electron }
- { os: darwin, target: "test:ci", runner: macos-latest, environment: node }
- { os: android, target: "test:ci:android", runner: macos-latest, environment: react-native, arch: "armeabi-v7a" }
- { os: ios, target: "test:ci:ios", runner: macos-latest, environment: react-native, arch: "ios" }
# - { os: linux, target: "test:ci", runner: ubuntu-latest, environment: node }
# - { os: linux, target: "test:ci:main", runner: ubuntu-latest, environment: electron }
# - { os: linux, target: "test:ci:renderer", runner: ubuntu-latest, environment: electron }
- { os: windows, target: "test:ci", runner: windows-latest, environment: node}
- { os: windows, target: "test:ci:main", runner: windows-latest, environment: electron }
- { os: windows, target: "test:ci:renderer", runner: windows-latest, environment: electron }
# - { os: darwin, target: "test:ci:main", runner: macos-latest, environment: electron }
# - { os: darwin, target: "test:ci:renderer", runner: macos-latest, environment: electron }
# - { os: darwin, target: "test:ci", runner: macos-latest, environment: node }
# - { os: android, target: "test:ci:android", runner: macos-latest, environment: react-native, arch: "armeabi-v7a" }
# - { os: ios, target: "test:ci:ios", runner: macos-latest, environment: react-native, arch: "ios" }
#- { os: ios, target: "test:ci:catalyst", runner: macos-latest, environment: react-native, arch: "catalyst" }
timeout-minutes: 60
steps:
Expand All @@ -277,13 +277,15 @@ jobs:

- name: Generate server configuration
id: baas-config
shell: bash
run:
suffix=$(node -p 'Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)');
subdomain="realm-js-test-server-${{ github.run_id }}-${{ github.run_attempt }}-${suffix}";
echo "subdomain=${subdomain}" >> $GITHUB_OUTPUT;
echo "url=https://${subdomain}.ngrok.io" >> $GITHUB_OUTPUT;

- name: Trigger the test server workflow to start the server
shell: bash
run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }}
env:
GH_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -364,13 +366,16 @@ jobs:

- name: Create Mocha Remote Context
id: mocha-env
shell: bash
run: echo "context=syncLogLevel=warn,longTimeout=${{ env.LONG_TIMEOUT }},realmBaseUrl=${{ steps.baas-config.outputs.url }}" >> $GITHUB_OUTPUT

- name: Wait for the server to start
shell: bash
run: npx wait-on ${{ steps.baas-config.outputs.url }}

- name: Run ${{matrix.variant.target}} (${{ matrix.variant.os}} / ${{ matrix.variant.environment }})
if: ${{ (matrix.variant.os != 'android') && (matrix.variant.os != 'ios') }}
shell: bash
env:
MOCHA_REMOTE_CONTEXT: ${{ steps.mocha-env.outputs.context }}
# The non react native environments should not take so long
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/tests/src/hooks/open-realm-before.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import Realm, { User } from "realm";
import { deleteRealm } from "../utils/delete-realm";

import { openRealm, OpenRealmConfiguration } from "../utils/open-realm";

Expand Down Expand Up @@ -50,10 +51,10 @@
// Get rid of the Realm in any case
delete this.realm;
if (deleteFile) {
Realm.deleteFile(actualConfig);
await deleteRealm(actualConfig);
}
if (clearTestState) {
Realm.clearTestState();

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci) for node on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:main) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:main) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:main) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:main) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:main) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:main) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:main) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:main) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:renderer) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:renderer) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:renderer) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:renderer) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:renderer) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:renderer) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:renderer) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:renderer) for electron on windows

Async open canceled

Check failure on line 57 in integration-tests/tests/src/hooks/open-realm-before.ts

View workflow job for this annotation

GitHub Actions / Integration tests (test:ci:renderer) for electron on windows

Async open canceled
}
if (reopen) {
const { realm } = await openRealm(actualConfig, this.user as unknown as User);
Expand Down
6 changes: 4 additions & 2 deletions integration-tests/tests/src/tests/sync/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { generatePartition } from "../../utils/generators";
import { baseUrl } from "../../utils/import-app";
import { select } from "../../utils/select";
import { buildAppConfig } from "../../utils/build-app-config";
import { deleteRealm } from "../../utils/delete-realm";

const TestObjectSchema: Realm.ObjectSchema = {
primaryKey: "_id",
Expand Down Expand Up @@ -321,7 +322,8 @@ describe("App", () => {
_sessionStopPolicy: "immediately", // Make it safe to delete files after realm.close()
},
};
Realm.deleteFile(realmConfig);
await deleteRealm(realmConfig);

const realm = await Realm.open(realmConfig);
expect(nCalls).equals(1);
realm.write(() => {
Expand All @@ -344,7 +346,7 @@ describe("App", () => {
expect(realm.objects("Dog").length).equals(2);
realm.close();

Realm.deleteFile(realmConfig);
await deleteRealm(realmConfig);

const realm2 = await Realm.open(realmConfig);
expect(nCalls).equals(2);
Expand Down
8 changes: 6 additions & 2 deletions integration-tests/tests/src/tests/sync/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////
import { expect } from "chai";
import Realm from "realm";
import Realm, { SessionStopPolicy } from "realm";
import { authenticateUserBefore, importAppBefore, openRealmBefore } from "../../hooks";
import { expectDecimalEqual } from "../../utils/comparisons";
import { itUploadsDeletesAndDownloads } from "./upload-delete-download";
Expand Down Expand Up @@ -46,7 +46,11 @@ describe.skipIf(environment.missingServer, "Type roundtrip of Dictionary object"

openRealmBefore({
schema: [DictionaryObject],
sync: { partitionValue: "dictionary-test" },
sync: {
partitionValue: "dictionary-test",
// @ts-expect-error this setting is not for users to consume
_sessionStopPolicy: SessionStopPolicy.Immediately,
},
});

const expectedObject = {
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/tests/src/tests/sync/flexible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ describe.skipIf(environment.missingServer, "Flexible sync", function () {
expect(realm.subscriptions.state).to.equal(Realm.App.Sync.SubscriptionSetState.Complete);
} finally {
if (closeRealmAfter) {
closeRealm(realm);
await closeRealm(realm);
}
}

Expand All @@ -370,7 +370,7 @@ describe.skipIf(environment.missingServer, "Flexible sync", function () {
try {
expect(result).to.be.instanceOf(Promise);
} finally {
closeRealm(await result);
await closeRealm(await result);
}
});

Expand All @@ -383,7 +383,7 @@ describe.skipIf(environment.missingServer, "Flexible sync", function () {
expect(realm.subscriptions).to.have.length(1);
expect(realm.subscriptions.state).to.equal(Realm.App.Sync.SubscriptionSetState.Complete);

closeRealm(realm);
await closeRealm(realm);
});

it("updates the subscriptions on first open if rerunOnOpen is undefined", async function (this: RealmContext) {
Expand All @@ -408,7 +408,7 @@ describe.skipIf(environment.missingServer, "Flexible sync", function () {
const realm2 = await openRealm(this.user);
expect(realm2.subscriptions).to.have.length(0);

closeRealm(realm2);
await closeRealm(realm2);
});

it("does not update the subscriptions on second open if rerunOnOpen is false", async function (this: RealmContext) {
Expand All @@ -421,7 +421,7 @@ describe.skipIf(environment.missingServer, "Flexible sync", function () {
const realm2 = await openRealm(this.user);
expect(realm2.subscriptions).to.have.length(0);

closeRealm(realm2);
await closeRealm(realm2);
});

it("does update the subscriptions on second open if rerunOnOpen is true", async function (this: RealmContext) {
Expand Down
25 changes: 13 additions & 12 deletions integration-tests/tests/src/tests/sync/partition-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { authenticateUserBefore } from "../../hooks/authenticate-user-before";
import { importAppBefore } from "../../hooks/import-app-before";
import { generatePartition } from "../../utils/generators";
import { buildAppConfig } from "../../utils/build-app-config";
import { deleteRealm } from "../../utils/delete-realm";

const PvIntDog = {
name: "Dog",
Expand Down Expand Up @@ -133,7 +134,7 @@ describe("Partition-values", () => {
const realmConfigSecondary = createConfig(PvIntDog, this.user, 43);

// ensure clean starting point
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm1 = await Realm.open(realmConfigPrimary);
realm1.write(() => {
Expand All @@ -145,7 +146,7 @@ describe("Partition-values", () => {
realm1.close();

// cleanup, re-sync & check changes are synced
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm2 = await Realm.open(realmConfigPrimary);
await realm2.syncSession?.downloadAllServerChanges();
Expand All @@ -154,7 +155,7 @@ describe("Partition-values", () => {
realm2.close();

// cleanup & re-sync with different partitionValue
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm3 = await Realm.open(realmConfigSecondary);
await realm3.syncSession?.downloadAllServerChanges();
Expand All @@ -173,7 +174,7 @@ describe("Partition-values", () => {
const realmConfigSecondary = createConfig(PvStringDog, this.user, "43");

// ensure clean starting point
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm1 = await Realm.open(realmConfigPrimary);
realm1.write(() => {
Expand All @@ -185,7 +186,7 @@ describe("Partition-values", () => {
realm1.close();

// cleanup, re-sync & check changes are synced
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm2 = await Realm.open(realmConfigPrimary);
await realm2.syncSession?.downloadAllServerChanges();
Expand All @@ -194,7 +195,7 @@ describe("Partition-values", () => {
realm2.close();

// cleanup & re-sync with different partitionValue
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm3 = await Realm.open(realmConfigSecondary);
await realm3.syncSession?.downloadAllServerChanges();
Expand All @@ -221,7 +222,7 @@ describe("Partition-values", () => {
);

// ensure clean starting point
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm1 = await Realm.open(realmConfigPrimary);
realm1.write(() => {
Expand All @@ -233,7 +234,7 @@ describe("Partition-values", () => {
realm1.close();

// cleanup, re-sync & check changes are synced
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm2 = await Realm.open(realmConfigPrimary);
await realm2.syncSession?.downloadAllServerChanges();
Expand All @@ -242,7 +243,7 @@ describe("Partition-values", () => {
realm2.close();

// cleanup & re-sync with different partitionValue
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm3 = await Realm.open(realmConfigSecondary);
await realm3.syncSession?.downloadAllServerChanges();
Expand All @@ -265,7 +266,7 @@ describe("Partition-values", () => {
);

// ensure clean starting point
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);
const realm1 = await Realm.open(realmConfigPrimary);
realm1.write(() => {
realm1.create("Dog", { _id: new BSON.ObjectId(), name: "King" });
Expand All @@ -275,7 +276,7 @@ describe("Partition-values", () => {
await realm1.syncSession?.uploadAllLocalChanges();
realm1.close();

Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm2 = await Realm.open(realmConfigPrimary);
await realm2.syncSession?.downloadAllServerChanges();
Expand All @@ -284,7 +285,7 @@ describe("Partition-values", () => {
realm2.close();

// cleanup & re-sync with different partitionValue
Realm.deleteFile(realmConfigPrimary);
await deleteRealm(realmConfigPrimary);

const realm3 = await Realm.open(realmConfigSecondary);
await realm3.syncSession?.downloadAllServerChanges();
Expand Down
Loading
Loading