Files
sharedinbox/Taskfile.yml
T

416 lines
14 KiB
YAML
Raw Normal View History

version: "3"
2026-04-16 11:48:37 +02:00
silent: true
tasks:
default:
2026-04-16 15:14:18 +02:00
desc: Run all checks (analyze + unit tests + widget tests + integration, in parallel)
deps: [check]
_nix-check:
internal: true
run: once
cmds:
- cmd: |
if ! nix show-config experimental-features 2>/dev/null | grep -q "nix-command" || ! nix show-config experimental-features 2>/dev/null | grep -q "flakes"; then
echo "CRITICAL: Nix experimental features 'nix-command' and 'flakes' must be enabled."
echo "Attempting to fix by updating ~/.config/nix/nix.conf ..."
mkdir -p ~/.config/nix
CONF=~/.config/nix/nix.conf
if [ ! -f "$CONF" ]; then
echo "experimental-features = nix-command flakes" > "$CONF"
elif ! grep -q "experimental-features" "$CONF"; then
echo "experimental-features = nix-command flakes" >> "$CONF"
elif ! grep -E "experimental-features.*nix-command" "$CONF" || ! grep -E "experimental-features.*flakes" "$CONF"; then
echo "Your $CONF already has experimental-features but is missing 'nix-command' or 'flakes'."
echo "Please add them manually to the 'experimental-features' line."
exit 1
fi
echo "Local configuration updated. Please re-run your command."
exit 1
fi
2026-04-25 07:12:56 +02:00
_preflight:
internal: true
run: once
deps: [_nix-check]
preconditions:
- sh: test -n "${IN_NIX_SHELL}"
msg: "Not in nix dev shell. Run: nix develop"
2026-04-25 07:12:56 +02:00
cmds:
- scripts/silent_on_success.sh pre-commit install
2026-04-17 12:17:51 +02:00
_flutter-check:
2026-04-17 10:05:31 +02:00
internal: true
run: once
2026-04-25 07:12:56 +02:00
deps: [_preflight]
2026-04-17 12:17:51 +02:00
cmds:
2026-04-25 07:07:05 +02:00
- cmd: scripts/silent_on_success.sh fvm install --skip-pub-get
- cmd: scripts/silent_on_success.sh fvm use --skip-pub-get
setup:
desc: Fully set up the dev environment (FVM, pub get, codegen, hooks)
deps: [_preflight, _codegen, generate-changelog]
cmds:
- echo "Setup complete."
2026-04-17 12:17:51 +02:00
generate-changelog:
desc: Generate assets/changelog.txt from git history
cmds:
- mkdir -p assets
- 'git log -n 50 --pretty=format:"* %ad [%h](https://codeberg.org/guettli/sharedinbox/commit/%H): %s" --date=short > assets/changelog.txt'
2026-04-17 12:17:51 +02:00
_pub-get:
internal: true
run: once
deps: [_flutter-check]
2026-04-17 10:05:31 +02:00
cmds:
2026-04-25 07:07:05 +02:00
- scripts/silent_on_success.sh fvm flutter pub get --suppress-analytics
_linux-deps-check:
internal: true
run: once
preconditions:
- sh: command -v clang >/dev/null 2>&1
msg: "Linux desktop deps missing. Run: sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev"
- sh: pkg-config --exists gtk+-3.0 2>/dev/null
msg: "Linux desktop deps missing. Run: sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev"
2026-04-17 10:05:31 +02:00
install-hooks:
2026-04-16 15:14:18 +02:00
desc: Install pre-commit hooks (requires pre-commit; see .pre-commit-config.yaml)
cmds:
2026-04-16 15:14:18 +02:00
- pre-commit install
2026-04-25 07:07:05 +02:00
_codegen:
internal: true
run: once
deps: [_pub-get]
sources:
- lib/**/*.dart
- pubspec.yaml
generates:
- lib/**/*.g.dart
2026-04-25 07:07:05 +02:00
cmds:
- scripts/silent_on_success.sh fvm flutter pub run build_runner build --delete-conflicting-outputs
codegen:
desc: Generate Drift DB code (run after any schema change)
2026-04-25 07:12:56 +02:00
deps: [_preflight, _pub-get]
sources:
- lib/**/*.dart
- pubspec.yaml
generates:
- lib/**/*.g.dart
cmds:
- fvm flutter pub run build_runner build --delete-conflicting-outputs
analyze:
2026-04-16 11:48:37 +02:00
desc: Static analysis (flutter analyze)
2026-04-25 07:12:56 +02:00
deps: [_preflight, _codegen]
sources:
- lib/**/*.dart
- test/**/*.dart
- pubspec.yaml
- analysis_options.yaml
cmds:
2026-04-16 11:48:37 +02:00
- scripts/run_analyze.sh
format:
desc: Format all Dart source files
2026-04-25 07:12:56 +02:00
deps: [_preflight]
sources:
- "**/*.dart"
cmds:
- fvm dart format lib test
analyze-fix:
desc: Auto-fix lint issues with dart fix --apply
2026-04-25 07:12:56 +02:00
deps: [_preflight]
sources:
- lib/**/*.dart
- test/**/*.dart
cmds:
- fvm dart fix --apply
test:
2026-04-16 11:48:37 +02:00
desc: Unit tests + coverage gate (fails if any non-excluded lib/ file is missing)
2026-04-25 07:12:56 +02:00
deps: [_preflight, _codegen]
sources:
- lib/**/*.dart
- test/unit/**/*.dart
generates:
- coverage/lcov.info
cmds:
2026-04-16 11:48:37 +02:00
- scripts/run_unit_tests.sh
2026-04-16 15:14:18 +02:00
test-widget:
desc: Widget tests — headless, no display or network required
2026-04-25 07:12:56 +02:00
deps: [_preflight, _codegen]
sources:
- lib/**/*.dart
- test/widget/**/*.dart
2026-04-16 15:14:18 +02:00
cmds:
2026-04-17 10:05:31 +02:00
- scripts/run_widget_tests.sh
2026-04-16 15:14:18 +02:00
test-flutter:
2026-04-16 15:14:18 +02:00
desc: Full Flutter test suite (unit + widget + integration)
2026-04-25 07:12:56 +02:00
deps: [_preflight]
sources:
- lib/**/*.dart
- test/**/*.dart
- integration_test/**/*.dart
cmds:
- fvm flutter test
integration:
2026-04-16 11:48:37 +02:00
desc: Integration tests against a local Stalwart mail server
2026-04-17 12:17:51 +02:00
deps: [_flutter-check]
sources:
- lib/**/*.dart
- test/integration/**/*.dart
cmds:
2026-04-16 11:48:37 +02:00
- stalwart-dev/test.sh
integration-ui:
desc: UI E2E tests on Linux via Xvfb — headless, no emulator needed
deps: [_preflight, _linux-deps-check, _pub-get]
sources:
- lib/**/*.dart
- integration_test/app_e2e_test.dart
cmds:
- stalwart-dev/integration_ui_test.sh
integration-android:
desc: UI integration tests on a connected Android emulator (Stalwart on host, emulator reaches it via 10.0.2.2)
deps: [_preflight, _android-sdk-check, _android-avd-setup]
sources:
- lib/**/*.dart
- integration_test/app_e2e_test.dart
- android/**/*
generates:
- build/integration-android.done
cmds:
- stalwart-dev/integration_android_test.sh
- touch build/integration-android.done
2026-04-17 10:05:31 +02:00
build-linux:
desc: Build the Linux desktop app (debug)
deps: [_preflight, _linux-deps-check, _codegen, generate-changelog]
method: timestamp
sources:
- lib/**/*.dart
- linux/**/*
- pubspec.yaml
generates:
- build/linux/x64/debug/bundle/sharedinbox
2026-04-17 10:05:31 +02:00
cmds:
2026-04-25 07:07:05 +02:00
- scripts/silent_on_success.sh fvm flutter build linux --debug --no-pub
2026-04-17 10:05:31 +02:00
build-linux-release:
desc: Build the Linux desktop app (release)
deps: [_preflight, _linux-deps-check, _codegen, generate-changelog]
method: timestamp
sources:
- lib/**/*.dart
- linux/**/*
- pubspec.yaml
generates:
- build/linux/x64/release/bundle/sharedinbox
cmds:
- scripts/silent_on_success.sh fvm flutter build linux --release --no-pub
_android-avd-setup:
internal: true
run: once
status:
- test -f "${ANDROID_HOME:-$HOME/Android/Sdk}/emulator/emulator"
- test -d "$HOME/.android/avd/sharedinbox_test.avd"
cmds:
- cmd: |
SDK="${ANDROID_HOME:-$HOME/Android/Sdk}"
SDKMANAGER="$SDK/cmdline-tools/latest/bin/sdkmanager"
AVDMANAGER="$SDK/cmdline-tools/latest/bin/avdmanager"
yes | "$SDKMANAGER" --licenses >/dev/null 2>&1 || true
"$SDKMANAGER" "emulator" "system-images;android-34;google_apis;x86_64"
echo no | "$AVDMANAGER" create avd \
--name sharedinbox_test \
--package "system-images;android-34;google_apis;x86_64" \
--device pixel_4 \
--force
2026-04-19 15:30:42 +02:00
_android-sdk-check:
internal: true
run: once
preconditions:
- sh: test -d "${ANDROID_HOME:-$HOME/Android/Sdk}"
msg: |
Android SDK not found. Install it with:
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/cmdtools.zip
mkdir -p ~/Android/Sdk/cmdline-tools
unzip /tmp/cmdtools.zip -d ~/Android/Sdk/cmdline-tools
mv ~/Android/Sdk/cmdline-tools/cmdline-tools ~/Android/Sdk/cmdline-tools/latest
~/Android/Sdk/cmdline-tools/latest/bin/sdkmanager "platform-tools" "build-tools;34.0.0" "platforms;android-34"
- sh: ls "${ANDROID_HOME:-$HOME/Android/Sdk}/platforms/" 2>/dev/null | grep -qE '^android-([3-9][4-9]|[4-9][0-9]|[1-9][0-9]{2,})$'
msg: |
Android platform 34 or higher not found. Install it with:
${ANDROID_HOME:-$HOME/Android/Sdk}/cmdline-tools/latest/bin/sdkmanager "build-tools;34.0.0" "platforms;android-34"
build-android:
desc: Build a release APK
deps: [_preflight, _android-sdk-check, _pub-get, generate-changelog]
method: timestamp
sources:
- lib/**/*.dart
- android/**/*
- pubspec.yaml
generates:
- build/app/outputs/flutter-apk/app-release.apk
2026-04-19 15:30:42 +02:00
cmds:
- ANDROID_HOME=${ANDROID_HOME:-$HOME/Android/Sdk} fvm flutter build apk --release --no-pub | grep -Ev "was tree-shaken|Tree-shaking can be disabled"
2026-04-19 15:30:42 +02:00
deploy-android-bundle:
desc: Build release AAB and upload to Play Store internal track
deps: [build-android-bundle]
preconditions:
- sh: test -n "$PLAY_STORE_CONFIG_JSON"
msg: "PLAY_STORE_CONFIG_JSON is not set"
cmds:
- python3 scripts/deploy_playstore.py
2026-05-12 08:15:47 +02:00
build-android-bundle:
desc: Build a release App Bundle (AAB)
deps: [_preflight, _android-sdk-check, _codegen, generate-changelog]
2026-05-12 08:15:47 +02:00
method: timestamp
sources:
- lib/**/*.dart
- android/**/*
- pubspec.yaml
generates:
- build/app/outputs/bundle/release/app-release.aab
cmds:
- ANDROID_HOME=${ANDROID_HOME:-$HOME/Android/Sdk} fvm flutter build appbundle --release --no-pub --build-number $(( $(date +%y) - 20 ))$(date +%m%d%H%M) --build-name $(date +%y%m%d-%H%M) | grep -Ev "was tree-shaken|Tree-shaking can be disabled"
2026-05-12 08:15:47 +02:00
2026-04-19 15:30:42 +02:00
deploy-android:
desc: Build release APK and upload via scp to $ANDROID_APK_SCP_USER@$ANDROID_APK_SCP_HOST:$ANDROID_APK_SCP_PATH
deps: [check, build-android]
sources:
- build/app/outputs/flutter-apk/app-release.apk
generates:
- build/deploy-android.done
2026-04-19 15:30:42 +02:00
dotenv: [".env"]
preconditions:
- sh: test -n "$ANDROID_APK_SCP_HOST"
msg: "ANDROID_APK_SCP_HOST is not set in .env"
- sh: test -n "$ANDROID_APK_SCP_USER"
msg: "ANDROID_APK_SCP_USER is not set in .env"
- sh: test -n "$ANDROID_APK_SCP_PATH"
msg: "ANDROID_APK_SCP_PATH is not set in .env"
cmds:
# integration-android runs after check (not in parallel) so the two E2E
# test suites don't compete for CPU and slow the Android emulator.
- task: integration-android
2026-04-19 15:30:42 +02:00
- scripts/deploy_android.sh
- touch build/deploy-android.done
run:
desc: Run the app on Linux desktop
2026-04-25 07:12:56 +02:00
deps: [_preflight, _linux-deps-check, _pub-get]
cmds:
- fvm flutter run -d linux --no-pub
run-android:
desc: Run the app on a connected Android emulator (boots sharedinbox_test AVD if needed)
deps: [_preflight, _android-sdk-check, _android-avd-setup, _pub-get]
cmds:
- stalwart-dev/run_android.sh
coverage:
desc: Coverage gate — run after test (and optionally integration) have written lcov.info
2026-04-25 07:12:56 +02:00
deps: [_preflight]
cmds:
- fvm dart run scripts/check_coverage.dart
check-coverage:
desc: Run unit+widget tests with coverage, then fail if the gate is not met
deps: [test]
cmds:
- task: coverage
website-dev:
desc: Run Hugo development server
cmds:
- fvm flutter pub global run # Just a placeholder if nix shell hook isn't active
- nix develop --command hugo server --source website -D
website-build:
desc: Build the static website (embeds current git hash via HUGO_PARAMS_GITVERSION)
env:
HUGO_PARAMS_GITVERSION:
sh: git rev-parse --short HEAD
cmds:
- hugo --source website --minify
website-verify:
desc: Check that the deployed site serves the current git version
cmds:
- scripts/website-verify.sh
website-deploy:
desc: Deploy the website via rsync to public_html
deps: [website-build]
cmds:
- |
rsync -avz --delete \
-e "ssh -o StrictHostKeyChecking=no" \
website/public/ \
${SSH_USER}@${SSH_HOST}:public_html/
check-fast:
desc: Pre-commit checks — analyze + unit+widget tests + coverage gate (no build, no integration)
deps: [analyze, check-coverage, check-hygiene, check-layers]
check-layers:
desc: Enforce architecture — ui/ must not import data/ (only core/ interfaces allowed)
cmds:
- |
VIOLATIONS=$(grep -rn "package:sharedinbox/data/" lib/ui/ 2>/dev/null || true)
if [ -n "$VIOLATIONS" ]; then
echo "ERROR: UI layer imports data layer (only core/ interfaces are allowed from ui/):"
echo "$VIOLATIONS"
exit 1
fi
check-hygiene:
desc: Verify that no forbidden files (like home dir config) are tracked
cmds:
- |
FORBIDDEN=".ssh .bashrc .config .local .cache .gitconfig .android Android .gradle .pub-cache .dartServer .flutter .dart-cli-completion .atuin .bash_logout .profile .zcompdump .zshrc snap .emulator_console_auth_token .lesshst .metadata .tmux.conf"
TRACKED=$(git ls-files $FORBIDDEN 2>/dev/null)
if [ -n "$TRACKED" ]; then
echo "ERROR: The following forbidden files are tracked in git:"
echo "$TRACKED"
echo "Please remove them with 'git rm --cached <file>'"
exit 1
fi
echo "Hygiene check passed."
_integrations:
internal: true
run: once
cmds:
- task: integration
- task: integration-ui
ci-logs:
desc: "Fetch latest CI job logs from Codeberg. Usage: task ci-logs [RUN=8] [JOB=0]"
cmds:
- scripts/ci_logs.sh "{{.RUN}}" "{{.JOB}}"
check:
desc: Full check suite — unit tests first, then integration (merges coverage), then gate
2026-05-12 21:55:06 +02:00
deps: [analyze, build-linux, test]
cmds:
- task: _integrations
- task: coverage