-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(anta): Add Markdown report option to ANTA #740
Merged
Merged
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c5c517a
feat(anta): Add markdown report option to ANTA CLI
carl-baillargeon ef3a942
Update MDReportFactory
carl-baillargeon 7920718
Make Py3.11 happy with f-string
carl-baillargeon 0c1e957
Remove unnecessary only_failed_tests from MDReportBase
carl-baillargeon cb35a83
Added TestStats
carl-baillargeon 733c159
Fix typos
carl-baillargeon aa2168f
Fix pytest
carl-baillargeon e72b22a
Added unit tests for reporter and result_manager
carl-baillargeon 874467b
Added unit tests for md_reporter
carl-baillargeon 650b8e2
Fix unit tests for md_reporter
carl-baillargeon 230bd0a
Remove license from test md reports
carl-baillargeon 8410064
Fix line too long
carl-baillargeon 1747500
Added more unit tests
carl-baillargeon f34b1fe
Added documentation
carl-baillargeon 596d029
Remove test.md
carl-baillargeon 30c8d7e
Address review comments
carl-baillargeon 73208a5
Update unit tests for ResultManager
carl-baillargeon 8d14307
More unit tests
carl-baillargeon 57f2021
Merge branch 'main' into feat/md_report
gmuloc fb2139a
Reduce number of tests in fake reports
carl-baillargeon d217ac3
Fix per review comments
carl-baillargeon 5c44994
Rebase with latest main
carl-baillargeon 16ae28c
Remove unrelated changes
carl-baillargeon dc23513
Merge branch 'main' into feat/md_report
carl-baillargeon 8918cd0
Fix per review comments
carl-baillargeon 7abf73a
Merge branch 'main' into feat/md_report
carl-baillargeon 83d8602
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 21cb559
Merge branch 'main' into feat/md_report
gmuloc 8372826
Added unit test for --hide
carl-baillargeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,14 @@ | |
from typing import TYPE_CHECKING, Literal | ||
|
||
import rich | ||
from rich.emoji import Emoji | ||
from rich.panel import Panel | ||
from rich.progress import BarColumn, MofNCompleteColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn, TimeRemainingColumn | ||
|
||
from anta.cli.console import console | ||
from anta.models import AntaTest | ||
from anta.reporter import ReportJinja, ReportTable | ||
from anta.reporter.md_reporter import MDReportGenerator | ||
from anta.runner import main | ||
|
||
if TYPE_CHECKING: | ||
|
@@ -122,6 +124,21 @@ def print_jinja(results: ResultManager, template: pathlib.Path, output: pathlib. | |
file.write(report) | ||
|
||
|
||
def save_markdown_report(ctx: click.Context, md_output: pathlib.Path, *, only_failed_tests: bool = False) -> None: | ||
"""Save the markdown report to a file. | ||
|
||
Parameters | ||
---------- | ||
ctx: Click context containing the result manager. | ||
md_output: Path to save the markdown report. | ||
only_failed_tests: If True, only failed tests will be included in the report. Default is False. | ||
""" | ||
console.print() | ||
MDReportGenerator.generate(results=_get_result_manager(ctx), md_filename=md_output, only_failed_tests=only_failed_tests) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could fail and raise an OSError, in that case we would need to catch it cleanly and not print "Markdown report saved" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 5c44994 |
||
checkmark = Emoji("white_check_mark") | ||
console.print(f"Markdown report saved to {md_output} {checkmark}", style="cyan") | ||
|
||
|
||
# Adding our own ANTA spinner - overriding rich SPINNERS for our own | ||
# so ignore warning for redefinition | ||
rich.spinner.SPINNERS = { # type: ignore[attr-defined] | ||
|
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this new option or could we not use the nrfu option
instead and pass it down the line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Removed in 8918cd0