From b845ba7fd599c66cee4bf08a82bca2fec77aad3c Mon Sep 17 00:00:00 2001 From: Victor Gaydov Date: Fri, 2 Aug 2024 14:45:38 +0400 Subject: [PATCH] Update dodo.py - remove __pycache__ at exit - don't print backtrace on ^C - add commands: doit analyze doit test doit exec doit build_apk doit wipe - use LongRunning() - add more doit files to .gitignore - use doit on CI - separate CI jobs for desktop & android --- .github/workflows/flutter_build.yml | 40 +++++++++++++++--- .gitignore | 4 +- dodo.py | 64 +++++++++++++++++++++++++---- 3 files changed, 93 insertions(+), 15 deletions(-) diff --git a/.github/workflows/flutter_build.yml b/.github/workflows/flutter_build.yml index 559c185..67ced73 100644 --- a/.github/workflows/flutter_build.yml +++ b/.github/workflows/flutter_build.yml @@ -17,12 +17,14 @@ on: - cron: '0 0 * * 1' jobs: - build: + desktop: strategy: matrix: os: [ubuntu-latest] runs-on: ${{ matrix.os }} + name: desktop-${{ matrix.os }} + steps: - name: Checkout uses: actions/checkout@v4 @@ -33,11 +35,39 @@ jobs: channel: stable cache: true + - name: Install doit + uses: awalsh128/cache-apt-pkgs-action@v1.4.2 + with: + packages: doit + - name: Run analyzer - run: flutter analyze + run: dodo analyze - name: Run tests - run: flutter test + run: dodo test + + android: + strategy: + matrix: + os: [ubuntu-latest] + + runs-on: ${{ matrix.os }} + name: android-${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + + - name: Install doit + uses: awalsh128/cache-apt-pkgs-action@v1.4.2 + with: + packages: doit - - name: Build Android APK - run: flutter build apk + - name: Build apk + run: dodo build_apk diff --git a/.gitignore b/.gitignore index 0513bae..1bd7662 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,4 @@ app.*.map.json /app # doit related -.doit.db.bak -.doit.db.dat -.doit.db.dir +.doit.db* diff --git a/dodo.py b/dodo.py index b0be3fa..e20fe16 100644 --- a/dodo.py +++ b/dodo.py @@ -1,4 +1,58 @@ -from doit.tools import title_with_actions +from doit.tools import title_with_actions, LongRunning +import atexit +import os +import shutil +import signal + +atexit.register( + lambda: shutil.rmtree('__pycache__', ignore_errors=True)) +if os.name == 'posix': + signal.signal(signal.SIGINT, lambda s, f: os._exit(0)) + +DOIT_CONFIG = { + 'default_tasks': ['analyze', 'test'], + 'verbosity': 2, +} + +# doit analyze +def task_analyze(): + """run analyzer""" + return { + 'actions': ['flutter analyze --fatal-infos --fatal-warnings'], + 'title': title_with_actions, + } + +# doit test +def task_test(): + """run tests""" + return { + 'actions': ['flutter test -j1 -r github'], + 'title': title_with_actions, + } + +# doit exec +def task_exec(): + """run on device""" + return { + 'actions': [LongRunning('flutter run --release')], + 'title': title_with_actions, + } + +# doit build_apk +def task_build_apk(): + """build android apk""" + return { + 'actions': ['flutter build apk --release'], + 'title': title_with_actions, + } + +# doit wipe +def task_wipe(): + """clean build artifacts""" + return { + 'actions': ['flutter clean'], + 'title': title_with_actions, + } # doit gen def task_gen(): @@ -6,16 +60,14 @@ def task_gen(): return { 'actions': ['dart run build_runner build --delete-conflicting-outputs'], 'title': title_with_actions, - 'verbosity': 2, } # doit gen_watch def task_gen_watch(): """run flutter build_runner code watch generation""" return { - 'actions': ['dart run build_runner watch --delete-conflicting-outputs'], + 'actions': [LongRunning('dart run build_runner watch --delete-conflicting-outputs')], 'title': title_with_actions, - 'verbosity': 2, } # doit icons @@ -24,7 +76,6 @@ def task_icons(): return { 'actions': ['dart run flutter_launcher_icons'], 'title': title_with_actions, - 'verbosity': 2, } # doit splash @@ -33,5 +84,4 @@ def task_splash(): return { 'actions': ['dart run flutter_native_splash:create '], 'title': title_with_actions, - 'verbosity': 2, - } \ No newline at end of file + }