Skip to content

Commit

Permalink
ci: Melos scripts improvements (#400)
Browse files Browse the repository at this point in the history
* Improvement on melos script

* Add fail fast to lint

* Melos directory

* Updated test

* Update melos.yaml

* fix tests

---------

Co-authored-by: Lucas Oliveira <[email protected]>
  • Loading branch information
leoafarias and tilucasoli authored Jul 25, 2024
1 parent 16fa623 commit c6df98c
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 146 deletions.
106 changes: 71 additions & 35 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@ name: mix_workspace

sdkPath: .fvm/flutter_sdk
packages:
- packages/**
- examples/**

categories:
mix_deps:
- packages/mix
- packages/mix_annotations
- packages/mix_generator
- packages/mix_lint
should_test:
- packages/mix
- examples/**
- packages/*
- packages/*/example
- examples/*
- packages/*/demo

command:
bootstrap:
Expand All @@ -22,40 +14,84 @@ command:
flutter: ">=3.19.0"
publish:
hooks:
pre: melos run brb
pre: melos run gen:build

scripts:
# ANALYSIS
analyze:
run: melos run analyze:dart && melos run analyze:dcm
description: Run all static analysis checks.
exec:
failFast: true

analyze:dart:
run: melos exec -c 10 -- dart analyze --fatal-infos
description: Run Dart static analysis checks.

analyze:dcm:
run: melos exec -c 10 -- dcm analyze . --fatal-style --fatal-performance --fatal-warnings
description: Run DCM static analysis checks.
packageFilters:
dependsOn: "dart_code_metrics_presets"

lint:fix:all:
run: melos run lint:dart:fix && melos run lint:dcm:fix
description: Run all static analysis checks and apply fixes.

lint:dart:fix:
run: melos exec -- dart fix --apply .
description: Run Dart static analysis checks.

lint:dcm:fix:
run: melos exec -- dcm fix .
description: Run DCM static analysis checks.
packageFilters:
dependsOn: "dart_code_metrics_presets"

gen:watch:
run: melos exec --order-dependents -- dart run build_runner watch --delete-conflicting-outputs
description: Generate code for all packages
packageFilters:
dependsOn: "build_runner"

gen:build:
run: melos run gen:clean && melos exec --order-dependents -- dart run build_runner build --delete-conflicting-outputs
description: Generate code for all packages
packageFilters:
dependsOn: "build_runner"

gen:clean:
run: melos exec --order-dependents -- dart run build_runner clean
description: Clean generated code for all packages
packageFilters:
dependsOn: "build_runner"

test:
run: melos exec -- flutter test
description: Run flutter test
packageFilters:
dirExists: test

test:coverage:
run: melos exec -- flutter test --coverage
description: Run flutter test with coverage
packageFilters:
dirExists: test

brb:
description: Run build_runner for projects that have it as a dependency
steps:
- melos run brbc
- melos exec --depends-on="build_runner" --category="mix_deps" dart run build_runner build --delete-conflicting-outputs
run: melos run gen:build

brbc:
run: melos exec --depends-on="build_runner" dart run build_runner clean
description: Clean build_runner for projects that have it as a dependency
test:
run: melos exec --category="should_test" flutter test
description: Run flutter test in all projects that should be tested
run: melos run gen:clean
fix:
steps:
- melos exec dart fix --apply .
- melos exec --depends-on="dart_code_metrics_presets" dcm fix .
run: melos run lint:fix:all
custom_lint_analyze:
run: dart pub global activate custom_lint && melos exec --depends-on="mix_lint" custom_lint

mix_exports:
run: melos exec --scope="packages/mix" dart run ./scripts/exports.dart
description: Generate exports for the mix package

analyze:
run: |
dcm analyze --fatal-warnings --fatal-style --fatal-performance .
dart analyze --fatal-infos .
exec:
failFast: true
packageFilters:
category: "mix_deps"


verify_version_pubspec_changelog:
run: ./scripts/verify_changelogs.sh packages
description: Verify that all packages have the same version
1 change: 1 addition & 0 deletions packages/mix_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:


dev_dependencies:
test: ^1.24.4
dart_code_metrics_presets: ^2.13.0
build_runner: ^2.4.9
build_test: ^2.2.2
Expand Down
6 changes: 5 additions & 1 deletion packages/mix_generator/test/mix_generator_test.dart
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
void main() {}
import 'package:test/test.dart';

void main() {
test('description', () => expect(true, true));
}
18 changes: 2 additions & 16 deletions packages/remix/demo/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,8 @@
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter_test/flutter_test.dart';

void main() {
// testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// // Build our app and trigger a frame.
// await tester.pumpWidget(const HotReload());

// // Verify that our counter starts at 0.
// expect(find.text('0'), findsOneWidget);
// expect(find.text('1'), findsNothing);

// // Tap the '+' icon and trigger a frame.
// await tester.tap(find.byIcon(Icons.add));
// await tester.pump();

// // Verify that our counter has incremented.
// expect(find.text('0'), findsNothing);
// expect(find.text('1'), findsOneWidget);
// });
test('description', () => expect(true, true));
}
97 changes: 3 additions & 94 deletions packages/remix/test/components/button_test.dart
Original file line number Diff line number Diff line change
@@ -1,96 +1,5 @@
void main() {
// group('RemixButton', () {
// testWidgets('renders with correct label', (WidgetTester tester) async {
// const label = 'Test Button';
// await tester.pumpWidget(
// MaterialApp(
// home: RxButton(label: label, onPressed: () {}),
// ),
// );

// expect(
// find.byWidgetPredicate(
// (widget) => widget is Text && widget.data == label,
// ),
// findsOneWidget,
// );
// });

// testWidgets('shows loading indicator and label when isLoading is true',
// (WidgetTester tester) async {
// const loadingLabel = 'Loading...';

// await tester.pumpWidget(
// MaterialApp(
// home: RxButton(
// label: 'Test Button',
// loading: true,
// onPressed: () {},
// ),
// ),
// );

// expect(find.byType(CircularProgressIndicator), findsOneWidget);
// expect(find.text(loadingLabel), findsOneWidget);
// });

// testWidgets('displays correct icons when provided',
// (WidgetTester tester) async {
// await tester.pumpWidget(MaterialApp(
// home: RxButton(
// label: 'Test Button',
// iconLeft: Icons.arrow_back,
// iconRight: Icons.arrow_forward,
// onPressed: () {},
// ),
// ));

// expect(find.byIcon(Icons.arrow_back), findsOneWidget);
// expect(find.byIcon(Icons.arrow_forward), findsOneWidget);

// final HBox iconRow = tester.widget(find.byType(HBox));
// expect(iconRow.children.first, isInstanceOf<StyledIcon>());
// expect((iconRow.children.first as StyledIcon).icon, Icons.arrow_back);
// expect(iconRow.children.last, isInstanceOf<StyledIcon>());
// expect((iconRow.children.last as StyledIcon).icon, Icons.arrow_forward);
// });
// });
import 'package:flutter_test/flutter_test.dart';

// testWidgets('when disabled must not call onPressed',
// (WidgetTester tester) async {
// bool didCallOnPressed = false;

// await tester.pumpWidget(MaterialApp(
// home: RxButton(
// label: 'Disabled Button',
// onPressed: () {
// didCallOnPressed = true;
// },
// disabled: true,
// ),
// ));

// await tester.tap(find.byType(RxButton));
// await tester.pumpAndSettle(const Duration(milliseconds: 200));

// expect(didCallOnPressed, false);
// });

// testWidgets('when enabled must call onPressed', (WidgetTester tester) async {
// bool didCallOnPressed = false;

// await tester.pumpWidget(MaterialApp(
// home: RxButton(
// label: 'Disabled Button',
// onPressed: () {
// didCallOnPressed = true;
// },
// ),
// ));

// await tester.tap(find.byType(RxButton));
// await tester.pumpAndSettle(const Duration(milliseconds: 200));

// expect(didCallOnPressed, isTrue);
// });
void main() {
test('description', () => expect(true, true));
}

0 comments on commit c6df98c

Please sign in to comment.