From 03e4198fdd286b4eb21c558588159fd7b2f4fee3 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Thu, 2 Jul 2026 18:51:11 -0400 Subject: [PATCH] ci: fail on stale generated files run build_runner in both ci.yml (push to main) and pr-check.yml (PRs), then fail if git status is dirty. catches forgetting to regenerate a .g.dart after editing a MobX store or @JsonSerializable model, which analyze/test/build all miss (as #576 did). Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/ci.yml | 12 ++++++++++++ .github/workflows/pr-check.yml | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce303d57..3a14cc5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,18 @@ jobs: cache: true - run: flutter doctor -v - run: flutter pub get + # Fail if committed generated files (*.g.dart) are stale — CI never runs + # build_runner otherwise, so forgetting to regenerate after editing a MobX + # store or @JsonSerializable model slips past analyze/test/build. + - run: dart run build_runner build --delete-conflicting-outputs + - name: Verify generated files are up to date + run: | + if [ -n "$(git status --porcelain)" ]; then + echo '::error::Generated files are out of date. Run `dart run build_runner build --delete-conflicting-outputs` and commit the result.' + git status --porcelain + git diff + exit 1 + fi - run: flutter analyze - run: flutter test - run: flutter build apk --release diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 2b632d17..8ea53ae2 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -20,6 +20,18 @@ jobs: cache: true - run: flutter doctor -v - run: flutter pub get + # Fail if committed generated files (*.g.dart) are stale — CI never runs + # build_runner otherwise, so forgetting to regenerate after editing a MobX + # store or @JsonSerializable model slips past analyze/test/build. + - run: dart run build_runner build --delete-conflicting-outputs + - name: Verify generated files are up to date + run: | + if [ -n "$(git status --porcelain)" ]; then + echo '::error::Generated files are out of date. Run `dart run build_runner build --delete-conflicting-outputs` and commit the result.' + git status --porcelain + git diff + exit 1 + fi - run: flutter analyze - run: flutter test # Release-mode compile check (no signing secrets needed — Android falls back