Skip to content

Commit

Permalink
Link to Develocity tests dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Feb 21, 2024
1 parent e1a0813 commit 110f0c9
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public Optional<String> generateReportComment(String workflowName,
workflowRunIdMarker,
WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER,
buildReporterConfig.isDevelocityEnabled(),
buildReporterConfig.getDevelocityUrl(),
indicateSuccess,
hasOtherPendingCheckRuns,
true,
Expand All @@ -77,6 +78,7 @@ public Optional<String> generateReportComment(String workflowName,
workflowRunIdMarker,
WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER,
buildReporterConfig.isDevelocityEnabled(),
buildReporterConfig.getDevelocityUrl(),
indicateSuccess,
hasOtherPendingCheckRuns,
false,
Expand All @@ -91,6 +93,22 @@ public Optional<String> generateReportComment(String workflowName,
workflowRunIdMarker,
WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER,
buildReporterConfig.isDevelocityEnabled(),
buildReporterConfig.getDevelocityUrl(),
indicateSuccess,
hasOtherPendingCheckRuns,
false,
false,
workflowReportJobIncludeStrategy);
}
if (reportComment.length() > GITHUB_FIELD_LENGTH_HARD_LIMIT) {
reportComment = workflowReportFormatter.getReportComment(workflowReport,
artifactsAvailable,
checkRunOptional.orElse(null),
statusCommentMarker,
workflowRunIdMarker,
WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER,
false,
null,
indicateSuccess,
hasOtherPendingCheckRuns,
false,
Expand All @@ -112,12 +130,19 @@ public Optional<GHCheckRun> createCheckRun(GHWorkflowRun workflowRun,
String name = WorkflowConstants.BUILD_SUMMARY_CHECK_RUN_PREFIX + workflowRun.getHeadSha();
String summary = workflowReportFormatter.getCheckRunReportSummary(workflowReport, workflowContext,
artifactsAvailable, workflowReportJobIncludeStrategy);
String checkRunReport = workflowReportFormatter.getCheckRunReport(workflowReport, true, true);
String checkRunReport = workflowReportFormatter.getCheckRunReport(workflowReport,
buildReporterConfig.isDevelocityEnabled(), buildReporterConfig.getDevelocityUrl(), true, true);
if (checkRunReport.length() > GITHUB_FIELD_LENGTH_HARD_LIMIT) {
checkRunReport = workflowReportFormatter.getCheckRunReport(workflowReport,
buildReporterConfig.isDevelocityEnabled(), buildReporterConfig.getDevelocityUrl(), false, true);
}
if (checkRunReport.length() > GITHUB_FIELD_LENGTH_HARD_LIMIT) {
checkRunReport = workflowReportFormatter.getCheckRunReport(workflowReport, false, true);
checkRunReport = workflowReportFormatter.getCheckRunReport(workflowReport,
buildReporterConfig.isDevelocityEnabled(), buildReporterConfig.getDevelocityUrl(), false, false);
}
if (checkRunReport.length() > GITHUB_FIELD_LENGTH_HARD_LIMIT) {
checkRunReport = workflowReportFormatter.getCheckRunReport(workflowReport, false, false);
checkRunReport = workflowReportFormatter.getCheckRunReport(workflowReport,
false, null, false, false);
}

Output checkRunOutput = new Output(name, summary).withText(checkRunReport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ public class BuildReporterConfig {
private final Set<String> monitoredWorkflows;
private final boolean createCheckRun;
private final boolean develocityEnabled;
private final String develocityUrl;

private BuildReporterConfig(boolean dryRun, Comparator<GHWorkflowJob> workflowJobComparator,
Set<String> monitoredWorkflows, boolean createCheckRun, boolean develocityEnabled) {
Set<String> monitoredWorkflows, boolean createCheckRun, boolean develocityEnabled,
String develocityUrl) {
this.dryRun = dryRun;
this.workflowJobComparator = workflowJobComparator;
this.monitoredWorkflows = monitoredWorkflows;
this.createCheckRun = createCheckRun;
this.develocityEnabled = develocityEnabled;
this.develocityUrl = develocityUrl;
}

public boolean isDryRun() {
Expand All @@ -43,6 +46,10 @@ public boolean isDevelocityEnabled() {
return develocityEnabled;
}

public String getDevelocityUrl() {
return develocityUrl;
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -54,6 +61,7 @@ public static class Builder {
private Comparator<GHWorkflowJob> workflowJobComparator = DefaultJobNameComparator.INSTANCE;
private Set<String> monitoredWorkflows = Collections.emptySet();
private boolean develocityEnabled;
private String develocityUrl;

public Builder dryRun(boolean dryRun) {
this.dryRun = dryRun;
Expand All @@ -80,9 +88,14 @@ public Builder enableDevelocity(boolean develocityEnabled) {
return this;
}

public Builder develocityUrl(String develocityUrl) {
this.develocityUrl = develocityUrl;
return this;
}

public BuildReporterConfig build() {
return new BuildReporterConfig(dryRun, workflowJobComparator, monitoredWorkflows, createCheckRun,
develocityEnabled);
develocityEnabled, develocityUrl);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ public String getCheckRunReportSummary(WorkflowReport report, WorkflowContext wo
.render();
}

public String getCheckRunReport(WorkflowReport report, boolean includeStackTraces, boolean includeFailureLinks) {
return Templates.checkRunReport(report, includeStackTraces, includeFailureLinks).render();
public String getCheckRunReport(WorkflowReport report, boolean develocityEnabled, String develocityUrl,
boolean includeStackTraces, boolean includeFailureLinks) {
return Templates.checkRunReport(report, develocityEnabled, develocityUrl, includeStackTraces, includeFailureLinks)
.render();
}

public String getReportComment(WorkflowReport report, boolean artifactsAvailable, GHCheckRun checkRun,
String messageIdActive, String workflowRunId, String buildScansCheckRunMarker,
boolean develocityEnabled, boolean indicateSuccess, boolean hasOtherPendingCheckRuns,
boolean develocityEnabled, String develocityUrl, boolean indicateSuccess, boolean hasOtherPendingCheckRuns,
boolean includeStackTraces, boolean includeFailureLinks,
WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy) {
return Templates
.commentReport(report, artifactsAvailable, checkRun, messageIdActive, workflowRunId, buildScansCheckRunMarker,
develocityEnabled, indicateSuccess, hasOtherPendingCheckRuns,
develocityEnabled, develocityUrl, indicateSuccess, hasOtherPendingCheckRuns,
includeStackTraces, includeFailureLinks, workflowReportJobIncludeStrategy)
.render();
}
Expand All @@ -40,12 +42,13 @@ private static class Templates {
public static native TemplateInstance checkRunReportSummary(WorkflowReport report, WorkflowContext workflowContext,
boolean artifactsAvailable, WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy);

public static native TemplateInstance checkRunReport(WorkflowReport report, boolean includeStackTraces,
boolean includeFailureLinks);
public static native TemplateInstance checkRunReport(WorkflowReport report,
boolean develocityEnabled, String develocityUrl,
boolean includeStackTraces, boolean includeFailureLinks);

public static native TemplateInstance commentReport(WorkflowReport report, boolean artifactsAvailable,
GHCheckRun checkRun, String messageIdActive, String workflowRunId, String buildScansCheckRunMarker,
boolean develocityEnabled, boolean indicateSuccess, boolean hasOtherPendingCheckRuns,
boolean develocityEnabled, String develocityUrl, boolean indicateSuccess, boolean hasOtherPendingCheckRuns,
boolean includeStackTraces, boolean includeFailureLinks,
WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ public class WorkflowReportFlakyTestCase implements Comparable<WorkflowReportFla
private final String classPath;
private final String fullName;
private final String fullClassName;
private final String name;
private final List<Flake> flakes;

public WorkflowReportFlakyTestCase(String classPath, ReportTestCase reportTestCase, List<Flake> flakes) {
this.classPath = classPath;
this.fullName = reportTestCase.getFullName();
this.fullClassName = reportTestCase.getFullClassName();
this.name = reportTestCase.getName();
this.flakes = Collections.unmodifiableList(flakes);
}

Expand All @@ -34,6 +36,10 @@ public String getFullClassName() {
return fullClassName;
}

public String getName() {
return name;
}

public List<Flake> getFlakes() {
return flakes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class WorkflowReportTestCase implements Comparable<WorkflowReportTestCase
private final String classPath;
private final String fullName;
private final String fullClassName;
private final String name;
private final String failureType;
private final String failureErrorLine;
private final String abbreviatedFailureDetail;
Expand All @@ -23,6 +24,7 @@ public WorkflowReportTestCase(String classPath, ReportTestCase reportTestCase, S
this.classPath = classPath;
this.fullName = reportTestCase.getFullName();
this.fullClassName = reportTestCase.getFullClassName();
this.name = reportTestCase.getName();
this.failureType = reportTestCase.getFailureType();
this.failureErrorLine = reportTestCase.getFailureErrorLine();
this.abbreviatedFailureDetail = abbreviatedFailureDetail;
Expand All @@ -43,6 +45,10 @@ public String getFullClassName() {
return fullClassName;
}

public String getName() {
return name;
}

public String getFailureType() {
return failureType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
```

{#for failure : module.testFailures}
<p>✖ <code>{failure.fullName}</code>{#if failure.failureErrorLine} line <code>{failure.failureErrorLine}</code>{/if}{#if includeFailureLinks} <a id="test-failure-{failure.fullClassName.toLowerCase}-{failure_count}"></a> - <a href="{failure.shortenedFailureUrl}">Source on GitHub</a> - <a href="#user-content-build-summary-top">🠅</a>{/if}</p>
<p>✖ <code>{failure.fullName}</code>{#if failure.failureErrorLine} line <code>{failure.failureErrorLine}</code>{/if}{#if develocityEnabled && develocityUrl} - <a href="{develocityUrl}scans/tests?tests.container={failure.fullClassName}&tests.test={failure.name}">History</a>{/if}{#if includeFailureLinks} <a id="test-failure-{failure.fullClassName.toLowerCase}-{failure_count}"></a> - <a href="{failure.shortenedFailureUrl}">Source on GitHub</a> - <a href="#user-content-build-summary-top">🠅</a>{/if}</p>

{#if (failure.abbreviatedFailureDetail && includeStackTraces) || (report.sameRepository && failure.failureErrorLine)}
<details>
Expand Down Expand Up @@ -60,7 +60,7 @@
{/for}

{#if report.flakyTests}
## Flaky tests
## Flaky tests{#if develocityEnabled && develocityUrl} - <a href="{develocityUrl}scans/tests">Develocity</a>{/if}

{#for job in report.jobsWithFlakyTests}
### :gear: {job.name}
Expand All @@ -69,7 +69,7 @@
#### :package: {module.name ? module.name : "Root project"}

{#for flakyTest : module.flakyTests}
<p>✖ <code>{flakyTest.fullName}</code></p>
<p>✖ <code>{flakyTest.fullName}</code>{#if develocityEnabled && develocityUrl} - <a href="{develocityUrl}scans/tests?tests.container={flakyTest.fullClassName}&tests.test={flakyTest.name}">History</a>{/if}</p>

{#for flake : flakyTest.flakes}
- `{flake.message}`{#if flake.type} - <code>{flake.type}</code>{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Full information is available in the [Build summary check run]({checkRun.htmlUrl

{#if module.testFailures}
{#for failure : module.testFailures}
<p>✖ <code>{failure.fullName}</code>{#if failure.failureErrorLine} line <code>{failure.failureErrorLine}</code>{/if}{#if includeFailureLinks} - {#if checkRun && failure.failureDetail}<a href="{checkRun.htmlUrl}#user-content-test-failure-{failure.fullClassName.toLowerCase}-{failure_count}">More details</a> - {/if}<a href="{failure.shortenedFailureUrl}">Source on GitHub</a>{/if}</p>
<p>✖ <code>{failure.fullName}</code>{#if failure.failureErrorLine} line <code>{failure.failureErrorLine}</code>{/if}{#if develocityEnabled && develocityUrl} - <a href="{develocityUrl}scans/tests?tests.container={failure.fullClassName}&tests.test={failure.name}">History</a>{/if}{#if includeFailureLinks} - {#if checkRun && failure.failureDetail}<a href="{checkRun.htmlUrl}#user-content-test-failure-{failure.fullClassName.toLowerCase}-{failure_count}">More details</a> - {/if}<a href="{failure.shortenedFailureUrl}">Source on GitHub</a>{/if}</p>

{#if failure.abbreviatedFailureDetail && includeStackTraces}
<details>
Expand Down Expand Up @@ -98,7 +98,7 @@ It should be safe to merge provided you have a look at the other checks in the s

---

## Flaky tests
## Flaky tests{#if develocityEnabled && develocityUrl} - <a href="{develocityUrl}scans/tests">Develocity</a>{/if}

{#for job in report.jobsWithFlakyTests}
### :gear: {job.name}
Expand All @@ -107,7 +107,7 @@ It should be safe to merge provided you have a look at the other checks in the s
#### :package: {module.name ? module.name : "Root project"}

{#for flakyTest : module.flakyTests}
<p>✖ <code>{flakyTest.fullName}</code></p>
<p>✖ <code>{flakyTest.fullName}</code>{#if develocityEnabled && develocityUrl} - <a href="{develocityUrl}scans/tests?tests.container={flakyTest.fullClassName}&tests.test={flakyTest.name}">History</a>{/if}</p>

{#for flake : flakyTest.flakes}
- `{flake.message}`{#if flake.type} - <code>{flake.type}</code>{/if}
Expand Down

0 comments on commit 110f0c9

Please sign in to comment.