-
Notifications
You must be signed in to change notification settings - Fork 193
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
GitHub warning annotations #432
Open
timkrins
wants to merge
6
commits into
Bachmann1234:main
Choose a base branch
from
timkrins:github-warning-annotations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+85
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2fc54e9
Add --github-warning-annotations argument and template
timkrins 2522160
Add test for GitHubWarningAnnotationsReportGenerator
timkrins 7eac78e
Print GitHub annotations to stdout
timkrins f12ee55
Support multiline Github annotations and add test for single line
timkrins bc245b0
Switch argument to use `store_false`
timkrins 46661af
Switch store_false to store_true as I misunderstood the default
timkrins 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
10 changes: 10 additions & 0 deletions
10
diff_cover/templates/github_coverage_warning_annotations.txt
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% if src_stats %} | ||
{% for src_path, stats in src_stats|dictsort %} | ||
{% if stats.percent_covered < 100 %} | ||
{% for line in stats.violation_lines %} | ||
{% set splitLines = line.split("-") %} | ||
::warning file={{ src_path }},line={{ splitLines[0] }}{% if splitLines[1] %},endLine={{ splitLines[1] }}{% endif %},title=Missing Coverage::Line {{ line }} missing coverage | ||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} |
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
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.
given the idea of moving to a plugin type framework, maybe this should be implemented as a top level
--format
flag, similar to some other programs, so that it's possible to do--format github-native
or--format xyz
?There would have to be discussion then about whether multiple formats are allowed (and if so, how)... for example, would it allow
--format json,markdown,github-native
or multiple instances of the same flag, something like--format github-native --format markdown:foo.md
(the latter case allowing specifying the format and filename together)? If it's too invasive to take over the markdown / json / etc. reports, could at least have a single flag to control all stdout / stderr reporting.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.
Yep, I like this
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.
I will say if we move to this style then we should have it support the existing formats as well as the new one.
We kinda have to keep the existing flags to avoid breaking compatibility, but if we are going to be adding more then moving to something like this makes sense
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.
I actually started down the path of attempting to pass something like
--github-annotations=warning
or--github-annotations=error
.But I saw that customizing the context that is passed to jinja template for specific template generators wasn't so easy to adapt.
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.
@timkrins if you wanted to have that context could that be achieved by adding some kind of
context
parameter to the init of BaseReportGenerator?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.
Maybe - I'll try have a go later in the week