Fix function export

This commit is contained in:
Rodel Calasagsag 2023-08-16 08:14:22 +08:00
parent bbfa6c0644
commit d351853bc1
2 changed files with 97 additions and 88 deletions

View File

@ -1,55 +1,62 @@
const { API_RESULT, E2E_RESULT, k6_RESULT, PLUGINS_BLOCKS_PATH } = process.env;
const { selectEmoji, readContextBlocksFromJsonFiles } = require( './utils' );
module.exports = ( { core } ) => {
const { API_RESULT, E2E_RESULT, k6_RESULT, PLUGINS_BLOCKS_PATH } =
process.env;
const {
selectEmoji,
readContextBlocksFromJsonFiles,
} = require( './utils' );
const block_header = {
type: 'header',
text: {
type: 'plain_text',
text: 'Daily test results',
emoji: true,
},
const block_header = {
type: 'header',
text: {
type: 'plain_text',
text: 'Daily test results',
emoji: true,
},
};
const emoji_API = selectEmoji( API_RESULT );
const emoji_E2E = selectEmoji( E2E_RESULT );
const emoji_k6 = selectEmoji( k6_RESULT );
const block_nightlySite = {
type: 'context',
elements: [
{
type: 'mrkdwn',
text: '*Smoke tests on daily build*',
},
{
type: 'mrkdwn',
text: ' ',
},
{
type: 'mrkdwn',
text: ' ',
},
{
type: 'mrkdwn',
text: `API ${ emoji_API }`,
},
{
type: 'mrkdwn',
text: `E2E ${ emoji_E2E }`,
},
{
type: 'mrkdwn',
text: `k6 ${ emoji_k6 }`,
},
],
};
const blocks_plugins =
readContextBlocksFromJsonFiles( PLUGINS_BLOCKS_PATH );
const payload = {
blocks: [ block_header, block_nightlySite, ...blocks_plugins ],
};
const payload_stringified = JSON.stringify( payload );
core.setOuput( 'payload', payload_stringified );
};
const emoji_API = selectEmoji( API_RESULT );
const emoji_E2E = selectEmoji( E2E_RESULT );
const emoji_k6 = selectEmoji( k6_RESULT );
const block_nightlySite = {
type: 'context',
elements: [
{
type: 'mrkdwn',
text: '*Smoke tests on daily build*',
},
{
type: 'mrkdwn',
text: ' ',
},
{
type: 'mrkdwn',
text: ' ',
},
{
type: 'mrkdwn',
text: `API ${ emoji_API }`,
},
{
type: 'mrkdwn',
text: `E2E ${ emoji_E2E }`,
},
{
type: 'mrkdwn',
text: `k6 ${ emoji_k6 }`,
},
],
};
const blocks_plugins = readContextBlocksFromJsonFiles( PLUGINS_BLOCKS_PATH );
const payload = {
blocks: [ block_header, block_nightlySite, ...blocks_plugins ],
};
const payload_stringified = JSON.stringify( payload );
core.setOuput( 'payload', payload_stringified );

View File

@ -1,38 +1,40 @@
const { UPLOAD_RESULT, E2E_RESULT, PLUGIN_NAME, PLUGIN_SLUG } = process.env;
const { selectEmoji } = require( './utils' );
const fs = require( 'fs' );
module.exports = ( { core } ) => {
const { UPLOAD_RESULT, E2E_RESULT, PLUGIN_NAME, PLUGIN_SLUG } = process.env;
const { selectEmoji } = require( './utils' );
const fs = require( 'fs' );
const emoji_UPLOAD = selectEmoji( UPLOAD_RESULT );
const emoji_E2E = selectEmoji( E2E_RESULT );
const emoji_UPLOAD = selectEmoji( UPLOAD_RESULT );
const emoji_E2E = selectEmoji( E2E_RESULT );
const block = {
type: 'context',
elements: [
{
type: 'mrkdwn',
text: PLUGIN_NAME,
},
{
type: 'mrkdwn',
text: ' ',
},
{
type: 'mrkdwn',
text: ' ',
},
{
type: 'mrkdwn',
text: `Upload test ${ emoji_UPLOAD }`,
},
{
type: 'mrkdwn',
text: `E2E ${ emoji_E2E }`,
},
],
const block = {
type: 'context',
elements: [
{
type: 'mrkdwn',
text: PLUGIN_NAME,
},
{
type: 'mrkdwn',
text: ' ',
},
{
type: 'mrkdwn',
text: ' ',
},
{
type: 'mrkdwn',
text: `Upload test ${ emoji_UPLOAD }`,
},
{
type: 'mrkdwn',
text: `E2E ${ emoji_E2E }`,
},
],
};
const block_stringified = JSON.stringify( block );
const path = `/tmp/${ PLUGIN_SLUG }.json`;
fs.writeFileSync( path, block_stringified );
core.setOutput( 'path', path );
};
const block_stringified = JSON.stringify( block );
const path = `/tmp/${ PLUGIN_SLUG }.json`;
fs.writeFileSync( path, block_stringified );
core.setOutput( 'path', path );