Skip to content

chore(ci): actually enforce Dart formatting with the pinned SDK - #130

Merged
PapyElGringo merged 1 commit into
mainfrom
chore/dart-format-ci
Oct 13, 2026
Merged

PapyElGringo merged 1 commit into
mainfrom
chore/dart-format-ci

Conversation

@PapyElGringo

@PapyElGringo PapyElGringo commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The existing "Flutter Format Dart Code" workflow did not actually keep the shell formatted, and it formatted with a different SDK than the project pin. This makes formatting a real, enforced gate. Rebased on top of the merged #129.

What was broken

  • Nothing was ever pushed. The job committed its formatting on the CI runner and had no git push, so the commit was discarded — despite the step being named "Commit and push formatted code".
  • Unpinned SDK. subosito/flutter-action@v2 with no version installs the latest stable Flutter/Dart, not the project pin in Cargo.toml ([package.metadata] flutter_version). The formatter's output is version-dependent, so CI's style could drift from .flutter_sdk/bin/dart.
  • It auto-formatted instead of gating, so unformatted code was never caught, and the committed baseline was not format-clean under the pinned formatter.

Changes

  • Gate, don't rewrite: dart format --output=none --set-exit-if-changed lib test from src/shell — drift now fails the job.
  • Use the project pin: read flutter_version from Cargo.toml and install exactly that SDK, so CI formats with the same formatter as .flutter_sdk/bin/dart locally.
  • Resolve dependencies first (flutter pub get): the formatter derives its output from the package language version recorded in .dart_tool/package_config.json. Without it, CI falls back to a different default and reports drift on a already-clean tree (the first CI run failed exactly this way: 47 files "changed").
  • Target only real sources (lib, test); the previous dart format . also walked into build/.
  • Drop the unused checkout token (nothing is pushed anymore).
  • Add the dart format step to the AGENTS.md verification loop.

Formatting pass

The repo-wide reformat uses the pinned SDK (.flutter_sdk, Flutter 3.47.7): 138 Dart files, whitespace only, 1199 insertions / 1420 deletions. The tree was in the pre-3.7 "short" style; it now matches the pinned formatter, which is what makes the new gate green and keeps future diffs free of incidental churn.

Verification

  • dart format --output=none --set-exit-if-changed lib test → exit 0 (0 files changed).
  • flutter test — 448 passed.
  • No generated files are committed (.g.dart / .freezed.dart are ignored; a fresh CI checkout has none, so the gate only checks tracked sources).

@PapyElGringo
PapyElGringo force-pushed the chore/dart-format-ci branch 2 times, most recently from 0e2916c to 772d611 Compare October 13, 2026 21:52
The "Flutter Format Dart Code" workflow never kept the tree formatted: it
committed its formatting on the runner but had no `git push`, and it set up
an unpinned Flutter (latest stable) rather than the project-pinned SDK, so
its idea of the style could differ from `.flutter_sdk`.

- Turn the job into a real gate: `dart format --output=none
  --set-exit-if-changed lib test` from `src/shell`, so drift fails CI
  instead of hiding in a discarded bot commit.
- Read the Flutter pin from `Cargo.toml` `[package.metadata]
  flutter_version` and install exactly that SDK, so CI formats with the same
  formatter as the project pin.
- Drop the unused checkout token now that nothing is pushed.
- Format the whole shell (`lib`, `test`) with the pinned SDK so the new gate
  is green; whitespace only.
- Document the command in AGENTS.md's verification loop.
@PapyElGringo
PapyElGringo merged commit 0f12ada into main Oct 13, 2026
2 checks passed
@PapyElGringo
PapyElGringo deleted the chore/dart-format-ci branch October 13, 2026 22:02
@PapyElGringo PapyElGringo mentioned this pull request Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant