From 999c327b9e46160cdd4f2660d3fecf4bd6775fda Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 29 Apr 2026 04:16:14 +0000 Subject: [PATCH] ci: verify committed generated files are up to date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The repo commits its generated code (52 *.mocks.dart, 42 *.g.dart) and build.yaml never runs build_runner, so releases are compiled from exactly what is checked in — but nothing checked that it still matches its sources. Run build_runner in the test job and fail on any *.mocks.dart or *.g.dart the generators would rewrite, pointing at scripts/dev/build_runner.sh. The step also works around two generator quirks, commented inline: --delete-conflicting-outputs deletes the gitignored generated app config, and hive_ce emits an untracked registrar this repo never imports. --- .github/workflows/test.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index eca0145f8b..fcbee08aaa 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -66,6 +66,34 @@ jobs: run: bash prebuild.sh working-directory: scripts + - name: Verify committed generated files are up to date + run: | + # --delete-conflicting-outputs deletes the gitignored app config too + # (source_gen claims .dart -> .g.dart for every input), and + # ensure_test_app_config.sh's stub is not the configured app, so put + # the configured file back and leave the script as the fallback. + SAVED_APP_CONFIG="${RUNNER_TEMP:-/tmp}/app_config.g.dart.saved" + cp lib/app_config.g.dart "$SAVED_APP_CONFIG" + dart run build_runner build --delete-conflicting-outputs + cp "$SAVED_APP_CONFIG" lib/app_config.g.dart + bash scripts/ensure_test_app_config.sh + # hive_ce emits a registrar nothing here imports; never delete it if + # someone has committed it. + if [ -f lib/hive_registrar.g.dart ] \ + && ! git ls-files --error-unmatch lib/hive_registrar.g.dart >/dev/null 2>&1; then + rm -f lib/hive_registrar.g.dart + fi + + # build.yaml never runs build_runner, so releases are compiled from + # the committed *.g.dart; stale isar/drift output has to fail the job + # here or nothing checks it at all. + GENERATED_STATUS=$(git status --porcelain -- '*.mocks.dart' '*.g.dart') + if [ -n "$GENERATED_STATUS" ]; then + echo "$GENERATED_STATUS" + echo "::error::Committed generated files differ from build_runner output; re-run scripts/dev/build_runner.sh and commit the result." + exit 1 + fi + - name: Check formatting of changed files run: | if [ "${{ github.event_name }}" = "pull_request" ]; then