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

Set up semaphore #15

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
83 changes: 37 additions & 46 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 21 additions & 23 deletions lib/features/detail/detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,12 @@ class _DetailPageState extends State<DetailPage> {
);
_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
}
});
Expand Down Expand Up @@ -109,7 +106,7 @@ class _DetailPageState extends State<DetailPage> {
labelText: 'Title',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
Radius.circular(10),
),
),
),
Expand All @@ -125,7 +122,7 @@ class _DetailPageState extends State<DetailPage> {
labelText: 'Description',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
Radius.circular(10),
),
),
),
Expand All @@ -144,18 +141,19 @@ class _DetailPageState extends State<DetailPage> {
),
),
),
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(),
],
),
),
Expand Down
8 changes: 4 additions & 4 deletions lib/features/detail/detail_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DetailViewModel extends ChangeNotifier {
required this.todoViewModel,
});

final TodoViewModel? todoViewModel;
final TodoViewModel todoViewModel;

DetailPageType type = DetailPageType.add;

Expand Down Expand Up @@ -57,7 +57,7 @@ class DetailViewModel extends ChangeNotifier {
updatedAt: timestamp,
);

todoViewModel?.addItemToList(item);
todoViewModel.addItemToList(item);
break;
case DetailPageType.edit:
final item = TodoItem(
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/features/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class _HomePageState extends State<HomePage> {
onPressed: () {
Navigator.push(
context,
CupertinoPageRoute(
CupertinoPageRoute<DetailPage>(
builder: (_) => const DetailPage(
type: DetailPageType.add,
),
Expand All @@ -64,7 +64,7 @@ class _HomePageState extends State<HomePage> {
hintText: 'Search',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
Radius.circular(10),
),
),
),
Expand All @@ -80,7 +80,7 @@ class _HomePageState extends State<HomePage> {
onTap: () {
Navigator.push(
context,
CupertinoPageRoute(
CupertinoPageRoute<DetailPage>(
builder: (_) => DetailPage(
type: DetailPageType.edit,
item: data.todos[i],
Expand Down
Loading