Skip to content

Commit

Permalink
- split logic between include passed and annotate notice, so we can s…
Browse files Browse the repository at this point in the history
…kip file resolution if we won't annotate notice (this should significantly boost performance if annotate notice is not enabled)
  • Loading branch information
mikepenz committed Nov 28, 2024
1 parent 66cd029 commit a8076ea
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 24 deletions.
2 changes: 2 additions & 0 deletions __tests__/table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('buildSummaryTables', () => {
'*',
true,
true,
true,
[],
'{{SUITE_NAME}}/{{TEST_NAME}}',
'/'
Expand Down Expand Up @@ -108,6 +109,7 @@ describe('buildSummaryTables', () => {
'*',
true,
true,
true,
[],
'{{SUITE_NAME}}/{{TEST_NAME}}',
'/'
Expand Down
11 changes: 11 additions & 0 deletions __tests__/testParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ describe('parseFile', () => {
undefined,
undefined,
undefined,
undefined,
'/',
undefined,
undefined,
Expand Down Expand Up @@ -268,6 +269,7 @@ describe('parseFile', () => {
'',
false,
false,
false,
['/build/', '/__pycache__/'],
'{{BREAD_CRUMB}}{{SUITE_NAME}}/{{TEST_NAME}}',
'/',
Expand Down Expand Up @@ -434,6 +436,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
'',
false,
false,
false,
undefined,
'{{BREAD_CRUMB}}{{SUITE_NAME}}/{{TEST_NAME}}'
)
Expand Down Expand Up @@ -504,6 +507,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
'test_results/issues/testDisabled.xml',
'',
true,
true,
false,
undefined,
'{{SUITE_NAME}}/{{TEST_NAME}}'
Expand Down Expand Up @@ -813,6 +817,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
'test_results/mocha/mocha.xml',
'*',
true,
true,
false,
undefined,
'{{SUITE_NAME}}/{{TEST_NAME}}'
Expand Down Expand Up @@ -844,6 +849,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
'test_results/mocha/mocha.xml',
'*',
true,
true,
false,
['/build/', '/__pycache__/'],
'{{TEST_NAME}}'
Expand Down Expand Up @@ -875,6 +881,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
'test_results/mocha/mocha.xml',
'*',
true,
true,
false,
['/build/', '/__pycache__/'],
'{{TEST_NAME}}',
Expand Down Expand Up @@ -984,6 +991,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
'test_results/junit-web-test/expectedRetries.xml',
'',
false,
false,
true,
['/build/', '/__pycache__/']
)
Expand Down Expand Up @@ -1132,6 +1140,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
'test_results/perl/result.xml',
'',
true,
true,
undefined,
undefined,
undefined,
Expand Down Expand Up @@ -1254,6 +1263,7 @@ describe('parseTestReports', () => {
'*',
true,
true,
true,
[],
'{{SUITE_NAME}}/{{TEST_NAME}}',
'/'
Expand Down Expand Up @@ -1290,6 +1300,7 @@ describe('parseTestReports', () => {
'',
false,
false,
false,
[],
'',
'/',
Expand Down
24 changes: 12 additions & 12 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export async function run(): Promise<void> {
retrieve('reportPaths', reportPaths, i, reportsCount),
retrieve('suiteRegex', suiteRegex, i, reportsCount),
includePassed,
annotateNotice,
checkRetries,
excludeSources,
retrieve('checkTitleTemplate', checkTitleTemplate, i, reportsCount),
Expand Down
30 changes: 19 additions & 11 deletions src/testParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ export async function resolvePath(
export async function parseFile(
file: string,
suiteRegex = '', // no-op
annotatePassed = false,
includePassed = false,
annotateNotice = false,
checkRetries = false,
excludeSources: string[] = ['/build/', '/__pycache__/'],
checkTitleTemplate: string | undefined = undefined,
Expand Down Expand Up @@ -222,7 +223,8 @@ export async function parseFile(
suiteRegex, // no-op
'',
breadCrumbDelimiter,
annotatePassed,
includePassed,
annotateNotice,
checkRetries,
excludeSources,
checkTitleTemplate,
Expand All @@ -245,7 +247,8 @@ async function parseSuite(
suiteRegex: string, // no-op
breadCrumb: string,
breadCrumbDelimiter = '/',
annotatePassed = false,
includePassed = false,
annotateNotice = false,
checkRetries = false,
excludeSources: string[],
checkTitleTemplate: string | undefined = undefined,
Expand Down Expand Up @@ -282,7 +285,8 @@ async function parseSuite(
suiteLine,
breadCrumb,
testcases,
annotatePassed,
includePassed,
annotateNotice,
checkRetries,
excludeSources,
checkTitleTemplate,
Expand Down Expand Up @@ -328,7 +332,8 @@ async function parseSuite(
suiteRegex,
childBreadCrumb,
breadCrumbDelimiter,
annotatePassed,
includePassed,
annotateNotice,
checkRetries,
excludeSources,
checkTitleTemplate,
Expand Down Expand Up @@ -375,7 +380,8 @@ async function parseTestCases(
suiteLine: string | null,
breadCrumb: string,
testcases: any[],
annotatePassed = false,
includePassed = false,
annotateNotice = false,
checkRetries = false,
excludeSources: string[],
checkTitleTemplate: string | undefined = undefined,
Expand Down Expand Up @@ -429,9 +435,9 @@ async function parseTestCases(
skippedCount++
}

// If this won't be reported as a failure and processing all passed tests
// If this isn't reported as a failure and processing all passed tests
// isn't enabled, then skip the rest of the processing.
if (annotationLevel !== 'failure' && !annotatePassed) {
if (annotationLevel !== 'failure' && !includePassed) {
continue
}

Expand Down Expand Up @@ -484,7 +490,7 @@ async function parseTestCases(

const githubWorkspacePath = process.env['GITHUB_WORKSPACE']
let resolvedPath: string = transformedFileName
if (failed || (annotatePassed && success)) {
if (failed || (annotateNotice && success)) {
if (fs.existsSync(transformedFileName)) {
resolvedPath = transformedFileName
} else if (githubWorkspacePath && fs.existsSync(`${githubWorkspacePath}${transformedFileName}`)) {
Expand Down Expand Up @@ -561,7 +567,8 @@ export async function parseTestReports(
summary: string,
reportPaths: string,
suiteRegex: string, // no-op
annotatePassed = false,
includePassed = false,
annotateNotice = false,
checkRetries = false,
excludeSources: string[],
checkTitleTemplate: string | undefined = undefined,
Expand All @@ -587,7 +594,8 @@ export async function parseTestReports(
const testResult = await parseFile(
file,
suiteRegex,
annotatePassed,
includePassed,
annotateNotice,
checkRetries,
excludeSources,
checkTitleTemplate,
Expand Down

0 comments on commit a8076ea

Please sign in to comment.