Repository navigation
flet build: --log-format github for structured steps and annotations - #6952
FeodorFitsner wants to merge 1 commit into
Conversation
…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
|
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 |
Deploying flet-website-v2 with
|
| 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 |
There was a problem hiding this comment.
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}andFLET_CLI_LOG_FORMATacross Flutter-based commands, with--no-rich-outputas an alias forplain. - 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.
| group_id = self.start_group(title) | ||
| try: | ||
| yield | ||
| except Exception: | ||
| self._failed_group = title | ||
| raise | ||
| finally: | ||
| self.end_group(group_id) |
| 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). |

Closes #6947.
What
flet build(and the other Flutter-based commands:debug,test,devices,emulators) get--log-format {rich,plain,github}(envFLET_CLI_LOG_FORMAT):rich— current interactive output (default).plain— current--no-rich-outputoutput;--no-rich-output/FLET_CLI_NO_RICH_OUTPUTstay as aliases.github— plain output plus GitHub Actions workflow commands: each build phase is a collapsible::group::, warnings/errors are::warning::/::error::annotations.How
utils/log_format.py: format resolution, workflow-command formatting and escaping (data%,\r,\n; properties also:,,).BaseFlutterCommand.step(status)replacesupdate_status()+ the trailing "… OK" pairs; groups are closed on exceptions and bycleanup(), and never nest (GitHub doesn't support nesting).warn()/error()replace theconsole.log("Warning: …")call sites (15).cleanup()with a non-zero exit emits::error::titled after the failing step and runsflutter doctorin its own group.flutter build <target>, copy output, macOS signing/notarization/.pkg.richandplainoutput are unchanged (byte-for-byte tests against the previousconsole.log/console.printcalls). Review withgit diff -w— wrapping blocks inwith self.step(...)re-indents much ofbuild_base.py.Example (
flet build web --log-format github)Tests
cd sdk/python && uv run --no-dev --group test pytest packages/flet-cli/tests→ 535 passed, 1 skipped (69 new intests/test_log_format.py: escaping, format resolution,--log-formatin--help, github-output snapshots incl. groups closed on exception andcleanup(), and byte-identical rich/plain output). Also ran a realflet build webwith--log-format githubend to end.Docs:
website/docs/cli/flet-build.md(Log formats),reference/environment-variables.md, and the GitHub Actions example inpublish/index.mdnow usesFLET_CLI_LOG_FORMAT: github. CHANGELOG entry under 1.1.0.Not included (possible follow-ups): auto-selecting
githubwhenGITHUB_ACTIONS=true;flet debug/devices/emulators/teststatus 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:
--log-formatorFLET_CLI_LOG_FORMAT.Enhancements:
Documentation:
Tests:
Chores: