From d4075b099f3dbc6abf8b46e7ea346660b5f023e0 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Wed, 27 Jul 2022 16:37:15 +0530 Subject: [PATCH] Fix for script to measure bundle size over time (#15338) --- .circleci/scripts/bundle-stats-commit.sh | 18 ++++++++---------- test/e2e/mv3-perf-stats/bundle-size.js | 12 ++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.circleci/scripts/bundle-stats-commit.sh b/.circleci/scripts/bundle-stats-commit.sh index 7c0894430..db5fe101b 100755 --- a/.circleci/scripts/bundle-stats-commit.sh +++ b/.circleci/scripts/bundle-stats-commit.sh @@ -16,6 +16,12 @@ then exit 1 fi +if [[ "${CIRCLE_BRANCH}" != "develop" ]] +then + printf 'This is not develop branch' + exit 0 +fi + if [[ -z "${GITHUB_TOKEN:-}" ]] then printf '%s\n' 'GITHUB_TOKEN environment variable must be set' @@ -26,14 +32,6 @@ then exit 1 fi -printf '%s\n' 'Commit the manifest version and changelog if the manifest has changed' - -if [[ "${CIRCLE_BRANCH}" != "develop" ]] -then - printf 'This is not develop branch' - exit 0 -fi - mkdir temp git config --global user.email "metamaskbot@users.noreply.github.com" @@ -50,11 +48,11 @@ then exit 0 fi -cp -R test-artifacts/chrome/mv3/bundle_size.json temp/stats +cp -R test-artifacts/chrome/mv3/bundle_size_stats.json temp/stats echo " bundle_size_stats-${CIRCLE_SHA1}.json" >> temp/stats/fileList.txt -mv temp/stats/bundle_size.json "temp/stats/bundle_size_stats-${CIRCLE_SHA1}.json" +mv temp/stats/bundle_size_stats.json "temp/stats/bundle_size_stats-${CIRCLE_SHA1}.json" cd temp diff --git a/test/e2e/mv3-perf-stats/bundle-size.js b/test/e2e/mv3-perf-stats/bundle-size.js index da52d916c..d7360ab9d 100644 --- a/test/e2e/mv3-perf-stats/bundle-size.js +++ b/test/e2e/mv3-perf-stats/bundle-size.js @@ -109,6 +109,18 @@ async function main() { await fs.mkdir(outputDirectory, { recursive: true }); } await fs.writeFile(outPath, JSON.stringify(result, null, 2)); + await fs.writeFile( + `${out}/bundle_size_stats.json`, + JSON.stringify( + { + background: backgroundBundleSize, + ui: uiBundleSize, + timestamp: new Date().getTime(), + }, + null, + 2, + ), + ); } else { console.log(JSON.stringify(result, null, 2)); }