Skip to content

Commit

Permalink
🧪 Refactor main and post functions to remove IIFE and improve readabi…
Browse files Browse the repository at this point in the history
…lity
  • Loading branch information
polRk committed Nov 23, 2024
1 parent 3f7fc81 commit 055a04e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
7 changes: 4 additions & 3 deletions init/dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -93174,7 +93174,7 @@ async function getPullRequestNumber() {
}

// src/main.ts
(async function main() {
async function main() {
let cwd = path.join(process.cwd(), ".slo");
let sdk = import_core2.getInput("sdk_name", { required: true });
import_core2.saveState("cwd", cwd);
Expand Down Expand Up @@ -93221,7 +93221,7 @@ async function getPullRequestNumber() {
{
import_core2.info("Creating compose config...");
let composePath = path.join(cwd, "compose.yaml");
let composeContent = generateComposeFile(parseInt(import_core2.getInput("YDB_DATABASE_NODE_COUNT", { required: true })));
let composeContent = generateComposeFile(parseInt(import_core2.getInput("ydb_database_node_count", { required: true })));
fs.writeFileSync(composePath, composeContent, { encoding: "utf-8" });
import_core2.info(`Created compose.yaml: ${composePath}`);
}
Expand All @@ -93230,4 +93230,5 @@ async function getPullRequestNumber() {
let start = new Date;
import_core2.info(`YDB started at ${start}`);
import_core2.saveState("start", start.toISOString());
})();
}
main();
5 changes: 3 additions & 2 deletions init/dist/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -89361,7 +89361,7 @@ var defaultMetrics = [
];

// src/post.ts
(async function post() {
async function post() {
let cwd = import_core.getState("cwd");
let sdk = import_core.getState("sdk");
let pull = import_core.getState("pull");
Expand Down Expand Up @@ -89396,4 +89396,5 @@ var defaultMetrics = [
import_core.info(`YDB SLO Test duration: ${duration}ms.`);
import_core.debug("Cleaning up temp directory...");
fs.rmSync(cwd, { recursive: true });
})();
}
post();
9 changes: 6 additions & 3 deletions init/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import prometheusConfig from './cfg/prom/config.yml' with { type: 'text' }
import { generateComposeFile } from './configs'
import { getPullRequestNumber } from './pulls'
import { HOST, PROMETHEUS_PUSHGATEWAY_PORT } from './constants'
;(async function main() {

async function main() {
let cwd = path.join(process.cwd(), '.slo')
let sdk = getInput('sdk_name', { required: true })

Expand Down Expand Up @@ -74,7 +75,7 @@ import { HOST, PROMETHEUS_PUSHGATEWAY_PORT } from './constants'
{
info('Creating compose config...')
let composePath = path.join(cwd, 'compose.yaml')
let composeContent = generateComposeFile(parseInt(getInput('YDB_DATABASE_NODE_COUNT', { required: true })))
let composeContent = generateComposeFile(parseInt(getInput('ydb_database_node_count', { required: true })))

fs.writeFileSync(composePath, composeContent, { encoding: 'utf-8' })
info(`Created compose.yaml: ${composePath}`)
Expand All @@ -86,4 +87,6 @@ import { HOST, PROMETHEUS_PUSHGATEWAY_PORT } from './constants'
let start = new Date()
info(`YDB started at ${start}`)
saveState('start', start.toISOString())
})()
}

main()
7 changes: 5 additions & 2 deletions init/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { DefaultArtifactClient } from '@actions/artifact'

import { collectPrometheus } from './prometheus'
import { defaultMetrics } from './metrics'
;(async function post() {

async function post() {
let cwd = getState('cwd')
let sdk = getState('sdk')
let pull = getState('pull')
Expand Down Expand Up @@ -52,4 +53,6 @@ import { defaultMetrics } from './metrics'

debug('Cleaning up temp directory...')
fs.rmSync(cwd, { recursive: true })
})()
}

post()

0 comments on commit 055a04e

Please sign in to comment.