diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 20c0122..28e45ed 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -1,82 +1,73 @@ version: v1.0 -name: Main +name: Initial Pipeline agent: machine: - type: a1-standard-4 - os_image: macos-xcode12 -fail_fast: - stop: - when: 'true' + type: e1-standard-2 + os_image: ubuntu1804 + containers: + - name: main + image: 'registry.semaphoreci.com/android:30-flutter' blocks: - - name: Install dependencies + - name: install dependencies task: jobs: - - name: Install and cache flutter + - name: Install commands: - checkout - 'cache restore flutter-packages-$SEMAPHORE_GIT_BRANCH-$(checksum pubspec.yaml),flutter-packages-$(checksum pubspec.yaml),flutter-packages' - flutter pub get - - 'cache store flutter-packages-$SEMAPHORE_GIT_BRANCH-$(checksum pubspec.yaml),flutter-packages-$(checksum pubspec.yaml),flutter-packages' - prologue: - commands: - - checkout - - 'cache restore flutter-packages-$SEMAPHORE_GIT_BRANCH-$(checksum pubspec.yaml),flutter-packages-$(checksum pubspec.yaml),flutter-packages' - - flutter pub get - - name: Lint + - 'cache store flutter-packages-$SEMAPHORE_GIT_BRANCH-$(checksum pubspec.yaml),flutter-packages-$(checksum pubspec.yaml),flutter-packages /root/.pub-cache' + - name: Linting task: prologue: commands: - checkout - 'cache restore flutter-packages-$SEMAPHORE_GIT_BRANCH-$(checksum pubspec.yaml),flutter-packages-$(checksum pubspec.yaml),flutter-packages' - - flutter pub get jobs: - - name: Format + - name: Format code commands: - flutter format --set-exit-if-changed . - - name: Analyze + - name: Run code lint commands: - flutter analyze . - - name: Unit and widget tests + - name: Tests task: - prologue: - commands: - - checkout - - 'cache restore flutter-packages-$SEMAPHORE_GIT_BRANCH-$(checksum pubspec.yaml),flutter-packages-$(checksum pubspec.yaml),flutter-packages' - - flutter pub get jobs: - - name: Test + - name: Run unit and widget tests commands: + - checkout + - 'cache restore flutter-packages-$SEMAPHORE_GIT_BRANCH-$(checksum pubspec.yaml),flutter-packages-$(checksum pubspec.yaml),flutter-packages' - flutter test test - - name: Run UI tests + - name: Integration tests task: prologue: commands: - checkout - 'cache restore flutter-packages-$SEMAPHORE_GIT_BRANCH-$(checksum pubspec.yaml),flutter-packages-$(checksum pubspec.yaml),flutter-packages' - - flutter pub get - - device_uuid=$(xcrun simctl create ios-simulator com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro com.apple.CoreSimulator.SimRuntime.iOS-14-5) - - xcrun simctl boot $device_uuid + - sdkmanager "platform-tools" "platforms;android-29" "build-tools;30.0.0" "emulator" + - sdkmanager "system-images;android-29;google_apis;x86" + - echo no | avdmanager create avd -n test-emulator -k "system-images;android-29;google_apis;x86" + - emulator -avd test-emulator -noaudio -no-boot-anim -gpu off -no-window & + - 'adb wait-for-device shell ''while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;''' + - adb shell wm dismiss-keyguard + - sleep 1 + - adb shell settings put global window_animation_scale 0 + - adb shell settings put global transition_animation_scale 0 + - adb shell settings put global animator_duration_scale 0 jobs: - - name: Add new item + - name: Add new item test commands: - flutter test integration_test/add_new_todo_item_test.dart - - name: Edit exist item + - name: Edit existing item test commands: - flutter test integration_test/edit_existing_item_test.dart - - name: Delete item + - name: Delete existing item test commands: - flutter test integration_test/delete_existing_item_test.dart - run: - when: 'change_in(''/lib'', {default_branch: ''main'', pipeline_file: ''ignore''})' - - name: Build artifact - task: - prologue: - commands: - - checkout - - 'cache restore flutter-packages-$SEMAPHORE_GIT_BRANCH-$(checksum pubspec.yaml),flutter-packages-$(checksum pubspec.yaml),flutter-packages' - - flutter pub get - jobs: - - name: Generate IPA - commands: - - flutter build ios --no-codesign - - artifact push job build/ios/iphoneos/Runner.app + agent: + machine: + type: e1-standard-2 + os_image: ubuntu2004 + containers: + - name: main + image: 'registry.semaphoreci.com/android:30-flutter' diff --git a/analysis_options.yaml b/analysis_options.yaml index ee86098..7f58cfa 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -7,3 +7,5 @@ linter: sort_constructors_first: false use_key_in_widget_constructors: false public_member_api_docs: false + sort_pub_dependencies: false + use_setters_to_change_properties: false diff --git a/android/app/build.gradle b/android/app/build.gradle index 36549ca..3248193 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/android/build.gradle b/android/build.gradle index 9b6ed06..ef64012 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.6.10' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:7.0.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index bc6a58a..b8793d3 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip diff --git a/lib/features/detail/detail_page.dart b/lib/features/detail/detail_page.dart index 9929d0e..5c0dbef 100644 --- a/lib/features/detail/detail_page.dart +++ b/lib/features/detail/detail_page.dart @@ -54,15 +54,12 @@ class _DetailPageState extends State { ); _detailViewModel.setDetailType(widget.type); - WidgetsBinding.instance?.addPostFrameCallback((_) { - switch (widget.type) { - case DetailPageType.edit: - _detailViewModel.setItemEditing(widget.item!); - - _titleController.text = widget.item!.title; - _descriptionController.text = widget.item!.description; - break; - default: + WidgetsBinding.instance.addPostFrameCallback((_) { + if (widget.type == DetailPageType.edit) { + _detailViewModel.setItemEditing(widget.item!); + + _titleController.text = widget.item!.title; + _descriptionController.text = widget.item!.description; // Do nothing } }); @@ -109,7 +106,7 @@ class _DetailPageState extends State { labelText: 'Title', border: OutlineInputBorder( borderRadius: BorderRadius.all( - Radius.circular(10.0), + Radius.circular(10), ), ), ), @@ -125,7 +122,7 @@ class _DetailPageState extends State { labelText: 'Description', border: OutlineInputBorder( borderRadius: BorderRadius.all( - Radius.circular(10.0), + Radius.circular(10), ), ), ), @@ -144,18 +141,19 @@ class _DetailPageState extends State { ), ), ), - widget.type == DetailPageType.edit - ? TextButton( - key: const ValueKey('button.delete'), - child: const Text( - 'Delete', - style: TextStyle( - color: Colors.red, - ), - ), - onPressed: _deleteItem, - ) - : Container(), + if (widget.type == DetailPageType.edit) + TextButton( + key: const ValueKey('button.delete'), + child: const Text( + 'Delete', + style: TextStyle( + color: Colors.red, + ), + ), + onPressed: _deleteItem, + ) + else + Container(), ], ), ), diff --git a/lib/features/detail/detail_viewmodel.dart b/lib/features/detail/detail_viewmodel.dart index 418b45a..25681b2 100644 --- a/lib/features/detail/detail_viewmodel.dart +++ b/lib/features/detail/detail_viewmodel.dart @@ -9,7 +9,7 @@ class DetailViewModel extends ChangeNotifier { required this.todoViewModel, }); - final TodoViewModel? todoViewModel; + final TodoViewModel todoViewModel; DetailPageType type = DetailPageType.add; @@ -57,7 +57,7 @@ class DetailViewModel extends ChangeNotifier { updatedAt: timestamp, ); - todoViewModel?.addItemToList(item); + todoViewModel.addItemToList(item); break; case DetailPageType.edit: final item = TodoItem( @@ -68,12 +68,12 @@ class DetailViewModel extends ChangeNotifier { updatedAt: timestamp, ); - todoViewModel?.updateItem(item); + todoViewModel.updateItem(item); break; } } - void deleteItemById(int id) => todoViewModel?.deleteItemById(id); + void deleteItemById(int id) => todoViewModel.deleteItemById(id); void reset() { type = DetailPageType.add; diff --git a/lib/features/home/home_page.dart b/lib/features/home/home_page.dart index 2bcfb5b..8855246 100644 --- a/lib/features/home/home_page.dart +++ b/lib/features/home/home_page.dart @@ -40,7 +40,7 @@ class _HomePageState extends State { onPressed: () { Navigator.push( context, - CupertinoPageRoute( + CupertinoPageRoute( builder: (_) => const DetailPage( type: DetailPageType.add, ), @@ -64,7 +64,7 @@ class _HomePageState extends State { hintText: 'Search', border: OutlineInputBorder( borderRadius: BorderRadius.all( - Radius.circular(10.0), + Radius.circular(10), ), ), ), @@ -80,7 +80,7 @@ class _HomePageState extends State { onTap: () { Navigator.push( context, - CupertinoPageRoute( + CupertinoPageRoute( builder: (_) => DetailPage( type: DetailPageType.edit, item: data.todos[i], diff --git a/pubspec.lock b/pubspec.lock index 0ec3560..61940df 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.1.2" + version: "3.1.11" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -28,14 +28,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -49,7 +49,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" crypto: dependency: transitive description: @@ -63,21 +63,21 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.5" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -88,6 +88,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -103,20 +110,34 @@ packages: description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" nested: dependency: transitive description: @@ -130,28 +151,28 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.1" + version: "4.2.4" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "6.0.3" sky_engine: dependency: transitive description: flutter @@ -163,7 +184,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -205,7 +226,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.9" typed_data: dependency: transitive description: @@ -219,21 +240,21 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" very_good_analysis: dependency: "direct dev" description: name: very_good_analysis url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "3.0.2" vm_service: dependency: transitive description: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "6.2.0" + version: "8.2.2" webdriver: dependency: transitive description: @@ -242,5 +263,5 @@ packages: source: hosted version: "3.0.0" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.17.0 <3.0.0" flutter: ">=1.16.0" diff --git a/pubspec.yaml b/pubspec.yaml index e25ed10..88a3bcd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,16 +11,17 @@ environment: dependencies: flutter: sdk: flutter + cupertino_icons: ^1.0.5 + provider: ^6.0.3 - cupertino_icons: ^1.0.2 - provider: ^5.0.0 dev_dependencies: flutter_test: sdk: flutter integration_test: sdk: flutter - very_good_analysis: ^2.1.0 + very_good_analysis: ^3.0.2 + flutter_lints: ^2.0.1 flutter: uses-material-design: true diff --git a/test/features/home/home_viewmodel_test.dart b/test/features/home/home_viewmodel_test.dart index 64a2b33..0ee49cb 100644 --- a/test/features/home/home_viewmodel_test.dart +++ b/test/features/home/home_viewmodel_test.dart @@ -6,10 +6,7 @@ import 'package:semaphoreci_flutter_demo/viewmodels/todo_viewmodel.dart'; void main() { test('Should show empty list if TodoViewModel is null ', () { // Arrange - const todoViewModel = null; - final homeViewModel = HomeViewModel( - todoViewModel: todoViewModel, - ); + final homeViewModel = HomeViewModel(); // Act // Do nothing