Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Mar 6, 2024
1 parent 01f6271 commit d144d12
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
16 changes: 13 additions & 3 deletions src/callExecutables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ export function prepareAWS(awsCredentialsB64: string, awsConfigB64: string) {
export function call(command: string, secret = false) {
const id = ++callId
!secret && core.info(`Call #${id} command: '${command}'`)
const spawnResult = execSync(command, {encoding: 'utf8', maxBuffer: Infinity, stdio: 'pipe'})
const spawnResult = execSync(command, {
encoding: 'utf8',
maxBuffer: Infinity,
stdio: 'pipe'
})
core.debug(`Call #${id} result ${spawnResult}`)
return spawnResult
}
Expand Down Expand Up @@ -113,14 +117,20 @@ export function callAsync(
} else {
if (secret)
core.info(`Call #${id} async with secrets failed - on close`)
else core.info(`Call #${id} async failed - on close:\nError: ${err}\nOutput: ${out}`)
else
core.info(
`Call #${id} async failed - on close:\nError: ${err}\nOutput: ${out}`
)

reject(new Error(err))
}
})
proc.on('error', err => {
if (secret) core.info(`Call #${id} async with secrets failed - on error`)
else core.info(`Call #${id} async failed - on error:\nError: ${err}\nOutput: ${out}`)
else
core.info(
`Call #${id} async failed - on error:\nError: ${err}\nOutput: ${out}`
)

reject(err)
})
Expand Down
21 changes: 9 additions & 12 deletions src/workload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {withTimeout} from './utils/withTimeout'

const workloadManifestTemplate = manifests['k8s/ci/workload.yaml'].content

const fs = require('fs');
const fs = require('fs')

export function dockerLogin(repo: string, user: string, password: string) {
return logGroup('Docker login', async () => {
Expand Down Expand Up @@ -124,7 +124,7 @@ export function runWorkload(
await saveLogs(options.id, command)
throw new Error(msg)
}
return (status.complete || status.succeeded);
return status.complete || status.succeeded
}
)
const endTime = new Date()
Expand All @@ -134,10 +134,7 @@ export function runWorkload(
})
}

async function saveLogs(
id: string,
command: string
) {
async function saveLogs(id: string, command: string) {
let logs = await callKubernetesAsync(`logs job/${id}-wl-${command}`)

// TODO: print logs
Expand All @@ -146,13 +143,13 @@ async function saveLogs(
// core.endGroup()

try {
let dir = "./logs"
if (!fs.existsSync(dir)){
await fs.promises.mkdir(dir);
let dir = './logs'
if (!fs.existsSync(dir)) {
await fs.promises.mkdir(dir)
}

await fs.promises.writeFile(`${dir}/${id}-${command}.log`, logs);
await fs.promises.writeFile(`${dir}/${id}-${command}.log`, logs)
} catch (e) {
core.info(`error write file for ${id}-${command}: ${(e as Error).message}`)
core.info(`error write file for ${id}-${command}: ${(e as Error).message}`)
}
}
}

0 comments on commit d144d12

Please sign in to comment.