2023-08-16 00:14:22 +00:00
|
|
|
module.exports = ( { core } ) => {
|
2023-08-16 04:47:25 +00:00
|
|
|
const {
|
|
|
|
API_RESULT,
|
|
|
|
E2E_RESULT,
|
|
|
|
k6_RESULT,
|
|
|
|
PLUGINS_BLOCKS_PATH,
|
2023-08-17 00:51:49 +00:00
|
|
|
GITHUB_REF_NAME,
|
2023-08-16 04:47:25 +00:00
|
|
|
GITHUB_RUN_ID,
|
|
|
|
} = process.env;
|
2023-08-16 00:14:22 +00:00
|
|
|
const {
|
|
|
|
selectEmoji,
|
|
|
|
readContextBlocksFromJsonFiles,
|
|
|
|
} = require( './utils' );
|
2023-08-15 08:53:29 +00:00
|
|
|
|
2023-08-17 00:51:49 +00:00
|
|
|
const create_blockGroup_header = () => {
|
|
|
|
const date = new Intl.DateTimeFormat( 'en-US', {
|
|
|
|
dateStyle: 'full',
|
|
|
|
} ).format( Date.now() );
|
2023-08-15 08:53:29 +00:00
|
|
|
|
2023-08-17 00:54:21 +00:00
|
|
|
const blocks = [
|
2023-08-17 00:51:49 +00:00
|
|
|
{
|
|
|
|
type: 'divider',
|
2023-08-16 00:14:22 +00:00
|
|
|
},
|
|
|
|
{
|
2023-08-17 00:51:49 +00:00
|
|
|
type: 'header',
|
2023-08-16 04:47:25 +00:00
|
|
|
text: {
|
|
|
|
type: 'plain_text',
|
2023-08-17 00:51:49 +00:00
|
|
|
text: 'Daily test results',
|
2023-08-16 04:47:25 +00:00
|
|
|
emoji: true,
|
|
|
|
},
|
2023-08-16 00:14:22 +00:00
|
|
|
},
|
2023-08-17 00:51:49 +00:00
|
|
|
{
|
|
|
|
type: 'context',
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
type: 'mrkdwn',
|
|
|
|
text: `*Date:* ${ date }`,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'context',
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
type: 'mrkdwn',
|
|
|
|
text: `*Branch:* \`${ GITHUB_REF_NAME }\``,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'context',
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
type: 'mrkdwn',
|
|
|
|
text: `*GitHub run logs:* <https://github.com/woocommerce/woocommerce/actions/runs/${ GITHUB_RUN_ID }|${ GITHUB_RUN_ID }>`,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'context',
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
type: 'mrkdwn',
|
|
|
|
text: '*Test reports dashboard:* <https://woocommerce.github.io/woocommerce-test-reports/daily/|Daily smoke tests>',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-08-17 00:54:21 +00:00
|
|
|
return blocks;
|
2023-08-16 04:47:25 +00:00
|
|
|
};
|
2023-08-17 00:51:49 +00:00
|
|
|
|
|
|
|
const create_blockGroup_nightlySite = () => {
|
|
|
|
const emoji_API = selectEmoji( API_RESULT );
|
|
|
|
const emoji_E2E = selectEmoji( E2E_RESULT );
|
|
|
|
const emoji_k6 = selectEmoji( k6_RESULT );
|
|
|
|
|
2023-08-17 00:54:21 +00:00
|
|
|
const blocks = [
|
2023-08-16 00:14:22 +00:00
|
|
|
{
|
2023-08-17 00:51:49 +00:00
|
|
|
type: 'section',
|
2023-08-16 04:47:25 +00:00
|
|
|
text: {
|
2023-08-17 00:51:49 +00:00
|
|
|
type: 'mrkdwn',
|
|
|
|
text: '*Smoke tests on daily build*',
|
2023-08-16 04:47:25 +00:00
|
|
|
},
|
2023-08-16 00:14:22 +00:00
|
|
|
},
|
2023-08-17 00:51:49 +00:00
|
|
|
{
|
|
|
|
type: 'context',
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
type: 'mrkdwn',
|
|
|
|
text: `API ${ emoji_API }\tE2E ${ emoji_E2E }\tk6 ${ emoji_k6 }`,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-08-17 00:54:21 +00:00
|
|
|
return blocks;
|
2023-08-16 00:14:22 +00:00
|
|
|
};
|
2023-08-15 08:53:29 +00:00
|
|
|
|
2023-08-17 00:51:49 +00:00
|
|
|
const blockGroup_header = create_blockGroup_header();
|
|
|
|
const blockGroup_nightlySite = create_blockGroup_nightlySite();
|
|
|
|
const blockGroups_plugins =
|
|
|
|
readContextBlocksFromJsonFiles( PLUGINS_BLOCKS_PATH );
|
2023-08-16 00:14:22 +00:00
|
|
|
const payload = {
|
2023-08-16 04:47:25 +00:00
|
|
|
blocks: [
|
2023-08-17 00:51:49 +00:00
|
|
|
...blockGroup_header,
|
2023-08-16 04:47:25 +00:00
|
|
|
...blockGroup_nightlySite,
|
|
|
|
...blockGroups_plugins.flat(),
|
|
|
|
],
|
2023-08-16 00:14:22 +00:00
|
|
|
};
|
|
|
|
const payload_stringified = JSON.stringify( payload );
|
2023-08-15 08:53:29 +00:00
|
|
|
|
2023-08-16 01:07:56 +00:00
|
|
|
core.setOutput( 'payload', payload_stringified );
|
2023-08-16 00:14:22 +00:00
|
|
|
};
|