Skip to content

flet build: --log-format github for structured steps and annotations - #6952

Open
FeodorFitsner wants to merge 1 commit into
flet-1.1.0from
feature/cli-log-format
Open

FeodorFitsner wants to merge 1 commit into
flet-1.1.0from
feature/cli-log-format

Conversation

@FeodorFitsner

@FeodorFitsner FeodorFitsner commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6947.

What

flet build (and the other Flutter-based commands: debug, test, devices, emulators) get --log-format {rich,plain,github} (env FLET_CLI_LOG_FORMAT):

  • rich — current interactive output (default).
  • plain — current --no-rich-output output; --no-rich-output / FLET_CLI_NO_RICH_OUTPUT stay as aliases.
  • github — plain output plus GitHub Actions workflow commands: each build phase is a collapsible ::group::, warnings/errors are ::warning:: / ::error:: annotations.

How

  • New utils/log_format.py: format resolution, workflow-command formatting and escaping (data %, \r, \n; properties also :, ,).
  • BaseFlutterCommand.step(status) replaces update_status() + the trailing "… OK" pairs; groups are closed on exceptions and by cleanup(), and never nest (GitHub doesn't support nesting).
  • warn() / error() replace the console.log("Warning: …") call sites (15). cleanup() with a non-zero exit emits ::error:: titled after the failing step and runs flutter doctor in its own group.
  • Steps: install Flutter/JDK/Android SDK, create app shell, package Python app, Pyodide runtime, register extensions, icons, splash, flutter build <target>, copy output, macOS signing/notarization/.pkg.

rich and plain output are unchanged (byte-for-byte tests against the previous console.log/console.print calls). Review with git diff -w — wrapping blocks in with self.step(...) re-indents much of build_base.py.

Example (flet build web --log-format github)

::group::Packaging Python app
::warning title=App package::.env not packaged. If the app loads it at runtime ...
[13:01:28] Packaged Python app OK
::endgroup::
::group::Generating app icons
::warning title=App icon,file=assets/icon.png::icon source is 512x256, not square. ...
::endgroup::
::group::Building web app
::error title=Building web app::Error building Flet app - see the log of failed command above.
::endgroup::

Tests

cd sdk/python && uv run --no-dev --group test pytest packages/flet-cli/tests → 535 passed, 1 skipped (69 new in tests/test_log_format.py: escaping, format resolution, --log-format in --help, github-output snapshots incl. groups closed on exception and cleanup(), and byte-identical rich/plain output). Also ran a real flet build web with --log-format github end to end.

Docs: website/docs/cli/flet-build.md (Log formats), reference/environment-variables.md, and the GitHub Actions example in publish/index.md now uses FLET_CLI_LOG_FORMAT: github. CHANGELOG entry under 1.1.0.

Not included (possible follow-ups): auto-selecting github when GITHUB_ACTIONS=true; flet debug/devices/emulators/test status lines are still plain lines in github mode.

Summary by Sourcery

Add configurable structured logging to Flutter-based Flet CLI commands, including GitHub Actions groups and annotations while retaining existing interactive and plain output.

New Features:

  • Add rich, plain, and GitHub Actions log formats to Flutter-based CLI commands, configurable through --log-format or FLET_CLI_LOG_FORMAT.
  • Emit collapsible GitHub Actions groups for build steps and workflow annotations for warnings, errors, and failed builds.

Enhancements:

  • Preserve existing rich and plain output while standardizing build-step, warning, error, and cleanup reporting across Flutter commands.
  • Ensure workflow output safely escapes annotation content and closes groups when steps fail or cleanup runs.

Documentation:

  • Document CLI log formats and environment-variable configuration, and update the GitHub Actions publishing example to use structured output.

Tests:

  • Add comprehensive coverage for format resolution, workflow-command escaping, grouped output, annotations, failure cleanup, and unchanged rich/plain output.

Chores:

  • Record the new CLI log-format support in the changelog.

…6947)

Add `--log-format {rich,plain,github}` (env `FLET_CLI_LOG_FORMAT`) to the
Flutter-based commands. `rich` is the current default, `plain` is the
current `--no-rich-output` behavior (`--no-rich-output` and
`FLET_CLI_NO_RICH_OUTPUT` stay as aliases), and `github` is plain output
plus GitHub Actions workflow commands.

- `BaseFlutterCommand.step(status)` replaces the `update_status()` calls
  of the build phases: Flutter SDK/JDK/Android SDK install, app shell,
  Python app packaging, Pyodide runtime, Flutter extensions, app icons,
  splash screens, `flutter build <target>`, copying the output, and macOS
  signing / notarization / .pkg packaging. In `github` it renders as
  `::group::` ... `::endgroup::`, closed on exceptions and `cleanup()`;
  groups never nest.
- `warn()`/`error()` replace the `Warning: ...` log calls; `rich`/`plain`
  output is unchanged, `github` emits `::warning title=...,file=...::`
  annotations with workflow-command escaping.
- `cleanup()` with a non-zero exit code emits `::error::`, titled after
  the failed step, and runs `flutter doctor` in its own group.

Closes #6947
@sourcery-ai

sourcery-ai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Sorry @FeodorFitsner, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 22 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@FeodorFitsner
FeodorFitsner requested a balanced review from Copilot October 10, 2026 21:07
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0fddc0a
Status: ✅  Deploy successful!
Preview URL: https://2ebfca43.flet-website-v2.pages.dev
Branch Preview URL: https://feature-cli-log-format.flet-website-v2.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open findings
What changed in this PR

Adds configurable structured logging for Flutter-based flet CLI commands, including a new GitHub Actions-friendly mode with grouped steps and workflow annotations, while preserving existing rich/plain output behavior.

Changes:

  • Introduces --log-format {rich,plain,github} and FLET_CLI_LOG_FORMAT across Flutter-based commands, with --no-rich-output as an alias for plain.
  • Adds a new logging/formatting utility that emits GitHub Actions ::group:: blocks and ::warning::/::error:: annotations.
  • Updates docs and CI publishing example to use the new GitHub log format; adds extensive tests for format selection and output snapshots.
File Description
website/​docs/​reference/​environment-variables.md Documents FLET_CLI_LOG_FORMAT and clarifies FLET_CLI_NO_RICH_OUTPUT aliasing.
website/​docs/​publish/​index.md Updates CI example to use FLET_CLI_LOG_FORMAT: github.
website/​docs/​cli/​flet-build.md Adds “Log formats” section and GitHub Actions output example.
sdk/​python/​packages/​flet-cli/​src/​flet_cli/​utils/​log_format.py New log-format resolver and GitHub workflow-command rendering (escaping, grouping, annotations).
sdk/​python/​packages/​flet-cli/​src/​flet_cli/​commands/​flutter_base.py Wires --log-format, introduces step grouping, and routes warnings/errors through shared output.
sdk/​python/​packages/​flet-cli/​src/​flet_cli/​commands/​build_base.py Converts build phases and warning sites to step contexts + annotations (uses annotation_path).
sdk/​python/​packages/​flet-cli/​src/​flet_cli/​commands/​build.py Wraps build/sign/notarize/pkg phases in steps for consistent grouped logging.
sdk/​python/​packages/​flet-cli/​tests/​test_log_format.py New comprehensive tests for escaping, resolution, and output snapshots.
sdk/​python/​packages/​flet-cli/​tests/​test_flutter.py Adapts tests to new step() API.
CHANGELOG.md Records new CLI logging option and environment variable.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +333 to +340
group_id = self.start_group(title)
try:
yield
except Exception:
self._failed_group = title
raise
finally:
self.end_group(group_id)
Comment on lines +200 to +202
Output format of `flet build`, `flet debug` and `flet test`: `rich`, `plain` or `github`.
Same as the `--log-format` option, which takes precedence. See
[`flet build`](../cli/flet-build.md#log-formats).
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.

2 participants