Skip to content
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

Support withChecks #721

Merged
merged 7 commits into from
Dec 29, 2020
Merged

Support withChecks #721

merged 7 commits into from
Dec 29, 2020

Conversation

mrginglymus
Copy link
Contributor

@mrginglymus mrginglymus commented Dec 26, 2020

This PR adds support for the withChecks step recently added to the checks-api plugin, that allows for customization of published checks names by context.

@codecov
Copy link

codecov bot commented Dec 26, 2020

Codecov Report

Merging #721 (5770309) into master (11841d9) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #721      +/-   ##
============================================
+ Coverage     79.86%   79.88%   +0.01%     
- Complexity     1505     1506       +1     
============================================
  Files           241      241              
  Lines          5489     5493       +4     
  Branches        397      397              
============================================
+ Hits           4384     4388       +4     
  Misses          945      945              
  Partials        160      160              
Impacted Files Coverage Δ Complexity Δ
...plugins/analysis/core/steps/PublishIssuesStep.java 57.86% <100.00%> (+0.26%) 29.00 <0.00> (ø)
...ns/analysis/core/steps/WarningChecksPublisher.java 97.46% <100.00%> (+0.09%) 23.00 <2.00> (+1.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11841d9...5770309. Read the comment docs.

@mrginglymus
Copy link
Contributor Author

@uhafner the Auto Assign PR check failed to auto assign PRs, so dropping you a quick ping in case you missed this otherwise. I'm not sure on the GitHub CI failure - looks environmental?

Copy link
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

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

Comment on lines 860 to 861
String checksName = Optional.ofNullable(getContext().get(ChecksInfo.class)).map(ChecksInfo::getName).orElse(null);
WarningChecksPublisher checksPublisher = new WarningChecksPublisher(action, getTaskListener(), checksName);
Copy link
Member

Choose a reason for hiding this comment

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

I would rather prefer it look like:

WarningChecksPublisher checksPublisher = new WarningChecksPublisher(action, getTaskListener(), getContext().get(ChecksInfo.class));

Then we can place the logic inside of WarningChecksPublisher and reuse it for the recordIssues step. (PublishIssuesStep is a different step with the name publishIssues).


WarningChecksPublisher(final ResultAction action, final TaskListener listener) {
WarningChecksPublisher(final ResultAction action, final TaskListener listener, final String checksName) {
Copy link
Member

Choose a reason for hiding this comment

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

See above: parameter should be of type ChecksInfo.
And do not add a second constructor since we need the same call for the IssueRecorder (which is used by the recordIssues step).

@mrginglymus
Copy link
Contributor Author

Ahh, I knew there was another place. With RecordIssues, do we want to not use ChecksInfo when publishing multiple checks? Otherwise they will all get (slightly) overwritten - the annotations should be preserved, but other bits will get overwritten.

@mrginglymus
Copy link
Contributor Author

Tests for recordIssues to follow.

@mrginglymus mrginglymus requested a review from uhafner December 28, 2020 18:56
Copy link
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

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

Thanks, this PR looks already great! I only found some minor things left to do.

@@ -591,6 +594,10 @@ public void setFilters(final List<RegexpFilter> filters) {
this.filters = new ArrayList<>(filters);
}

public void setChecksInfo(final ChecksInfo checksInfo) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public void setChecksInfo(final ChecksInfo checksInfo) {
public void setChecksInfo(@CheckForNull final ChecksInfo checksInfo) {


WarningChecksPublisher(final ResultAction action, final TaskListener listener) {
WarningChecksPublisher(final ResultAction action, final TaskListener listener, final ChecksInfo checksInfo) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
WarningChecksPublisher(final ResultAction action, final TaskListener listener, final ChecksInfo checksInfo) {
WarningChecksPublisher(final ResultAction action, final TaskListener listener, @CheckForNull final ChecksInfo checksInfo) {

Comment on lines 217 to 218
WorkflowJob project = createPipeline();
copySingleFileToWorkspace(project, NEW_CHECKSTYLE_REPORT);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
WorkflowJob project = createPipeline();
copySingleFileToWorkspace(project, NEW_CHECKSTYLE_REPORT);
WorkflowJob project = createPipelineWithWorkspaceFiles(NEW_CHECKSTYLE_REPORT);

The file name needs to be renamed automatically, otherwise it is not found.


List<ChecksDetails> publishedChecks = PUBLISHER_FACTORY.getPublishedChecks();

assertThat(publishedChecks.size()).isEqualTo(2);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assertThat(publishedChecks.size()).isEqualTo(2);
assertThat(publishedChecks).hasSize(2); // add a small comment why there are two results?

@mrginglymus mrginglymus requested a review from uhafner December 29, 2020 17:03
@uhafner uhafner merged commit f641419 into jenkinsci:master Dec 29, 2020
@uhafner uhafner added the enhancement Enhancement of existing functionality label Dec 29, 2020
@uhafner
Copy link
Member

uhafner commented Dec 30, 2020

Thanks! Your CapturingChecksPublisher.Factory really is a very helpful concept, makes testing of the checks much easier! I already used it in

(part of #724).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants