Add --progress option to report command for incremental status updates#343
Merged
Conversation
Reviewer's GuideImplements a new --progress mode for the Sequence diagram for newa report command with --progress optionsequenceDiagram
actor User
participant CLI as NewaCLI
participant ReportCmd as cmd_report
participant Helpers as report_helpers
User->>CLI: newa report --progress
CLI->>ReportCmd: invoke cmd_report(ctx, progress=True)
ReportCmd->>ReportCmd: ctx.enter_command("report")
ReportCmd->>ReportCmd: load execute_jobs
ReportCmd->>ReportCmd: group execute_jobs by jira_id
loop for each jira_id
ReportCmd->>Helpers: _process_jira_id_reports(ctx, jira_id, execute_jobs,
Note over ReportCmd,Helpers: rp, jira_connection, et, rog,
Note over ReportCmd,Helpers: jira_comment_limit, progress_mode=True
activate Helpers
Helpers->>Helpers: _get_rp_launch_details(execute_jobs)
Helpers->>Helpers: execute_jobs_summary(..., target=ReportPortal)
Helpers->>Helpers: _compute_jira_descriptions(...)
alt progress_mode = True
Helpers->>Helpers: build jira_description parts
loop for each jira_description
Helpers->>Helpers: _build_jira_comment(..., progress_mode=True)
Helpers->>Jira: _add_jira_comment_for_report(...)
Jira-->>Helpers: comment added
end
Helpers->>Helpers: skip _finalize_rp_launch
Helpers->>Helpers: skip _transition_jira_issue_based_on_results
Helpers->>Helpers: skip _add_erratum_comment_for_report
Helpers->>Helpers: skip _add_rog_comment_for_report
end
deactivate Helpers
end
ReportCmd-->>CLI: reporting progress complete
CLI-->>User: show completion of progress report only
Updated class diagram for report helpers and report command progress modeclassDiagram
class CLIContext {
}
class ReportCommand {
+cmd_report(ctx: CLIContext, progress: bool) void
}
class ReportHelpers {
+execute_jobs_summary(ctx: CLIContext, jira_id: str, execute_jobs: list, target: str) tuple
+_build_jira_comment(status: str, all_tests_finished: bool, launch_uuid: str?, launch_url: str?, jira_description: str, footer: str = '', first_comment: bool = True, progress_mode: bool = False) str
+_process_jira_id_reports(ctx: CLIContext, jira_id: str, execute_jobs: list, rp: Any, jira_connection: Any, et: ErrataTool?, rog: RoGTool?, jira_comment_limit: int, progress_mode: bool = False) void
+_finalize_rp_launch(ctx: CLIContext, rp: Any, launch_uuid: str, launch_url: str, launch_description: str) void
+_transition_jira_issue_based_on_results(ctx: CLIContext, jira_connection: Any, jira_id: str, execute_job: Any, all_tests_passed: bool, all_tests_finished: bool) void
+_add_jira_comment_for_report(ctx: CLIContext, jira_connection: Any, jira_id: str, execute_job: Any, comment: str) void
+_add_erratum_comment_for_report(ctx: CLIContext, et: ErrataTool, jira_connection: Any, jira_id: str, execute_job: Any, launch_url: str?) void
+_add_rog_comment_for_report(ctx: CLIContext, rog: RoGTool, jira_connection: Any, jira_id: str, execute_job: Any, launch_url: str?) void
}
class ExecuteJob {
+request: Request
+execution: Execution
}
class Request {
+id: str
+tmt: dict
+reportportal: dict?
}
class Execution {
+state: str
+result: Enum
+request_uuid: str
+artifacts_url: str?
+request_api: str?
}
class ErrataTool {
}
class RoGTool {
}
ReportCommand --> CLIContext
ReportCommand --> ReportHelpers
ReportHelpers --> CLIContext
ReportHelpers --> ExecuteJob
ExecuteJob --> Request
ExecuteJob --> Execution
ReportHelpers --> ErrataTool
ReportHelpers --> RoGTool
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The branching in
_build_jira_commentforprogress_modevs normal mode duplicates a lot of logic (especially aroundlaunch_uuidandfirst_commenthandling); consider refactoring to a single flow with small conditional pieces for status text and presence oflaunch_urlto make it easier to maintain. - Now that
_process_jira_id_reportshas aprogress_modeflag, it might be worth adding a small guard or helper (e.g.,_should_finalize(progress_mode, launch_uuid, rp)) so future changes don’t accidentally reintroduce finalization, transitions, or external comments when--progressis set.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The branching in `_build_jira_comment` for `progress_mode` vs normal mode duplicates a lot of logic (especially around `launch_uuid` and `first_comment` handling); consider refactoring to a single flow with small conditional pieces for status text and presence of `launch_url` to make it easier to maintain.
- Now that `_process_jira_id_reports` has a `progress_mode` flag, it might be worth adding a small guard or helper (e.g., `_should_finalize(progress_mode, launch_uuid, rp)`) so future changes don’t accidentally reintroduce finalization, transitions, or external comments when `--progress` is set.
## Individual Comments
### Comment 1
<location path="newa/cli/report_helpers.py" line_range="352" />
<code_context>
max_length=jira_comment_limit - len(footer))
launch_description = execute_jobs_summary(ctx, jira_id, execute_jobs, target='ReportPortal')[0]
- # Finalize RP launch if needed
</code_context>
<issue_to_address>
**suggestion (performance):** Avoid building `launch_description` when running in progress mode if it is not used.
Since `_finalize_rp_launch` is skipped when `progress_mode=True`, `launch_description` is never used in that path and becomes unnecessary work. Consider only calling `execute_jobs_summary` (or computing `launch_description`) when `progress_mode` is false, or moving this computation lazily into `_finalize_rp_launch` to avoid extra processing for large job sets.
```suggestion
launch_uuid, launch_url = _get_rp_launch_details(execute_jobs)
max_length=jira_comment_limit - len(footer))
# Only compute the (potentially expensive) launch_description when it will be used
launch_description = None
if not progress_mode:
launch_description = execute_jobs_summary(
ctx,
jira_id,
execute_jobs,
target="ReportPortal",
)[0]
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
d65912e to
6b189e3
Compare
This introduces a new --progress flag to the 'newa report' command that allows reporting current test execution status without finalizing results. This is useful for providing intermediate updates during long-running test executions. When --progress is used: - Updates TF request statuses to get current execution state - Adds Jira comments with "test execution is in progress" message - Uses Testing Farm API URLs for requests not yet scheduled/finished - Skips ReportPortal launch finalization and description updates - Skips Jira issue state transitions - Skips Errata Tool and RoG comments Changes: - Add --progress flag to report command (report_cmd.py) - Modify execute_jobs_summary to use API URLs when artifacts_url is unavailable - Update _build_jira_comment to support progress mode messaging - Update _process_jira_id_reports to conditionally skip finalization steps - Add documentation for --progress option to README.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
6b189e3 to
39183d0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces a new --progress flag to the 'newa report' command that allows reporting current test execution status without finalizing results. This is useful for providing intermediate updates during long-running test executions.
When --progress is used:
Changes:
🤖 Generated with Claude Code
Summary by Sourcery
Add a progress-only reporting mode to the report command that allows intermediate status updates without finalizing external systems.
New Features:
Enhancements:
Documentation: