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

Use baasaas on CI #1441

Merged
merged 28 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6789f01
Use baasaas on CI
nirinchev Dec 1, 2023
08b23e4
Remove dependency on realm in the baas client
nirinchev Dec 1, 2023
c461358
Regenerate models
nirinchev Dec 1, 2023
56d8199
Cleanup containers after test runs
nirinchev Dec 1, 2023
dac4274
Fix CI
nirinchev Dec 1, 2023
81f19a0
Try setting the baas url correctly
nirinchev Dec 1, 2023
180f85d
Fix order of test setup
nirinchev Dec 1, 2023
a46bf37
..
nirinchev Dec 1, 2023
a05da4b
Add some missing flutter tests
nirinchev Dec 1, 2023
2ffa076
Try to fix flutter tests
nirinchev Dec 1, 2023
99c58aa
Rework indexed test to use values from the second half of the table.
nirinchev Dec 1, 2023
841649b
Use api key auth
nirinchev Dec 8, 2023
ad2278f
Merge branch 'main' into ni/baasaas
nirinchev Dec 8, 2023
b132782
Post-merge fixes
nirinchev Dec 8, 2023
00eb188
Use endpoints, wire-up differentiator tag
nirinchev Dec 12, 2023
f7a2efb
Guard against incomplete containers
nirinchev Dec 12, 2023
f848a9f
Fix cleanup workflow; fix env variable names
nirinchev Dec 12, 2023
61c84e4
Don't log isolate warnings when the isolate is created by dart test
nirinchev Dec 12, 2023
120e1b5
Pass correct differentiator to android tests
nirinchev Dec 12, 2023
69feaea
Always run cleanup
nirinchev Dec 12, 2023
67b29bf
Rework cleanup command
nirinchev Dec 12, 2023
892c408
Use reporter
nirinchev Dec 13, 2023
3acebef
Don't fail test run on test errors
nirinchev Dec 13, 2023
9d8e858
Fail on error
nirinchev Dec 13, 2023
1cd60ef
Remove failing test
nirinchev Jan 2, 2024
3e3d0bb
Update lib/src/cli/atlas_apps/options.dart
nirinchev Jan 3, 2024
0bc8bec
Support maps (#1406)
nielsenko Jan 3, 2024
466bc9b
Merge main, regenerate cli
nirinchev Jan 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
539 changes: 204 additions & 335 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions .github/workflows/cleanup-clusters.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/create-cluster.yml

This file was deleted.

40 changes: 14 additions & 26 deletions .github/workflows/dart-desktop-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,21 @@ on:
description: Architecture to execute on.
required: false
type: string
app:
description: App name prefix.
required: true
type: string
cluster:
description: Cluster name to deploy.
differentiator:
description: Differentiator for the BaaS container.
required: true
type: string

env:
BAAS_URL: ${{ secrets.REALM_QA_URL }}
BAAS_API_KEY: ${{ secrets.ATLAS_QA_PUBLIC_API_KEY }}
BAAS_PRIVATE_API_KEY: ${{ secrets.ATLAS_QA_PRIVATE_API_KEY }}
BAAS_PROJECT_ID: ${{ secrets.ATLAS_QA_PROJECT_ID}}
REALM_CI: true
BAAS_BAASAAS_API_KEY: ${{ secrets.BAASAAS_API_KEY}}
BAAS_DIFFERENTIATOR: ${{ inputs.differentiator }}

jobs:
dart-tests:
runs-on: ${{ inputs.runner }}
name: Dart tests on ${{inputs.os }} ${{ inputs.architecture }}
timeout-minutes: 45
env:
BAAS_CLUSTER: ${{ inputs.cluster }}
BAAS_DIFFERENTIATOR: ${{ inputs.app }}${{ github.run_id }}${{ github.run_attempt }}

steps:
- name: Checkout
Expand Down Expand Up @@ -68,20 +59,17 @@ jobs:
run: ulimit -n 10240
if: ${{ contains(inputs.os, 'macos') }}

# This will be a no-op under normal circumstances since the cluster would have been deployed
# in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped.
- name: Create cluster
uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7
with:
realmUrl: ${{ env.BAAS_URL }}
atlasUrl: ${{ secrets.ATLAS_QA_URL }}
projectId: ${{ env.BAAS_PROJECT_ID }}
apiKey: ${{ env.BAAS_API_KEY }}
privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }}
clusterName: ${{ env.BAAS_CLUSTER }}

- name: Run tests
run: ${{ inputs.architecture == 'arm' && 'arch -arm64 ' || '' }}dart test -r expanded --coverage ./coverage/ -j 1 --test-randomize-ordering-seed random
run: ${{ inputs.architecture == 'arm' && 'arch -arm64 ' || '' }}dart test -r expanded --coverage ./coverage/ -j 1 --test-randomize-ordering-seed random --file-reporter="json:test-results.json" || true

- name: Publish Test Report
uses: dorny/[email protected]
if: success() || failure()
with:
name: Test Results Dart ${{ inputs.os }} ${{ inputs.architecture }}
path: test-results.json
reporter: dart-json
only-summary: true

# we're pruning generated files, the cli folder, as well as realm_bindings.dart from our coverage reports
- name: Generate realm_dart coverage report
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/deploy-baas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy BaaS and apps

on:
workflow_call:
inputs:
differentiator:
description: Differentiator for the BaaS container.
required: true
type: string

env:
REALM_CI: true

jobs:
deploy-baas:
runs-on: ubuntu-latest
name: Deploy BaaS
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
submodules: false

- name : Setup Dart SDK
uses: dart-lang/setup-dart@main
with:
sdk: stable
architecture: 'x64'

- name: Install dependencies
run: dart pub get

- name: Deploy cluster and apps
run: dart run realm_dart deploy-apps --baasaas-api-key ${{ secrets.BAASAAS_API_KEY }} --differentiator ${{ inputs.differentiator }}
29 changes: 5 additions & 24 deletions .github/workflows/flutter-desktop-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,12 @@ on:
description: Architecture to execute on.
required: false
type: string
app:
description: App name prefix
required: true
type: string
cluster:
description: Cluster name to deploy.
differentiator:
description: Differentiator for the BaaS container.
required: true
type: string

env:
BAAS_URL: ${{ secrets.REALM_QA_URL }}
BAAS_API_KEY: ${{ secrets.ATLAS_QA_PUBLIC_API_KEY }}
BAAS_PRIVATE_API_KEY: ${{ secrets.ATLAS_QA_PRIVATE_API_KEY }}
BAAS_PROJECT_ID: ${{ secrets.ATLAS_QA_PROJECT_ID}}
REALM_CI: true

jobs:
Expand All @@ -37,8 +29,9 @@ jobs:
name: Flutter tests on ${{inputs.os }}-${{ inputs.architecture }}
timeout-minutes: 45
env:
BAAS_CLUSTER: ${{ inputs.cluster }}
BAAS_DIFFERENTIATOR: ${{ inputs.app }}${{ github.run_id }}${{ github.run_attempt }}
BAAS_BAASAAS_API_KEY: ${{ secrets.BAASAAS_API_KEY}}
BAAS_DIFFERENTIATOR: ${{ inputs.differentiator }}

steps:

- name: Checkout
Expand Down Expand Up @@ -78,18 +71,6 @@ jobs:
run: ulimit -n 10240
if: ${{ contains(inputs.os, 'macos') }}

# This will be a no-op under normal circumstances since the cluster would have been deployed
# in deploy-cluster. It is needed in case we want to re-run the job after the cluster has been reaped.
- name: Create cluster
uses: realm/ci-actions/mdb-realm/deploy@338bf3e7575015a28faec8b67614385d122aece7
with:
realmUrl: ${{ env.BAAS_URL }}
atlasUrl: ${{ secrets.ATLAS_QA_URL }}
projectId: ${{ env.BAAS_PROJECT_ID }}
apiKey: ${{ env.BAAS_API_KEY }}
privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }}
clusterName: ${{ env.BAAS_CLUSTER }}

- name: Run tests
run: ${{ inputs.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ inputs.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" --debug # -a="Some test name"
working-directory: ./flutter/realm_flutter/tests
58 changes: 0 additions & 58 deletions .github/workflows/shared-apps.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/terminate-baas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Terminate BaaS

on:
workflow_call:
inputs:
differentiator:
description: Differentiator for the BaaS container.
required: true
type: string

env:
REALM_CI: true

jobs:
terminate-baas:
runs-on: ubuntu-latest
name: Terminate BaaS
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
submodules: false

- name : Setup Dart SDK
uses: dart-lang/setup-dart@main
with:
sdk: stable
architecture: 'x64'

- name: Install dependencies
run: dart pub get

- name: Terminate baas
run: dart run realm_dart delete-apps --baasaas-api-key ${{ secrets.BAASAAS_API_KEY }} --differentiator ${{ inputs.differentiator }}
3 changes: 1 addition & 2 deletions flutter/realm_flutter/tests/test_driver/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import 'package:test/test.dart';
import 'const.dart';

void main(List<String> args) {
print("Current PID $pid");

group('Realm tests', () {
FlutterDriver? driver;

Expand All @@ -28,6 +26,7 @@ void main(List<String> args) {
testCommandWithArgs += getArgFromEnvVariable("BAAS_PRIVATE_API_KEY");
testCommandWithArgs += getArgFromEnvVariable("BAAS_PROJECT_ID");
testCommandWithArgs += getArgFromEnvVariable("BAAS_DIFFERENTIATOR");
testCommandWithArgs += getArgFromEnvVariable("BAAS_BAASAAS_API_KEY");

String result = await driver!.requestData(testCommandWithArgs, timeout: const Duration(minutes: 30));
if (result.isNotEmpty) {
Expand Down
8 changes: 6 additions & 2 deletions flutter/realm_flutter/tests/test_driver/realm_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import 'package:test_api/src/backend/invoker.dart';
import 'package:test_api/src/backend/state.dart' as test_api;

import '../test/app_test.dart' as app_test;
import '../test/asymmetric_test.dart' as asymmetric_test;
import '../test/backlinks_test.dart' as backlinks_test;
import '../test/client_reset_test.dart' as client_reset_test;
import '../test/configuration_test.dart' as configuration_test;
import '../test/credentials_test.dart' as credentials_test;
import '../test/decimal128_test.dart' as decimal128_test;
import '../test/dynamic_realm_test.dart' as dynamic_realm_test;
import '../test/embedded_test.dart' as embedded_test;
import '../test/geospatial_test.dart' as geospatial_test;
import '../test/indexed_test.dart' as indexed_test;
import '../test/list_test.dart' as list_test;
import '../test/migration_test.dart' as migration_test;
Expand All @@ -34,16 +36,19 @@ Future<String> main(List<String> args) async {
final List<String> failedTests = [];

await app_test.main(args);
await asymmetric_test.main(args);
await backlinks_test.main(args);
await client_reset_test.main(args);
await configuration_test.main(args);
await credentials_test.main(args);
await decimal128_test.main(args);
await dynamic_realm_test.main(args);
await embedded_test.main(args);
indexed_test.main(args);
await geospatial_test.main(args);
await indexed_test.main(args);
await list_test.main(args);
await migration_test.main(args);
await realm_logger_test.main(args);
await realm_object_test.main(args);
await realm_set_test.main(args);
await realm_test.main(args);
Expand All @@ -52,7 +57,6 @@ Future<String> main(List<String> args) async {
await session_test.main(args);
await subscription_test.main(args);
await user_test.main(args);
await realm_logger_test.main(args);

tearDown(() {
if (Invoker.current?.liveTest.state.result == test_api.Result.error || Invoker.current?.liveTest.state.result == test_api.Result.failure) {
Expand Down
6 changes: 5 additions & 1 deletion lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ class App implements Finalizable {
/// Create an app with a particular [AppConfiguration]. This constructor should only be used on the main isolate and,
/// ideally, only once as soon as the app starts.
App(AppConfiguration configuration) : _handle = _createApp(configuration) {
if (Isolate.current.debugName != 'main') {
// This is not foolproof, but could point people to errors they may have in their app. Realm apps are cached natively, so calling App(config)
// on a background isolate will not recreate the app. Instead, users should construct the app on the main isolate and then call getById on the
// background isolates. This check will log a warning if the isolate name is != 'main' and doesn't start with 'test/' since dart test will
// construct a new isolate per file and we don't want to log excessively in unit test projects.
if (Isolate.current.debugName != 'main' && Isolate.current.debugName?.startsWith('test/') == false) {
Realm.logger.log(RealmLogLevel.warn,
"App constructor called on Isolate ${Isolate.current.debugName} which doesn't appear to be the main isolate. If you need an app instance on a background isolate use App.getById after constructing the App on the main isolate.");
}
Expand Down
Loading
Loading