mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-11-09 13:09:21 +03:00
ci: run flutter test on ci
This commit is contained in:
parent
2781809f87
commit
0b0cbe192b
38
.github/workflows/dart_test.yml
vendored
Normal file
38
.github/workflows/dart_test.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
name: Unit test(Flutter)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: subosito/flutter-action@v1
|
||||
with:
|
||||
channel: "stable"
|
||||
- name: Flutter pub get
|
||||
run: flutter pub get
|
||||
working-directory: frontend/app_flowy
|
||||
- name: Generate language files
|
||||
working-directory: frontend/app_flowy
|
||||
run:
|
||||
flutter pub run easy_localization:generate --source-dir ./assets/translations -f keys -O lib/generated -o locale_keys.g.dart
|
||||
- name: Build FlowySDK
|
||||
working-directory: frontend
|
||||
run: |
|
||||
flutter config --enable-linux-desktop
|
||||
cargo make --profile development-linux-x86 flowy-sdk-dev
|
||||
- name: Bloc Test
|
||||
working-directory: frontend/app_flowy
|
||||
run: |
|
||||
flutter test
|
||||
|
2
frontend/app_flowy/.vscode/launch.json
vendored
2
frontend/app_flowy/.vscode/launch.json
vendored
@ -12,6 +12,7 @@
|
||||
"preLaunchTask": "build_flowy_sdk",
|
||||
"env":{
|
||||
"RUST_LOG":"info",
|
||||
"INTEGRATION_ENV":"develop",
|
||||
},
|
||||
"cwd": "${workspaceRoot}"
|
||||
},
|
||||
@ -23,6 +24,7 @@
|
||||
"preLaunchTask": "build_flowy_sdk",
|
||||
"env":{
|
||||
"RUST_LOG":"trace",
|
||||
"INTEGRATION_ENV":"develop",
|
||||
},
|
||||
"cwd": "${workspaceRoot}"
|
||||
},
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:app_flowy/startup/tasks/prelude.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
@ -23,10 +25,6 @@ import 'package:flowy_sdk/flowy_sdk.dart';
|
||||
//
|
||||
// 3.build MeterialApp
|
||||
final getIt = GetIt.instance;
|
||||
enum IntegrationEnv {
|
||||
dev,
|
||||
pro,
|
||||
}
|
||||
|
||||
abstract class EntryPoint {
|
||||
Widget create();
|
||||
@ -35,7 +33,7 @@ abstract class EntryPoint {
|
||||
class System {
|
||||
static Future<void> run(EntryPoint f) async {
|
||||
// Specify the env
|
||||
const env = IntegrationEnv.dev;
|
||||
final env = integrationEnv();
|
||||
|
||||
// Config the deps graph
|
||||
getIt.registerFactory<EntryPoint>(() => f);
|
||||
@ -44,8 +42,11 @@ class System {
|
||||
|
||||
// add task
|
||||
getIt<AppLauncher>().addTask(InitRustSDKTask());
|
||||
getIt<AppLauncher>().addTask(ApplicationWidgetTask());
|
||||
getIt<AppLauncher>().addTask(InitPlatformService());
|
||||
|
||||
if (!env.isTest()) {
|
||||
getIt<AppLauncher>().addTask(ApplicationWidgetTask());
|
||||
getIt<AppLauncher>().addTask(InitPlatformService());
|
||||
}
|
||||
|
||||
// execute the tasks
|
||||
getIt<AppLauncher>().launch();
|
||||
@ -101,3 +102,27 @@ class AppLauncher {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum IntegrationEnv {
|
||||
develop,
|
||||
release,
|
||||
test,
|
||||
}
|
||||
|
||||
extension IntegrationEnvExt on IntegrationEnv {
|
||||
bool isTest() {
|
||||
return this == IntegrationEnv.test;
|
||||
}
|
||||
}
|
||||
|
||||
IntegrationEnv integrationEnv() {
|
||||
if (Platform.environment.containsKey('FLUTTER_TEST')) {
|
||||
return IntegrationEnv.test;
|
||||
}
|
||||
final value = String.fromEnvironment('INTEGRATION_ENV');
|
||||
if (value == 'release') {
|
||||
return IntegrationEnv.release;
|
||||
}
|
||||
|
||||
return IntegrationEnv.develop;
|
||||
}
|
||||
|
@ -9,21 +9,24 @@ class InitRustSDKTask extends LaunchTask {
|
||||
|
||||
@override
|
||||
Future<void> initialize(LaunchContext context) async {
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
final documentPath = directory.path;
|
||||
switch (context.env) {
|
||||
case IntegrationEnv.develop:
|
||||
case IntegrationEnv.release:
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
return Directory('${directory.path}/flowy').create().then(
|
||||
(Directory directory) async {
|
||||
await context.getIt<FlowySDK>().init(directory);
|
||||
},
|
||||
);
|
||||
case IntegrationEnv.test:
|
||||
await context.getIt<FlowySDK>().init(testDir());
|
||||
break;
|
||||
default:
|
||||
assert(false, 'Unsupported env');
|
||||
}
|
||||
}
|
||||
|
||||
return Directory('$documentPath/flowy').create().then((Directory directory) async {
|
||||
switch (context.env) {
|
||||
case IntegrationEnv.dev:
|
||||
// await context.getIt<FlowySDK>().init(Directory('./temp/flowy_dev'));
|
||||
await context.getIt<FlowySDK>().init(directory);
|
||||
break;
|
||||
case IntegrationEnv.pro:
|
||||
await context.getIt<FlowySDK>().init(directory);
|
||||
break;
|
||||
default:
|
||||
assert(false, 'Unsupported env');
|
||||
}
|
||||
});
|
||||
Directory testDir() {
|
||||
return Directory("${Directory.systemTemp.path}/appflowy");
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
export 'application_widget.dart';
|
||||
export 'app_widget.dart';
|
||||
export 'init_sdk.dart';
|
||||
export 'init_platform_service.dart';
|
||||
export 'platform_service.dart';
|
||||
|
@ -7,7 +7,7 @@ import 'package:flowy_infra_ui/widget/buttons/secondary_button.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:app_flowy/startup/tasks/application_widget.dart';
|
||||
import 'package:app_flowy/startup/tasks/app_widget.dart';
|
||||
import 'package:flowy_infra/size.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/text_input.dart';
|
||||
import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart';
|
||||
|
@ -34,7 +34,6 @@ class ViewSection extends StatelessWidget {
|
||||
|
||||
Widget _renderSectionItems(BuildContext context, List<View> views) {
|
||||
List<Widget> viewWidgets = [];
|
||||
|
||||
if (views.isNotEmpty) {
|
||||
viewWidgets = views
|
||||
.map(
|
||||
|
@ -20,10 +20,9 @@ void main() {
|
||||
act: (bloc) {
|
||||
bloc.add(const WelcomeEvent.initial());
|
||||
},
|
||||
wait: const Duration(seconds: 2),
|
||||
wait: const Duration(seconds: 3),
|
||||
verify: (bloc) {
|
||||
assert(bloc.state.isLoading == false);
|
||||
assert((bloc.state.workspaces.length) == 1);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user