From e8f7169839dc1f67e8c054ca34d570ff5bda0a4d Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 6 Jan 2023 15:28:25 +0000 Subject: [PATCH] Move database bundling to inside the try-catch --- lib/database-upload.js | 10 +++++----- lib/database-upload.js.map | 2 +- src/database-upload.ts | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/database-upload.js b/lib/database-upload.js index 1da6e434f4..64595d573c 100644 --- a/lib/database-upload.js +++ b/lib/database-upload.js @@ -44,12 +44,12 @@ async function uploadDatabases(repositoryNwo, config, apiDetails, logger) { const client = (0, api_client_1.getApiClient)(); const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd); for (const language of config.languages) { - // Upload the database bundle. - // Although we are uploading arbitrary file contents to the API, it's worth - // noting that it's the API's job to validate that the contents is acceptable. - // This API method is available to anyone with write access to the repo. - const bundledDb = await (0, util_1.bundleDb)(config, language, codeql, language); try { + // Upload the database bundle. + // Although we are uploading arbitrary file contents to the API, it's worth + // noting that it's the API's job to validate that the contents is acceptable. + // This API method is available to anyone with write access to the repo. + const bundledDb = await (0, util_1.bundleDb)(config, language, codeql, language); await client.request(`POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name`, { owner: repositoryNwo.owner, repo: repositoryNwo.repo, diff --git a/lib/database-upload.js.map b/lib/database-upload.js.map index b2363a1e2b..876a5e1f84 100644 --- a/lib/database-upload.js.map +++ b/lib/database-upload.js.map @@ -1 +1 @@ -{"version":3,"file":"database-upload.js","sourceRoot":"","sources":["../src/database-upload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,4DAA8C;AAC9C,6CAA8D;AAC9D,qCAAqC;AAIrC,6CAA+B;AAC/B,iCAAkC;AAE3B,KAAK,UAAU,eAAe,CACnC,aAA4B,EAC5B,MAAc,EACd,UAA4B,EAC5B,MAAc;IAEd,IAAI,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CA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C,QAAQ,EAAE,CAAC,CAAC;SAChE;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,4CAA4C;YAC5C,MAAM,CAAC,OAAO,CAAC,iCAAiC,QAAQ,KAAK,CAAC,EAAE,CAAC,CAAC;SACnE;KACF;AACH,CAAC;AAvDD,0CAuDC"} \ No newline at end of file +{"version":3,"file":"database-upload.js","sourceRoot":"","sources":["../src/database-upload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,4DAA8C;AAC9C,6CAA8D;AAC9D,qCAAqC;AAIrC,6CAA+B;AAC/B,iCAAkC;AAE3B,KAAK,UAAU,eAAe,CACnC,aAA4B,EAC5B,MAAc,EACd,UAA4B,EAC5B,MAAc;IAEd,IAAI,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,KAAK,MAAM,EAAE;QAC9D,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACvE,OAAO;KACR;IAED,iDAAiD;IACjD,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;QAC3D,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,OAAO;KACR;IAED,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,wBAAwB,EAAE,CAAC,EAAE;QACnD,4EAA4E;QAC5E,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO;KACR;IAED,MAAM,MAAM,GAAG,IAAA,yBAAY,GAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAEjD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE;QACvC,IAAI;YACF,8BAA8B;YAC9B,2EAA2E;YAC3E,8EAA8E;YAC9E,wEAAwE;YACxE,MAAM,SAAS,GAAG,MAAM,IAAA,eAAQ,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;YAErE,MAAM,MAAM,CAAC,OAAO,CAClB,wGAAwG,EACxG;gBACE,KAAK,EAAE,aAAa,CAAC,KAAK;gBAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;gBACxB,QAAQ;gBACR,IAAI,EAAE,GAAG,QAAQ,WAAW;gBAC5B,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC;gBACpC,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,UAAU,CAAC,IAAI,EAAE;oBACzC,cAAc,EAAE,iBAAiB;oBACjC,gBAAgB,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI;iBAC9C;aACF,CACF,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,sCAAsC,QAAQ,EAAE,CAAC,CAAC;SAChE;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,4CAA4C;YAC5C,MAAM,CAAC,OAAO,CAAC,iCAAiC,QAAQ,KAAK,CAAC,EAAE,CAAC,CAAC;SACnE;KACF;AACH,CAAC;AAxDD,0CAwDC"} \ No newline at end of file diff --git a/src/database-upload.ts b/src/database-upload.ts index 4e13fdafb1..a09b7c2d30 100644 --- a/src/database-upload.ts +++ b/src/database-upload.ts @@ -36,12 +36,13 @@ export async function uploadDatabases( const codeql = await getCodeQL(config.codeQLCmd); for (const language of config.languages) { - // Upload the database bundle. - // Although we are uploading arbitrary file contents to the API, it's worth - // noting that it's the API's job to validate that the contents is acceptable. - // This API method is available to anyone with write access to the repo. - const bundledDb = await bundleDb(config, language, codeql, language); try { + // Upload the database bundle. + // Although we are uploading arbitrary file contents to the API, it's worth + // noting that it's the API's job to validate that the contents is acceptable. + // This API method is available to anyone with write access to the repo. + const bundledDb = await bundleDb(config, language, codeql, language); + await client.request( `POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name`, {