Skip to content

Commit

Permalink
Set up Github actions to detect syntax and formatting errors. (#66)
Browse files Browse the repository at this point in the history
* Set up Github actions to detect syntax and formatting errors.

* Updated flutter version.

* Changed line lenght from 100 to 80.

* Add formated files.

* Fix line length in .yml file.

---------

Co-authored-by: Aku <[email protected]>
  • Loading branch information
micedreams and Aku authored Oct 7, 2023
1 parent 23cc984 commit b82ad5f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy application

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
render_document:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v3
- name: Set up flutter-action
uses: subosito/flutter-action@v2
with:
flutter-version: '3.13.0'
channel: 'stable'
- name: Get dependencies
run: flutter pub get
- name: Detect formatting errors
run: dart format --line-length 80 --set-exit-if-changed --output none .
- name: Detect syntax errors
run: flutter analyze --no-pub .
3 changes: 2 additions & 1 deletion lib/app/themes/cosmic_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Cosmic {
todayForegroundColor: MaterialStatePropertyAll(Colors.white),
yearForegroundColor: MaterialStatePropertyAll(Colors.white),
),
timePickerTheme: const TimePickerThemeData(backgroundColor: Color(0xFF49638B)),
timePickerTheme:
const TimePickerThemeData(backgroundColor: Color(0xFF49638B)),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
foregroundColor: const Color.fromARGB(255, 48, 140, 221),
Expand Down
7 changes: 4 additions & 3 deletions lib/core/databases/sqflite_setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ class DBProvider {
log.i("Inserting welcome note");
//as soon as the tables are created, insert a welcome note

String body = """[{\"insert\":\"Welcome to DiaryVault!\\n\\nKey Features:\\n\\n-Rich text editor with support for images and videos.\\n\\n-Your data is securely preserved on your Google Drive / Dropbox account, ensuring complete ownership and privacy\\r.\\n\\n-Sync data between multiple devices.\\r\\n\\n-Fingerprint login on supported devices.\\r\\n\\n-Multiple Themes.\\n\\n\\nHappy notemaking!\\nThe DiaryVault team.\\n\\n\"}]""";
String body =
"""[{\"insert\":\"Welcome to DiaryVault!\\n\\nKey Features:\\n\\n-Rich text editor with support for images and videos.\\n\\n-Your data is securely preserved on your Google Drive / Dropbox account, ensuring complete ownership and privacy\\r.\\n\\n-Sync data between multiple devices.\\r\\n\\n-Fingerprint login on supported devices.\\r\\n\\n-Multiple Themes.\\n\\n\\nHappy notemaking!\\nThe DiaryVault team.\\n\\n\"}]""";

Map<String,Object> notemap = {
Map<String, Object> notemap = {
Notes.ID: "f773a170-6447-11ee-9a76-c314b6be99a3",
Notes.CREATED_AT: DateTime.now().millisecondsSinceEpoch,
Notes.TITLE: "Welcome to DiaryVault",
Expand All @@ -80,7 +81,7 @@ class DBProvider {

log.i("All create queries executed successfully");
log.i("Welcome Note inserted into table: ${Notes.TABLE_NAME}");
// print note
// print note
await db.query(Notes.TABLE_NAME).then((value) => log.i(value));
} catch (e) {
log.e(e);
Expand Down
6 changes: 1 addition & 5 deletions lib/features/auth/presentation/bloc/cubit/theme_state.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
part of 'theme_cubit.dart';

enum Themes {
coralBubbles,
cosmic,
lushGreen
}
enum Themes { coralBubbles, cosmic, lushGreen }

String themeKey = "current_theme";

Expand Down
31 changes: 31 additions & 0 deletions pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# Max line length for Dart files.
LINE_LENGTH=80

echo
echo "Running Dart Format, please wait…"
echo

if ! dart --disable-analytics format --fix --line-length $LINE_LENGTH "."; then
echo
echo "Fatal: Dart Format exited with an error. Please fix the issues and commit again."
echo
exit 1
fi

echo
echo "Running Dart Analysis, please wait…"
echo

# Run Dart Analysis on all modules.
if ! flutter --suppress-analytics analyze --no-pub "."; then
echo
echo "Dart Analysis found some issues. Please fix the issues and commit again."
echo
exit 1
fi

echo
echo "Dart Analysis found no issues, congratulations! Continuing with commit…"
echo

0 comments on commit b82ad5f

Please sign in to comment.