fix(ci): stop gradle daemon between flutter build apk and assembleAndroidTest

`flutter build apk --debug --no-pub` spawns a Gradle daemon whose journal
cache lock file lives on the persistent Dagger `gradle-cache` mount. When
the WithExec finishes, Dagger tears the container down and force-kills the
daemon, but the lock file remains with its now-dead PID. The next exec —
`./gradlew --no-daemon app:assembleAndroidTest` — then times out after 60s
waiting for that stale lock, failing the Firebase Test Lab build with:

  > Timeout waiting to lock journal cache (/home/ci/.gradle/caches/journal-1).
    It is currently in use by another process.
    Owner PID: 88
    Our PID: 53

The existing `--no-daemon` on the second exec only prevented daemon-registry
reuse, not stale lock files. Chain `./gradlew --stop` into the first exec so
the daemon shuts down gracefully and releases its locks before Dagger
snapshots the layer.

Closes #549

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till Düßmann (Claude agent)
2026-06-10 10:07:02 +00:00
co-authored by Claude Opus 4.7
parent 0297701829
commit 7239036c8e
+8 -1
View File
@@ -814,7 +814,14 @@ 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.firebaseBase().
WithExec([]string{"flutter", "build", "apk", "--debug", "--no-pub"}).
// `flutter build apk` spawns a Gradle daemon. When this WithExec ends the
// container is torn down and the daemon is killed, but its journal-cache
// lock file on the persistent gradle-cache volume keeps its dead PID — the
// next gradlew invocation then times out waiting for that lock. `gradlew
// --stop` shuts the daemon down gracefully so the lock is released before
// Dagger snapshots the layer.
WithExec([]string{"/bin/bash", "-c",
`flutter build apk --debug --no-pub && (cd android && ./gradlew --stop)`}).
WithWorkdir("/src/android").
// --no-daemon avoids connecting to a stale daemon whose registry file was
// preserved in the Dagger layer snapshot but whose process no longer exists.