add name to report, combine failures into a list

This commit is contained in:
A.J. Kaptijn 2024-03-20 14:44:57 +01:00
parent 52df78dda0
commit cb25e45d8e
2 changed files with 35 additions and 20 deletions

21
dist/index.js generated vendored
View file

@ -356,14 +356,19 @@ class TestReporter {
core.info(`Check run details: ${resp.data.details_url}`);
result.checkUrl = resp.data.html_url;
if (this.slackWebhook && this.context.branch === 'master') {
const webhook = new webhook_1.IncomingWebhook(this.slackWebhook, {
username: name
});
const webhook = new webhook_1.IncomingWebhook(this.slackWebhook);
const passed = results.reduce((sum, tr) => sum + tr.passed, 0);
const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0);
const failed = results.reduce((sum, tr) => sum + tr.failed, 0);
const req = {
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: `*${name}*`
}
},
{
type: 'section',
text: {
@ -385,19 +390,21 @@ class TestReporter {
}
});
if (failed <= 10) {
const failedTests = [];
tr.failedSuites.map(suite => {
suite.failedGroups.map(group => {
group.failedTests.map(test => {
failedTests.push(`* <${suite.link}|${test.name}>`);
});
});
});
req.blocks.push({
type: 'section',
text: {
type: 'mrkdwn',
text: `:red_circle: <${suite.link}|${test.name}>`
text: failedTests.join('\n')
}
});
});
});
});
}
});
yield webhook.send(req);

View file

@ -300,15 +300,20 @@ class TestReporter {
result.checkUrl = resp.data.html_url
if (this.slackWebhook && this.context.branch === 'master') {
const webhook = new IncomingWebhook(this.slackWebhook, {
username: name
})
const webhook = new IncomingWebhook(this.slackWebhook)
const passed = results.reduce((sum, tr) => sum + tr.passed, 0)
const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0)
const failed = results.reduce((sum, tr) => sum + tr.failed, 0)
const req = {
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: `*${name}*`
}
},
{
type: 'section',
text: {
@ -332,19 +337,22 @@ class TestReporter {
})
if (failed <= 10) {
const failedTests: string[] = []
tr.failedSuites.map(suite => {
suite.failedGroups.map(group => {
group.failedTests.map(test => {
failedTests.push(`* <${suite.link}|${test.name}>`)
})
})
})
req.blocks.push({
type: 'section',
text: {
type: 'mrkdwn',
text: `:red_circle: <${suite.link}|${test.name}>`
text: failedTests.join('\n')
}
})
})
})
})
}
})