|
1 | 1 | package io.quarkus.bot.buildreporter.githubactions;
|
2 | 2 |
|
| 3 | +import java.nio.file.Files; |
3 | 4 | import java.nio.file.Path;
|
4 | 5 | import java.util.Collections;
|
5 | 6 | import java.util.HashSet;
|
|
9 | 10 |
|
10 | 11 | class BuildReports {
|
11 | 12 |
|
12 |
| - private static final Path MAVEN_SUREFIRE_REPORTS_PATH = Path.of("target", "surefire-reports"); |
13 |
| - private static final Path MAVEN_FAILSAFE_REPORTS_PATH = Path.of("target", "failsafe-reports"); |
14 |
| - private static final Path GRADLE_REPORTS_PATH = Path.of("build", "test-results", "test"); |
15 |
| - |
16 | 13 | private final Path jobDirectory;
|
17 | 14 | private final Path buildReportPath;
|
18 | 15 | private final Path gradleBuildScanUrlPath;
|
@@ -61,6 +58,11 @@ public String toString() {
|
61 | 58 |
|
62 | 59 | static class Builder {
|
63 | 60 |
|
| 61 | + private static final String TARGET = "target"; |
| 62 | + private static final String FAILSAFE_REPORTS = "failsafe-reports"; |
| 63 | + private static final String SUREFIRE_REPORTS = "surefire-reports"; |
| 64 | + private static final Path GRADLE_REPORTS_PATH = Path.of("build", "test-results", "test"); |
| 65 | + |
64 | 66 | private final Path jobDirectory;
|
65 | 67 | private Path buildReportPath;
|
66 | 68 | private Path gradleBuildScanUrlPath;
|
@@ -102,14 +104,23 @@ private boolean addTestPath(Path path) {
|
102 | 104 | return true;
|
103 | 105 | }
|
104 | 106 |
|
105 |
| - if (path.endsWith(MAVEN_SUREFIRE_REPORTS_PATH)) { |
106 |
| - testResultsPaths.add(new SurefireTestResultsPath(path)); |
107 |
| - return true; |
| 107 | + if (!Files.isDirectory(path) || path.getNameCount() < 2) { |
| 108 | + return false; |
108 | 109 | }
|
109 |
| - if (path.endsWith(MAVEN_FAILSAFE_REPORTS_PATH)) { |
110 |
| - testResultsPaths.add(new FailsafeTestResultsPath(path)); |
111 |
| - return true; |
| 110 | + |
| 111 | + if (path.getFileName().toString().startsWith(SUREFIRE_REPORTS)) { |
| 112 | + if (path.getName(path.getNameCount() - 2).toString().equals(TARGET)) { |
| 113 | + testResultsPaths.add(new SurefireTestResultsPath(path)); |
| 114 | + return true; |
| 115 | + } |
112 | 116 | }
|
| 117 | + if (path.getFileName().toString().startsWith(FAILSAFE_REPORTS)) { |
| 118 | + if (path.getName(path.getNameCount() - 2).toString().equals(TARGET)) { |
| 119 | + testResultsPaths.add(new FailsafeTestResultsPath(path)); |
| 120 | + return true; |
| 121 | + } |
| 122 | + } |
| 123 | + |
113 | 124 | if (path.endsWith(GRADLE_REPORTS_PATH)) {
|
114 | 125 | testResultsPaths.add(new GradleTestResultsPath(path));
|
115 | 126 | return true;
|
|
0 commit comments