From 53947d805b9cf15782784725d7effea1bcb636eb Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 3 Apr 2022 22:53:11 +0200 Subject: [PATCH] fix: Lets await! --- src/lib/buildPacks/common.ts | 8 ++++++-- src/lib/docker.ts | 12 ++++++++---- src/lib/importers/github.ts | 4 ++-- src/lib/importers/gitlab.ts | 4 ++-- src/lib/queues/index.ts | 4 ++-- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/lib/buildPacks/common.ts b/src/lib/buildPacks/common.ts index 441794217..0fa4f936a 100644 --- a/src/lib/buildPacks/common.ts +++ b/src/lib/buildPacks/common.ts @@ -140,7 +140,11 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap ` ); await fs.writeFile(`${workdir}/entrypoint.sh`, `chown -R 1000 /app`); - saveBuildLog({ line: 'Copied default configuration file for PHP.', buildId, applicationId }); + await saveBuildLog({ + line: 'Copied default configuration file for PHP.', + buildId, + applicationId + }); } else if (staticDeployments.includes(buildPack)) { await fs.writeFile( `${workdir}/nginx.conf`, @@ -194,7 +198,7 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap } ` ); - saveBuildLog({ line: 'Copied default configuration file.', buildId, applicationId }); + await saveBuildLog({ line: 'Copied default configuration file.', buildId, applicationId }); } } catch (error) { console.log(error); diff --git a/src/lib/docker.ts b/src/lib/docker.ts index 89290fba2..f518bdcfe 100644 --- a/src/lib/docker.ts +++ b/src/lib/docker.ts @@ -88,12 +88,12 @@ export async function buildImage({ debug = false }) { if (isCache) { - saveBuildLog({ line: `Building cache image started.`, buildId, applicationId }); + await saveBuildLog({ line: `Building cache image started.`, buildId, applicationId }); } else { - saveBuildLog({ line: `Building image started.`, buildId, applicationId }); + await saveBuildLog({ line: `Building image started.`, buildId, applicationId }); } if (!debug && isCache) { - saveBuildLog({ + await saveBuildLog({ line: `Debug turned off. To see more details, allow it in the configuration.`, buildId, applicationId @@ -132,7 +132,11 @@ export async function streamEvents({ stream, docker, buildId, applicationId, deb } else if (event.stream) { if (event.stream !== '\n') { if (debug) - saveBuildLog({ line: `${event.stream.replace('\n', '')}`, buildId, applicationId }); + await saveBuildLog({ + line: `${event.stream.replace('\n', '')}`, + buildId, + applicationId + }); } } } diff --git a/src/lib/importers/github.ts b/src/lib/importers/github.ts index e9bea3d42..64fae1fd6 100644 --- a/src/lib/importers/github.ts +++ b/src/lib/importers/github.ts @@ -14,7 +14,7 @@ export default async function ({ buildId }): Promise { try { - saveBuildLog({ line: 'GitHub importer started.', buildId, applicationId }); + await saveBuildLog({ line: 'GitHub importer started.', buildId, applicationId }); const { privateKey, appId, installationId } = await db.getUniqueGithubApp({ githubAppId }); const githubPrivateKey = privateKey.replace(/\\n/g, '\n').replace(/"/g, ''); @@ -34,7 +34,7 @@ export default async function ({ } }) .json(); - saveBuildLog({ + await saveBuildLog({ line: `Cloning ${repository}:${branch} branch.`, buildId, applicationId diff --git a/src/lib/importers/gitlab.ts b/src/lib/importers/gitlab.ts index fceda7fe7..fb07dcbf0 100644 --- a/src/lib/importers/gitlab.ts +++ b/src/lib/importers/gitlab.ts @@ -11,11 +11,11 @@ export default async function ({ buildId, privateSshKey }): Promise { - saveBuildLog({ line: 'GitLab importer started.', buildId, applicationId }); + await saveBuildLog({ line: 'GitLab importer started.', buildId, applicationId }); await asyncExecShell(`echo '${privateSshKey}' > ${repodir}/id.rsa`); await asyncExecShell(`chmod 600 ${repodir}/id.rsa`); - saveBuildLog({ + await saveBuildLog({ line: `Cloning ${repository}:${branch} branch.`, buildId, applicationId diff --git a/src/lib/queues/index.ts b/src/lib/queues/index.ts index 55d7ca51b..0f7dd5815 100644 --- a/src/lib/queues/index.ts +++ b/src/lib/queues/index.ts @@ -135,12 +135,12 @@ buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => { const workdir = `/tmp/build-sources/${job.data.repository}`; if (!dev) await asyncExecShell(`rm -fr ${workdir}`); } - saveBuildLog({ + await saveBuildLog({ line: 'Failed to deploy!', buildId: job.data.build_id, applicationId: job.data.id }); - saveBuildLog({ + await saveBuildLog({ line: `Reason: ${failedReason.toString()}`, buildId: job.data.build_id, applicationId: job.data.id