[ci] Is dart format doing what we want (in CI)?
While working on an unrelated task, I noticed the following output in the dart format check:
Running Dart format...
Warning: Package resolution error when reading "analysis_options.yaml" file for "samples/client/flutter/restaurant_finder/app/lib/main.dart":
Failed to resolve package URI "package:lints/recommended.yaml" in include at "/home/runner/work/a2ui/a2ui/analysis_options.yaml".
Warning: Package resolution error when reading "analysis_options.yaml" file for "samples/client/flutter/restaurant_finder/app/lib/src/main.dart":
Failed to resolve package URI "package:lints/recommended.yaml" in include at "/home/runner/work/a2ui/a2ui/analysis_options.yaml".
Warning: Package resolution error when reading "analysis_options.yaml" file for "samples/client/flutter/restaurant_finder/app/test/widget_test.dart":
Failed to resolve package URI "package:lints/recommended.yaml" in include at "/home/runner/work/a2ui/a2ui/analysis_options.yaml".
Warning: Package resolution error when reading "analysis_options.yaml" file for "samples/client/flutter/restaurant_finder/e2e_test/test/infra_test.dart":
Failed to resolve package URI "package:lints/recommended.yaml" in include at "/home/runner/work/a2ui/a2ui/analysis_options.yaml".
Warning: Package resolution error when reading "analysis_options.yaml" file for "samples/client/flutter/restaurant_finder/e2e_test/test/test_infra/ai_client.dart":
Failed to resolve package URI "package:lints/recommended.yaml" in include at "/home/runner/work/a2ui/a2ui/analysis_options.yaml".
Formatted 13 files (0 changed) in 0.02 seconds.
Failed to resolve package URI
"package:lints/recommended.yaml"in include at".../analysis_options.yaml".
See this build task.
Are we applying the lints that we expect?
Gemini ideas:
Root Cause & Proposed Solution
🔍 Root Cause
• scripts/fix_format.sh https://github.com/a2ui-project/a2ui/blob/main/scripts/fix_format.sh runs dart pub get before formatting so dart format can resolve package:lints/recommended.yaml referenced in analysis_options.yaml. • In Dart-only CI steps (such as presubmit-lint.yml), only the standard Dart SDK is installed (setup-dart). • dart pub get currently fails with Because a2ui_monorepo requires the Flutter SDK, version solving failed. because the monorepo root pubspec.yaml specifies a flutter environment constraint (flutter: ">=3.35.7 <4.0.0"), a flutter: block, and includes Flutter sample packages in its Pub workspace:. • Because dart pub get fails in Dart-only CI environments, .dart_tool/package_config.json is not generated, causing dart format to emit the Package resolution error when reading "analysis_options.yaml" warning. ──────
💡 Proposed Fix
- Update root pubspec.yaml: • Remove flutter from environment: and remove the flutter: config block (the monorepo root is a workspace container, not a Flutter package). • Scope workspace: to pure Dart packages (dart/a2ui_agent, dart/a2ui_core).
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -18,15 +18,10 @@ license: BSD-3-Clause
environment:
sdk: ">=3.10.0 <4.0.0"
- flutter: ">=3.35.7 <4.0.0"
workspace:
- - samples/client/flutter/restaurant_finder/app
- - samples/client/flutter/restaurant_finder/e2e_test
- dart/a2ui_agent
- dart/a2ui_core
-flutter:
- uses-material-design: true
dev_dependencies:
lints: ^6.1.0
- Update Flutter sample pubspecs: • Remove resolution: workspace from samples/client/flutter/restaurant_finder/app/pubspec.yaml and samples/client/flutter/restaurant_finder/e2e_test/pubspec.yaml so they resolve independently using flutter pub get during Flutter test workflows.
──────
✨ Result
With these changes, dart pub get succeeds cleanly in Dart-only CI environments, generating .dart_tool/package_config.json and eliminating all resolution warnings during dart format.
Digging into this, the answer to "are we applying the lints that we expect?" splits in two, and only one half is about the warning quoted above.
The warning itself does not change formatting output. dart format reads analysis_options.yaml, but only for its formatter: section — page_width and friends — never for lint rules. This repository sets no formatter: section, so an unresolved include: leaves the formatter with nothing to lose. I checked the reading rather than assuming it: with formatter: page_width: 40 in an analysis_options.yaml, dart format does wrap at 40 columns, so the file is read; without that section there is nothing in it for the formatter to act on. What does change formatting output is the language version, which fix_format.sh already pins to 3.10 for exactly that reason, with a comment explaining the CI case.
So the warning is noise in the log rather than a silent behaviour change — though it is worth quieting, and the root-cause analysis above (the root pubspec's Flutter constraint blocking dart pub get under a Dart-only SDK) matches what I ran into.
The lints, though, are genuinely not applied to dart/. Lint rules only take effect through the analyzer, and no workflow analyzes those packages. flutter_packages_test.yml builds its matrix from find samples -name pubspec.yaml, so dart/a2ui_core and dart/a2ui_agent never enter it, and grep -rn "dart analyze\|dart test" .github/workflows/ returns only those samples lines. fix_format.sh formats samples/client/flutter renderers/flutter, which does not include dart/ either — and renderers/flutter currently holds only a README.
The consequence is broader than lints: those two packages ship to pub.dev and nothing in CI compiles, analyzes or tests them. #2374 changed MessageProcessor and was merged without its 74 tests ever running in CI.
I filed that as #2493 and opened #2494, which adds a dart/ matrix running dart pub get, dart format --set-exit-if-changed, dart analyze --fatal-infos and dart test. --fatal-infos is the piece that makes it a lint gate at all: the analyzer reports lint violations as infos, so without it a job exits 0 on a file that breaks every rule in analysis_options.yaml.
That PR uses the repository's setup-dart action (which installs Flutter) rather than depending on the pubspec split proposed here, so the two changes are independent. If the root pubspec is split as suggested above, that job can drop to a lightweight Dart SDK by swapping a single step.
A2UI Triage: Thanks @diegolopezrm for the detailed analysis on dart format vs dart analyze --fatal-infos. It sounds like this is already fixed by https://github.com/a2ui-project/a2ui/pull/2439 per https://github.com/a2ui-project/a2ui/issues/2493#issuecomment-5543725037. Marking as fixed.