Compare commits

..
Author SHA1 Message Date
Thomas SharedInboxandClaude Sonnet 4.6 37abd5abb6 fix: add git hash to crash screen and extend DB path retries (#179)
Two issues from #179:
- crash_screen.dart now reads GIT_HASH compile-time constant and includes
  'Git Commit: <hash>' in both the on-screen UI and the copied report, so
  crash reports always show the exact build that crashed.
- _resolveDatabasePath() retry delays extended from [100, 300, 600] ms
  (total ~1 s, 4 attempts) to [200, 500, 1000, 2000, 4000] ms (total
  ~7.7 s, 6 attempts) to handle slow/non-standard Android devices where
  the path_provider Pigeon channel takes several seconds to become ready.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 16:05:05 +02:00
Thomas SharedInboxandClaude Sonnet 4.6 dcb0cbd539 fix(android): prevent Gradle daemon hang in Firebase test build (#155)
Dagger preserves filesystem snapshots between WithExec steps but kills
background processes. After `flutter build apk --debug` completes, the
Gradle daemon registry file remains in /home/ci/.gradle/daemon/ while
the daemon process itself is gone. The subsequent `./gradlew
app:assembleAndroidTest` step finds the stale registry entry, tries to
connect to the dead daemon, and hangs.

Fix by:
- Adding --no-daemon to the assembleAndroidTest gradlew call so it runs
  in-process and never consults the daemon registry.
- Mounting the gradle-cache volume (same as Base()) so dependencies are
  cached between runs rather than re-downloaded from scratch each time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 15:41:24 +02:00
Thomas SharedInboxandClaude Sonnet 4.6 f7e0ffd4d5 docs: explain why continue-on-error is intentional on deploy steps (#154)
The deploy steps that require SSH_PRIVATE_KEY are best-effort: if the
secret is not set the task precondition fails and the step appears
failed/orange in the UI, but the overall job remains green because of
continue-on-error: true.  This confused issue #154.  Add inline
comments to each affected step explaining that this behavior is
intentional.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 15:27:52 +02:00
5 changed files with 74 additions and 3 deletions
+11
View File
@@ -74,6 +74,10 @@ jobs:
run: task publish-android
- name: Build & Deploy APK to server
# continue-on-error: step requires SSH_PRIVATE_KEY secret; if unset the task
# precondition fails, but we don't want that to fail the whole job — the Play
# Store publish above already succeeded. The overall job stays green even
# though this step shows as failed/orange in the UI.
continue-on-error: true
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
@@ -113,6 +117,11 @@ jobs:
run: scripts/setup_dagger_remote.sh
- name: Build & Deploy Linux to server
# continue-on-error: step requires SSH_PRIVATE_KEY secret; if unset the task
# precondition fails, but the build step that precedes this (done via Dagger)
# already succeeded. Deployment is best-effort; a missing secret should not
# turn the job red. The step will show as failed/orange in the UI even though
# the overall job is green — this is intentional.
continue-on-error: true
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
@@ -154,6 +163,8 @@ jobs:
run: scripts/setup_dagger_remote.sh
- name: Generate build history and deploy website
# continue-on-error: website publish is best-effort; a missing SSH_PRIVATE_KEY
# should not block the overall workflow status.
continue-on-error: true
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
+4 -1
View File
@@ -649,9 +649,12 @@ func (m *Ci) DeployApk(
// Returns a flat directory with app-debug.apk and app-debug-androidTest.apk.
func (m *Ci) BuildAndroidDebugApks() *dagger.Directory {
built := m.setup(m.firebaseSrc()).
WithMountedCache("/home/ci/.gradle", dag.CacheVolume("gradle-cache"), dagger.ContainerWithMountedCacheOpts{Owner: "ci"}).
WithExec([]string{"flutter", "build", "apk", "--debug", "--no-pub"}).
WithWorkdir("/src/android").
WithExec([]string{"./gradlew", "app:assembleAndroidTest"}).
// --no-daemon avoids connecting to a stale daemon whose registry file was
// preserved in the Dagger layer snapshot but whose process no longer exists.
WithExec([]string{"./gradlew", "--no-daemon", "app:assembleAndroidTest"}).
WithWorkdir("/src").
WithExec([]string{"/bin/bash", "-c",
`apk=$(find /src -path "*androidTest*" -name "*.apk" -type f 2>/dev/null | head -1) && \
+4 -2
View File
@@ -596,8 +596,10 @@ Future<void> initDatabasePath() async {
Future<String> _resolveDatabasePath() async {
if (_dbPath != null) return _dbPath!;
// initDatabasePath() failed (channel not ready before runApp). Retry now
// that the engine is fully initialised, with brief back-off.
const delays = [100, 300, 600];
// that the engine is fully initialised, with exponential back-off.
// Longer delays handle slow/non-standard Android devices where the Pigeon
// channel takes several seconds to become available.
const delays = [200, 500, 1000, 2000, 4000];
for (final ms in delays) {
try {
final dir = await getApplicationSupportDirectory();
+12
View File
@@ -15,15 +15,19 @@ class CrashScreen extends StatelessWidget {
final Object exception;
final StackTrace? stackTrace;
static const _gitHash = String.fromEnvironment('GIT_HASH');
Future<String> _buildReport() async {
String version = 'unknown';
try {
final info = await PackageInfo.fromPlatform();
version = '${info.version}+${info.buildNumber}';
} catch (_) {}
final gitLine = _gitHash.isNotEmpty ? 'Git Commit: $_gitHash\n' : '';
final platform =
'${Platform.operatingSystem} ${Platform.operatingSystemVersion}';
return 'App Version: $version\n'
'$gitLine'
'Platform: $platform\n\n'
'Error:\n```\n$exception\n```\n\n'
'Stack Trace:\n```\n$stackTrace\n```';
@@ -50,6 +54,14 @@ class CrashScreen extends StatelessWidget {
style: Theme.of(ctx).textTheme.titleMedium,
textAlign: TextAlign.center,
),
if (_gitHash.isNotEmpty) ...[
const SizedBox(height: 8),
const Text(
'Git Commit: $_gitHash',
style: TextStyle(fontSize: 12, color: Colors.grey),
textAlign: TextAlign.center,
),
],
const SizedBox(height: 24),
const Text(
'Error Details:',
+43
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:package_info_plus/package_info_plus.dart';
@@ -76,6 +77,48 @@ void main() {
expect(mock.launchedUrl, isNot(contains('Stack%20Trace')));
});
testWidgets(
'Copy to Clipboard includes App Version and excludes Git Commit when GIT_HASH is empty',
(
tester,
) async {
tester.view.physicalSize = const Size(800, 1200);
tester.view.devicePixelRatio = 1.0;
addTearDown(() => tester.view.resetPhysicalSize());
UrlLauncherPlatform.instance = MockUrlLauncher();
String? capturedClipboard;
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform,
(MethodCall call) async {
if (call.method == 'Clipboard.setData') {
capturedClipboard = (call.arguments as Map)['text'] as String;
}
return null;
},
);
const exception = 'TestException: clipboard test';
final stackTrace = StackTrace.current;
await tester.pumpWidget(
MaterialApp(
home: CrashScreen(exception: exception, stackTrace: stackTrace),
),
);
await tester.tap(find.text('Copy to Clipboard'));
await tester.pumpAndSettle();
expect(capturedClipboard, isNotNull);
expect(capturedClipboard, contains('App Version:'));
expect(capturedClipboard, contains('Platform:'));
expect(capturedClipboard, contains('TestException: clipboard test'));
// GIT_HASH is empty in tests (no --dart-define), so the line is omitted.
expect(capturedClipboard, isNot(contains('Git Commit:')));
});
testWidgets(
'CrashScreen used as root widget — buttons work without ScaffoldMessenger crash',
(tester) async {