Skip to content

Commit

Permalink
Update dodo.py (#110)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
gavv authored Aug 2, 2024
1 parent 6697e82 commit 62ac86d
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 15 deletions.
40 changes: 35 additions & 5 deletions .github/workflows/flutter_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,11 +35,39 @@ jobs:
channel: stable
cache: true

- name: Install doit
uses: awalsh128/cache-apt-pkgs-action@v1.4.2
with:
packages: python3-doit

- name: Run analyzer
run: flutter analyze
run: doit analyze

- name: Run tests
run: flutter test
run: doit 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: python3-doit

- name: Build Android APK
run: flutter build apk
- name: Build apk
run: doit build_apk
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,4 @@ app.*.map.json
/app

# doit related
.doit.db.bak
.doit.db.dat
.doit.db.dir
.doit.db*
64 changes: 57 additions & 7 deletions dodo.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,73 @@
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():
"""run flutter build_runner code generation"""
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
Expand All @@ -24,7 +76,6 @@ def task_icons():
return {
'actions': ['dart run flutter_launcher_icons'],
'title': title_with_actions,
'verbosity': 2,
}

# doit splash
Expand All @@ -33,5 +84,4 @@ def task_splash():
return {
'actions': ['dart run flutter_native_splash:create '],
'title': title_with_actions,
'verbosity': 2,
}
}

0 comments on commit 62ac86d

Please sign in to comment.