Skip to content

Commit 687f107

Browse files
authored
GH-184: ignore incompatible XML reports (#198)
Fixes #184 Ignore files that don't have testsuites Reorganize the folders
1 parent a27556b commit 687f107

File tree

31 files changed

+109
-73
lines changed

31 files changed

+109
-73
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,33 @@ jobs:
2222
java-version: 8
2323
distribution: 'temurin'
2424
cache: 'maven'
25-
- run: cd tests && mvn clean test --batch-mode -Dmaven.test.failure.ignore=true
25+
- run: cd integration-tests/maven && mvn clean verify --batch-mode -Dmaven.test.failure.ignore=true
2626
- uses: ./
2727
if: github.ref != 'refs/heads/master'
2828
with:
2929
check_name: Example Surefire Test Report
30+
report_paths: '**/surefire-reports/*.xml, **/failsafe-reports/*.xml'
3031
- uses: cclauss/[email protected]
3132
with:
32-
args: pytest --junit-xml=python/report.xml python/ || exit 0
33+
args: pytest integration-tests/python/ --junit-xml=integration-tests/python/report.xml || exit 0
3334
- uses: ./
3435
if: github.ref != 'refs/heads/master'
3536
with:
3637
check_name: Example Pytest Report
37-
report_paths: python/report.xml
38+
report_paths: integration-tests/python/report.xml
3839
- uses: actions/setup-go@v5
3940
with:
40-
go-version: 1.18.x
41+
go-version: 1.21.x
4142
- run: |
42-
cd go &&
43+
cd integration-tests/go &&
4344
go install github.com/jstemmer/go-junit-report/v2@latest &&
4445
go test -v 2>&1 ./... |
4546
go-junit-report -out report.xml
4647
- uses: ./
4748
if: github.ref != 'refs/heads/master'
4849
with:
4950
check_name: Example Go Report
50-
report_paths: go/report.xml
51+
report_paths: integration-tests/go/report.xml
5152
file_name_in_stack_trace: true
5253
- uses: actions/setup-node@v4
5354
with:

action.test.fixtures.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const finishedWithFailures = {
99
annotations: [
1010
{
1111
path:
12-
'tests/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
12+
'integration-tests/maven/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
1313
start_line: 39,
1414
end_line: 39,
1515
start_column: 0,
@@ -22,7 +22,7 @@ const finishedWithFailures = {
2222
},
2323
{
2424
path:
25-
'tests/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
25+
'integration-tests/maven/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
2626
start_line: 49,
2727
end_line: 49,
2828
start_column: 0,
@@ -35,7 +35,7 @@ const finishedWithFailures = {
3535
},
3636
{
3737
path:
38-
'tests/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
38+
'integration-tests/maven/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
3939
start_line: 57,
4040
end_line: 57,
4141
start_column: 0,
@@ -48,7 +48,7 @@ const finishedWithFailures = {
4848
},
4949
{
5050
path:
51-
'tests/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
51+
'integration-tests/maven/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
5252
start_line: 18,
5353
end_line: 18,
5454
start_column: 0,
@@ -61,7 +61,7 @@ const finishedWithFailures = {
6161
},
6262
{
6363
path:
64-
'tests/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
64+
'integration-tests/maven/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
6565
start_line: 32,
6666
end_line: 32,
6767
start_column: 0,
@@ -74,7 +74,7 @@ const finishedWithFailures = {
7474
},
7575
{
7676
path:
77-
'tests/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
77+
'integration-tests/maven/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
7878
start_line: 25,
7979
end_line: 25,
8080
start_column: 0,
@@ -88,7 +88,7 @@ const finishedWithFailures = {
8888
},
8989
{
9090
path:
91-
'tests/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
91+
'integration-tests/maven/email/src/test/java/action/surefire/report/email/EmailAddressTest.java',
9292
start_line: 66,
9393
end_line: 66,
9494
start_column: 0,
@@ -101,7 +101,7 @@ const finishedWithFailures = {
101101
},
102102
{
103103
path:
104-
'tests/evil_twins/src/test/java/action/surefire/report/twin/second/TwinTest.java',
104+
'integration-tests/maven/evil_twins/src/test/java/action/surefire/report/twin/second/TwinTest.java',
105105
start_line: 13,
106106
end_line: 13,
107107
start_column: 0,
@@ -113,7 +113,7 @@ const finishedWithFailures = {
113113
"java.lang.AssertionError: \n\nExpected: \"Good Twin\"\n but: was \"Evil Twin\"\n\tat action.surefire.report.twin.second.TwinTest.should_always_fail(TwinTest.java:13)"
114114
},
115115
{
116-
path: 'tests/utils/src/test/java/action/surefire/report/calc/CalcUtilsTest.kt',
116+
path: 'integration-tests/maven/utils/src/test/java/action/surefire/report/calc/CalcUtilsTest.kt',
117117
start_line: 27,
118118
end_line: 27,
119119
start_column: 0,
@@ -126,7 +126,7 @@ const finishedWithFailures = {
126126
'java.lang.AssertionError: unexpected exception type thrown; expected:<java.lang.IllegalStateException> but was:<java.lang.IllegalArgumentException>\n\tat action.surefire.report.calc.CalcUtilsTest.test error handling(CalcUtilsTest.kt:27)\nCaused by: java.lang.IllegalArgumentException: Amount must have max 2 non-zero decimal places\n\tat action.surefire.report.calc.CalcUtilsTest.scale(CalcUtilsTest.kt:31)\n\tat action.surefire.report.calc.CalcUtilsTest.access$scale(CalcUtilsTest.kt:9)\n\tat action.surefire.report.calc.CalcUtilsTest.test error handling(CalcUtilsTest.kt:27)'
127127
},
128128
{
129-
path: 'tests/utils/src/test/java/action/surefire/report/calc/CalcUtilsTest.kt',
129+
path: 'integration-tests/maven/utils/src/test/java/action/surefire/report/calc/CalcUtilsTest.kt',
130130
start_line: 15,
131131
end_line: 15,
132132
start_column: 0,
@@ -138,7 +138,7 @@ const finishedWithFailures = {
138138
'java.lang.AssertionError: \n\nExpected: <100.10>\n but: was <100.11>\n\tat action.surefire.report.calc.CalcUtilsTest.test scale(CalcUtilsTest.kt:15)'
139139
},
140140
{
141-
path: 'tests/utils/src/test/java/action/surefire/report/calc/StringUtilsTest.java',
141+
path: 'integration-tests/maven/utils/src/test/java/action/surefire/report/calc/StringUtilsTest.java',
142142
start_line: 27,
143143
end_line: 27,
144144
start_column: 0,
@@ -151,7 +151,7 @@ const finishedWithFailures = {
151151
'java.lang.AssertionError: \n\nExpected: (an instance of java.lang.IllegalArgumentException and exception with message a string containing "This is unexpected")\n but: exception with message a string containing "This is unexpected" message was "Input=\'\' didn\'t match condition."\nStacktrace was: java.lang.IllegalArgumentException: Input=\'\' didn\'t match condition.\n\tat action.surefire.report.calc.StringUtils.requireNotBlank(StringUtils.java:25)\n\tat action.surefire.report.calc.StringUtils.requireNotBlank(StringUtils.java:18)\n\tat action.surefire.report.calc.StringUtilsTest.require_fail(StringUtilsTest.java:27)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\n\tat org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:258)\n\tat org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)\n\tat org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)\n\tat org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)\n\tat org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)\n\tat org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:413)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)\n\tat org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)\n\tat org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)\n\tat org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)\n\tat org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)'
152152
},
153153
{
154-
path: 'tests/utils/src/test/java/action/surefire/report/calc/StringUtilsTest.java',
154+
path: 'integration-tests/maven/utils/src/test/java/action/surefire/report/calc/StringUtilsTest.java',
155155
start_line: 20,
156156
end_line: 20,
157157
start_column: 0,

dist/index.js

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ class OidcClient {
679679
.catch(error => {
680680
throw new Error(`Failed to get ID Token. \n
681681
Error Code : ${error.statusCode}\n
682-
Error Message: ${error.result.message}`);
682+
Error Message: ${error.message}`);
683683
});
684684
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
685685
if (!id_token) {
@@ -19994,24 +19994,24 @@ const resolveFileAndLine = (file, classname, output, isFilenameInOutput) => {
1999419994
let filenameWithPackage;
1999519995
if (isFilenameInOutput) {
1999619996
filename = output.split(':')[0].trim();
19997-
filenameWithPackage = filename
19997+
filenameWithPackage = filename;
1999819998
} else {
1999919999
filename = file ? file : classname.split('.').slice(-1)[0].split('(')[0];
20000-
filenameWithPackage = classname.replace(/\./g, "/");
20000+
filenameWithPackage = classname.replace(/\./g, '/');
2000120001
}
2000220002
const matches = output.match(new RegExp(`${filename}.*?:\\d+`, 'g'));
20003-
if (!matches) return { filename: filename, filenameWithPackage: filenameWithPackage, line: 1 };
20003+
if (!matches) return {filename: filename, filenameWithPackage: filenameWithPackage, line: 1};
2000420004

2000520005
const [lastItem] = matches.slice(-1);
2000620006
const [, line] = lastItem.split(':');
2000720007
core.debug(`Resolved file ${filenameWithPackage} with name ${filename} and line ${line}`);
2000820008

20009-
return { filename, filenameWithPackage, line: parseInt(line) };
20009+
return {filename, filenameWithPackage, line: parseInt(line)};
2001020010
};
2001120011

2001220012
const resolvePath = async filenameWithPackage => {
2001320013
core.debug(`Resolving path for ${filenameWithPackage}`);
20014-
const globber = await glob.create([`**/${filenameWithPackage}.*`, `**/${filenameWithPackage}`].join('\n'), { followSymbolicLinks: false });
20014+
const globber = await glob.create([`**/${filenameWithPackage}.*`, `**/${filenameWithPackage}`].join('\n'), {followSymbolicLinks: false});
2001520015
const results = await globber.glob();
2001620016
core.debug(`Matched files: ${results}`);
2001720017
const searchPath = globber.getSearchPaths()[0];
@@ -20034,6 +20034,19 @@ const resolvePath = async filenameWithPackage => {
2003420034
return canonicalPath;
2003520035
};
2003620036

20037+
function getTestsuites(report) {
20038+
if (report.testsuite) {
20039+
return [report.testsuite];
20040+
}
20041+
if (!report.testsuites || !report.testsuites.testsuite) {
20042+
return [];
20043+
}
20044+
if (Array.isArray(report.testsuites.testsuite)) {
20045+
return report.testsuites.testsuite;
20046+
}
20047+
return [report.testsuites.testsuite];
20048+
}
20049+
2003720050
async function parseFile(file, isFilenameInStackTrace) {
2003820051
core.debug(`Parsing file ${file}`);
2003920052
let count = 0;
@@ -20042,12 +20055,11 @@ async function parseFile(file, isFilenameInStackTrace) {
2004220055

2004320056
const data = await fs.promises.readFile(file);
2004420057

20045-
const report = JSON.parse(parser.xml2json(data, { compact: true }));
20046-
const testsuites = report.testsuite
20047-
? [report.testsuite]
20048-
: Array.isArray(report.testsuites.testsuite)
20049-
? report.testsuites.testsuite
20050-
: [report.testsuites.testsuite];
20058+
const report = JSON.parse(parser.xml2json(data, {compact: true}));
20059+
core.debug(`parsed report: ${JSON.stringify(report)}`);
20060+
20061+
const testsuites = getTestsuites(report);
20062+
core.debug(`test suites: ${JSON.stringify(testsuites)}`);
2005120063

2005220064
for (const testsuite of testsuites) {
2005320065
const testcases = Array.isArray(testsuite.testcase)
@@ -20084,7 +20096,7 @@ async function parseFile(file, isFilenameInStackTrace) {
2008420096
testcase._attributes.name
2008520097
).trim();
2008620098

20087-
const { filename, filenameWithPackage, line } = resolveFileAndLine(
20099+
const {filename, filenameWithPackage, line} = resolveFileAndLine(
2008820100
testcase._attributes.file,
2008920101
testcase._attributes.classname,
2009020102
stackTrace,
@@ -20109,22 +20121,22 @@ async function parseFile(file, isFilenameInStackTrace) {
2010920121
}
2011020122
}
2011120123
}
20112-
return { count, skipped, annotations };
20124+
return {count, skipped, annotations};
2011320125
}
2011420126

2011520127
const parseTestReports = async (reportPaths, isFilenameInStackTrace) => {
20116-
const globber = await glob.create(reportPaths, { followSymbolicLinks: false });
20128+
const globber = await glob.create(reportPaths, {followSymbolicLinks: false});
2011720129
let annotations = [];
2011820130
let count = 0;
2011920131
let skipped = 0;
2012020132
for await (const file of globber.globGenerator()) {
20121-
const { count: c, skipped: s, annotations: a } = await parseFile(file, isFilenameInStackTrace);
20133+
const {count: c, skipped: s, annotations: a} = await parseFile(file, isFilenameInStackTrace);
2012220134
if (c === 0) continue;
2012320135
count += c;
2012420136
skipped += s;
2012520137
annotations = annotations.concat(a);
2012620138
}
20127-
return { count, skipped, annotations };
20139+
return {count, skipped, annotations};
2012820140
};
2012920141

2013020142
module.exports = { resolveFileAndLine, resolvePath, parseFile, parseTestReports };
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/pom.xml renamed to integration-tests/maven/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@
7878
<testFailureIgnore>true</testFailureIgnore>
7979
</configuration>
8080
</plugin>
81+
<plugin>
82+
<groupId>org.apache.maven.plugins</groupId>
83+
<artifactId>maven-failsafe-plugin</artifactId>
84+
<version>2.22.2</version>
85+
<executions>
86+
<execution>
87+
<goals>
88+
<goal>integration-test</goal>
89+
<goal>verify</goal>
90+
</goals>
91+
</execution>
92+
</executions>
93+
</plugin>
8194
</plugins>
8295
</build>
8396

File renamed without changes.

tests/utils/src/test/java/action/surefire/report/calc/StringUtilsTest.java renamed to integration-tests/maven/utils/src/test/java/action/surefire/report/calc/StringUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ public void require_withNullMsg() {
4848
thrown.expectMessage("Input='' didn't match condition.");
4949
StringUtils.requireNotBlank("");
5050
}
51-
}
51+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)