From e27731bc7a9647d21a7b60903aa020afa4a224d3 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Wed, 14 Aug 2019 14:06:43 -0700 Subject: [PATCH] Toolkit: write PR report to a folder with the circle build number (#18560) --- .../src/cli/tasks/plugin.ci.ts | 25 ++++++++++--------- packages/grafana-toolkit/src/plugins/aws.ts | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/grafana-toolkit/src/cli/tasks/plugin.ci.ts b/packages/grafana-toolkit/src/cli/tasks/plugin.ci.ts index f054280986c..ab7c144b863 100644 --- a/packages/grafana-toolkit/src/cli/tasks/plugin.ci.ts +++ b/packages/grafana-toolkit/src/cli/tasks/plugin.ci.ts @@ -352,10 +352,10 @@ const pluginReportRunner: TaskRunner = async ({ upload }) => { const branch = build.branch || 'unknown'; const buildNumber = getBuildNumber(); const root = `dev/${pluginMeta.id}`; - const dirKey = pr ? `${root}/pr/${pr}` : `${root}/branch/${branch}/${buildNumber}`; + const dirKey = pr ? `${root}/pr/${pr}/${buildNumber}` : `${root}/branch/${branch}/${buildNumber}`; const jobKey = `${dirKey}/index.json`; - if (await s3.exits(jobKey)) { + if (await s3.exists(jobKey)) { throw new Error('Job already registered: ' + jobKey); } @@ -378,20 +378,21 @@ const pluginReportRunner: TaskRunner = async ({ upload }) => { version, }; + let base = `${root}/branch/${branch}/`; + latest.build.number = buildNumber; if (pr) { latest.build.pr = pr; - } else { - latest.build.number = buildNumber; - const base = `${root}/branch/${branch}/`; - const historyKey = base + `history.json`; - console.log('Read', historyKey); - const history: PluginHistory = await s3.readJSON(historyKey, defaultPluginHistory); - appendPluginHistory(report, latest, history); - - await s3.writeJSON(historyKey, history); - console.log('wrote history'); + base = `${root}/pr/${pr}/`; } + const historyKey = base + `history.json`; + console.log('Read', historyKey); + const history: PluginHistory = await s3.readJSON(historyKey, defaultPluginHistory); + appendPluginHistory(report, latest, history); + + await s3.writeJSON(historyKey, history); + console.log('wrote history'); + // Private things may want to upload if (upload) { s3.uploadPackages(packageInfo, { diff --git a/packages/grafana-toolkit/src/plugins/aws.ts b/packages/grafana-toolkit/src/plugins/aws.ts index 1ce78b634a9..c92d83f82a0 100644 --- a/packages/grafana-toolkit/src/plugins/aws.ts +++ b/packages/grafana-toolkit/src/plugins/aws.ts @@ -94,7 +94,7 @@ export class S3Client { }); } - async exits(key: string): Promise { + async exists(key: string): Promise { return new Promise((resolve, reject) => { this.s3.getObject( {