From 61a7b90bc144bcef892b8950bfce6905ccc071b9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 7 Jun 2026 00:23:14 +0000 Subject: [PATCH] ci: eliminate duplicate build_runner run in CheckGenerated Instead of re-running build_runner from scratch (git-snapshot approach), reuse codegenBase().Directory("/src") and diff committed *.g.dart / *.mocks.dart files against the freshly generated ones with diff -rq. Saves ~3 min per CI run. Closes #492. Co-Authored-By: Claude Sonnet 4.6 --- ci/main.go | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/ci/main.go b/ci/main.go index a7b8423..c56a291 100644 --- a/ci/main.go +++ b/ci/main.go @@ -503,23 +503,18 @@ func (m *Ci) CheckFast(ctx context.Context) (string, error) { } // CheckGenerated verifies that all generated files (*.g.dart, *.mocks.dart) are up to date. -// It snapshots the committed source (including any stale generated files) before -// running build_runner, so git diff detects real staleness instead of always -// comparing two freshly-generated outputs. +// It reuses the codegenBase() output instead of running build_runner a second time, +// diffing committed generated files against the freshly built ones. func (m *Ci) CheckGenerated(ctx context.Context) (string, error) { + fresh := m.codegenBase().Directory("/src") return m.pubGetLayer(). - WithDirectory("/src", m.checkSrc(), dagger.ContainerWithDirectoryOpts{Owner: "ci"}). - WithWorkdir("/src"). - WithExec([]string{"git", "init"}). - WithExec([]string{"git", "config", "user.email", "ci@sharedinbox.de"}). - WithExec([]string{"git", "config", "user.name", "CI"}). - WithExec([]string{"git", "add", "."}). - WithExec([]string{"git", "commit", "-q", "-m", "baseline"}). + WithDirectory("/committed", m.checkSrc(), dagger.ContainerWithDirectoryOpts{Owner: "ci"}). + WithDirectory("/generated", fresh, dagger.ContainerWithDirectoryOpts{Owner: "ci"}). WithExec([]string{"/bin/bash", "-c", - `tmp=$(mktemp); trap 'rm -f "$tmp"' EXIT; ` + - `flutter pub run build_runner build --delete-conflicting-outputs >"$tmp" 2>&1 || { cat "$tmp"; exit 1; }; ` + - `grep -vE '^\[.*s\] \|' "$tmp" || true`}). - WithExec([]string{"/bin/bash", "-c", "CHANGED=$(find . \\( -name '*.g.dart' -o -name '*.mocks.dart' \\) | xargs -r git diff --exit-code); if [ $? -ne 0 ]; then echo \"ERROR: Generated files are out of date — run: dart run build_runner build\"; exit 1; fi; echo \"Generated files are up to date.\""}). + `if diff -rq --include='*.g.dart' --include='*.mocks.dart' /committed /generated; then ` + + `echo "Generated files are up to date."; ` + + `else echo "ERROR: Generated files are out of date — run: dart run build_runner build"; exit 1; ` + + `fi`}). Stdout(ctx) }