Skip to content

Commit

Permalink
- introduce ability to group the test detailed summary
Browse files Browse the repository at this point in the history
- expand test for grouped summary
  • Loading branch information
mikepenz committed Nov 3, 2024
1 parent 5eb8e3e commit dda3b1e
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 107 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ jobs:
[{"searchValue":"::","replaceValue":"/"}]
annotate_only: ${{ github.event_name == 'workflow_dispatch' }}

- name: Test Nested JUnit test import
uses: ./
with:
check_name: Example Nested JUnit Test Report
report_paths: 'test_results/nested/multi-level.xml'
include_passed: true
detailed_summary: true
check_title_template: '{{SUITE_NAME}} | {{TEST_NAME}}'
annotate_only: ${{ github.event_name == 'workflow_dispatch' }}

release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
Expand Down
159 changes: 109 additions & 50 deletions __tests__/table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,54 @@ import {buildSummaryTables} from '../src/table'
*/
jest.setTimeout(30000)

const NORMAL_TABLE = [
[
{
'data': '',
'header': true
},
{
'data': 'Tests',
'header': true
},
{
'data': 'Passed ✅',
'header': true
},
{
'data': 'Skipped ⏭️',
'header': true
},
{
'data': 'Failed ❌',
'header': true
}
],
[
'checkName',
'3 ran',
'3 passed',
'0 skipped',
'0 failed'
]
]
const FLAKY_TABLE = [
[
{
'data': '',
'header': true
},
{
'data': 'Test',
'header': true
},
{
'data': 'Retries',
'header': true
}
]
]

describe('buildSummaryTables', () => {
it('should build simple tables', async () => {
const testResult = await parseTestReports(
Expand All @@ -22,83 +70,94 @@ describe('buildSummaryTables', () => {

const [table, detailTable, flakyTable] = buildSummaryTables([testResult], true, true, true)

expect(table).toStrictEqual([
expect(table).toStrictEqual(NORMAL_TABLE)
expect(detailTable).toStrictEqual([
[
{
'data': '',
'header': true
"data": "",
"header": true
},
{
'data': 'Tests',
'header': true
"data": "Test",
"header": true
},
{
'data': 'Passed ✅',
'header': true
},
{
'data': 'Skipped ⏭️',
'header': true
},
{
'data': 'Failed ❌',
'header': true
"data": "Result",
"header": true
}
],
[
'checkName',
'3 ran',
'3 passed',
'0 skipped',
'0 failed'
"checkName",
"ABC-0199: XMPP Ping/PingIntegrationTest.pingAsync (Normal)",
"✅ pass"
],
[
"checkName",
"ABC-0199: XMPP Ping/PingIntegrationTest.pingServer (Normal)",
"✅ pass"
],
[
"checkName",
"ABC-0045: Multi-User Chat/MultiUserIntegrationTest.mucRoleTestForReceivingModerator (Normal)",
"✅ pass"
]
])
expect(flakyTable).toStrictEqual(FLAKY_TABLE)
})

it('should group detail tables', async () => {
const testResult = await parseTestReports(
'checkName',
'summary',
'test_results/nested/multi-level.xml',
'*',
true,
true,
[],
'{{SUITE_NAME}}/{{TEST_NAME}}',
'/'
)

const [table, detailTable, flakyTable] = buildSummaryTables([testResult], true, true, true, true)

expect(table).toStrictEqual(NORMAL_TABLE)
expect(detailTable).toStrictEqual([
[
{
'data': '',
'header': true
"data": "",
"header": true
},
{
'data': 'Test',
'header': true
"data": "Test",
"header": true
},
{
'data': 'Result',
'header': true
"data": "Result",
"header": true
}
],
[
'checkName',
'XEP-0199: XMPP Ping/PingIntegrationTest.pingAsync (Normal)',
'✅ pass'
"ABC-0199: XMPP Ping"
],
[
'checkName',
'XEP-0199: XMPP Ping/PingIntegrationTest.pingServer (Normal)',
'✅ pass'
"",
"ABC-0199: XMPP Ping/PingIntegrationTest.pingAsync (Normal)",
"✅ pass"
],
[
'checkName',
'XEP-0045: Multi-User Chat/MultiUserChatRolesAffiliationsPrivilegesIntegrationTest.mucRoleTestForReceivingModerator (Normal)',
'✅ pass'
]
])
expect(flakyTable).toStrictEqual([
"",
"ABC-0199: XMPP Ping/PingIntegrationTest.pingServer (Normal)",
"✅ pass"
],
[
{
'data': '',
'header': true
},
{
'data': 'Test',
'header': true
},
{
'data': 'Retries',
'header': true
}
"ABC-0045: Multi-User Chat"
],
[
"",
"ABC-0045: Multi-User Chat/MultiUserIntegrationTest.mucRoleTestForReceivingModerator (Normal)",
"✅ pass"
]
])
expect(flakyTable).toStrictEqual(FLAKY_TABLE)
})
})
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ inputs:
description: 'Include table with all flaky results in summary'
required: false
default: 'false'
group_suite:
description: 'If enabled, will group the testcases by test suite in the `detailed_summary`'
required: false
default: 'false'
comment:
description: 'Enables a comment being added to the PR with the summary tables (summary has to be enabled). Default: false'
required: false
Expand Down
70 changes: 50 additions & 20 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.

8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export async function run(): Promise<void> {
const jobSummary = core.getInput('job_summary') === 'true'
const detailedSummary = core.getInput('detailed_summary') === 'true'
const flakySummary = core.getInput('flaky_summary') === 'true'
const groupSuite = core.getInput('group_suite') === 'true'
const comment = core.getInput('comment') === 'true'
const updateComment = core.getInput('updateComment') === 'true'
const jobName = core.getInput('job_name')
Expand Down Expand Up @@ -66,8 +67,8 @@ export async function run(): Promise<void> {
failed: 0,
passed: 0,
foundFiles: 0,
annotations: [],
globalAnnotations: []
globalAnnotations: [],
testResults: []
}

core.info(`Preparing ${reportsCount} report as configured.`)
Expand Down Expand Up @@ -146,7 +147,8 @@ export async function run(): Promise<void> {
testResults,
includePassed,
detailedSummary,
flakySummary
flakySummary,
groupSuite
)
if (jobSummary && supportsJobSummary) {
try {
Expand Down
Loading

0 comments on commit dda3b1e

Please sign in to comment.