From 3d2466a1f7be00c2cb3cb5b77ba98aa0e8687336 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 20 Dec 2024 14:21:15 -0330 Subject: [PATCH 1/7] ci: Fix metamaskbot comment build links Various build links in the `metamaskbot` PR comment were broken. All links have been fixed except beta (which is trickier to fix, requires more substantial changes to the beta workflows). Additionally, validation was added to verify each build link, omitting any that are not working from the comment (and logging warning). --- .circleci/config.yml | 16 ++- development/metamaskbot-build-announce.js | 121 +++++++++++++--------- 2 files changed, 85 insertions(+), 52 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 60bb80eaf449..7cd6843e6f28 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -301,10 +301,16 @@ workflows: - prep-deps - prep-build - prep-build-mv2 - - trigger-beta-build - prep-build-mmi - prep-build-flask - prep-build-flask-mv2 + - prep-build-test + - prep-build-test-mv2 + - prep-build-test-webpack + - prep-build-test-flask + - prep-build-test-flask-mv2 + - prep-build-test-mmi + - trigger-beta-build - prep-build-storybook - prep-build-ts-migration-dashboard - benchmark @@ -1408,8 +1414,16 @@ jobs: destination: builds-mv2 - store_artifacts: path: builds-test + - store_artifacts: + path: builds-test-mv2 + - store_artifacts: + path: builds-test-webpack - store_artifacts: path: builds-test-flask + - store_artifacts: + path: builds-test-flask-mv2 + - store_artifacts: + path: builds-test-mmi - store_artifacts: path: test-artifacts destination: test-artifacts diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index f85d64faa887..7bb10f510551 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -38,6 +38,17 @@ function getPercentageChange(from, to) { return parseFloat(((to - from) / Math.abs(from)) * 100).toFixed(2); } +/** + * Check whether an artifact exists, + * + * @param {string} url - The URL of the artifact to check. + * @returns True if the artifact exists, false if it doesn't + */ +async function artifactExists(url) { + const response = await fetch(url, { method: 'HEAD' }); + return response.ok; +} + async function start() { const { GITHUB_COMMENT_TOKEN, @@ -65,50 +76,62 @@ async function start() { // build the github comment content // links to extension builds - const platforms = ['chrome', 'firefox']; - const buildLinks = platforms - .map((platform) => { - const url = - platform === 'firefox' - ? `${BUILD_LINK_BASE}/builds-mv2/metamask-${platform}-${VERSION}.zip` - : `${BUILD_LINK_BASE}/builds/metamask-${platform}-${VERSION}.zip`; - return `${platform}`; - }) - .join(', '); - const betaBuildLinks = `chrome`; - const flaskBuildLinks = platforms - .map((platform) => { - const url = - platform === 'firefox' - ? `${BUILD_LINK_BASE}/builds-flask-mv2/metamask-flask-${platform}-${VERSION}-flask.0.zip` - : `${BUILD_LINK_BASE}/builds-flask/metamask-flask-${platform}-${VERSION}-flask.0.zip`; - return `${platform}`; - }) - .join(', '); - const mmiBuildLinks = platforms - .map((platform) => { - const url = `${BUILD_LINK_BASE}/builds-mmi/metamask-mmi-${platform}-${VERSION}-mmi.0.zip`; - return `${platform}`; - }) - .join(', '); - const testBuildLinks = platforms - .map((platform) => { - const url = - platform === 'firefox' - ? `${BUILD_LINK_BASE}/builds-test-mv2/metamask-${platform}-${VERSION}.zip` - : `${BUILD_LINK_BASE}/builds-test/metamask-${platform}-${VERSION}.zip`; - return `${platform}`; - }) - .join(', '); - const testFlaskBuildLinks = platforms - .map((platform) => { - const url = - platform === 'firefox' - ? `${BUILD_LINK_BASE}/builds-test-flask-mv2/metamask-flask-${platform}-${VERSION}-flask.0.zip` - : `${BUILD_LINK_BASE}/builds-test-flask/metamask-flask-${platform}-${VERSION}-flask.0.zip`; - return `${platform}`; - }) - .join(', '); + const buildMap = { + builds: { + chrome: `${BUILD_LINK_BASE}/builds/metamask-chrome-${VERSION}.zip`, + firefox: `${BUILD_LINK_BASE}/builds-mv2/metamask-firefox-${VERSION}.zip`, + }, + 'builds (beta)': { + chrome: `${BUILD_LINK_BASE}/builds-beta/metamask-flask-chrome-${VERSION}-beta.0.zip`, + }, + 'builds (flask)': { + chrome: `${BUILD_LINK_BASE}/builds-flask/metamask-flask-chrome-${VERSION}-flask.0.zip`, + firefox: `${BUILD_LINK_BASE}/builds-flask-mv2/metamask-flask-firefox-${VERSION}-flask.0.zip`, + }, + 'builds (MMI)': { + chrome: `${BUILD_LINK_BASE}/builds-mmi/metamask-mmi-chrome-${VERSION}-mmi.0.zip`, + }, + 'builds (test)': { + chrome: `${BUILD_LINK_BASE}/builds-test/metamask-chrome-${VERSION}.zip`, + firefox: `${BUILD_LINK_BASE}/builds-test-mv2/metamask-firefox-${VERSION}.zip`, + }, + 'builds (test webpack)': { + chrome: `${BUILD_LINK_BASE}/builds-test-webpack/metamask-chrome-${VERSION}.zip`, + }, + 'builds (test-flask)': { + chrome: `${BUILD_LINK_BASE}/builds-test-flask/metamask-flask-chrome-${VERSION}-flask.0.zip`, + firefox: `${BUILD_LINK_BASE}/builds-test-flask-mv2/metamask-flask-firefox-${VERSION}-flask.0.zip`, + }, + 'builds (test-mmi)': { + chrome: `${BUILD_LINK_BASE}/builds-test-mmi/metamask-mmi-chrome-${VERSION}-mmi.0.zip`, + }, + }; + + // Builds that have been verified to exist + const verifiedBuildMap = {}; + await Promise.all( + Object.entries(buildMap).map(async ([label, builds]) => { + verifiedBuildMap[label] = {}; + await Promise.all( + Object.entries(builds).map(async ([platform, url]) => { + if (await artifactExists(url)) { + verifiedBuildMap[label][platform] = url; + } else { + console.warn(`Build missing: ${url}`); + } + }), + ); + }), + ); + + const buildContentRows = Object.entries(verifiedBuildMap).map( + (label, builds) => { + const buildLinks = Object.entries(builds).map((platform, url) => { + return `${platform}`; + }); + return `${label}: ${buildLinks.join(', ')}`; + }, + ); // links to bundle browser builds const bundles = {}; @@ -171,12 +194,7 @@ async function start() { const allArtifactsUrl = `https://circleci.com/gh/MetaMask/metamask-extension/${CIRCLE_BUILD_NUM}#artifacts/containers/0`; const contentRows = [ - `builds: ${buildLinks}`, - `builds (beta): ${betaBuildLinks}`, - `builds (flask): ${flaskBuildLinks}`, - `builds (MMI): ${mmiBuildLinks}`, - `builds (test): ${testBuildLinks}`, - `builds (test-flask): ${testFlaskBuildLinks}`, + ...buildContentRows, `build viz: ${depVizLink}`, `mv3: ${moduleInitStatsBackgroundLink}`, `mv3: ${moduleInitStatsUILink}`, @@ -198,8 +216,9 @@ async function start() { const exposedContent = `Builds ready [${SHORT_SHA1}]`; const artifactsBody = `
${exposedContent}${hiddenContent}
\n\n`; + const benchmarkPlatforms = ['chrome']; const benchmarkResults = {}; - for (const platform of platforms) { + for (const platform of benchmarkPlatforms) { const benchmarkPath = path.resolve( __dirname, '..', From b1d9ed92d5bb27d856597406d9bc92f508652355 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 20 Dec 2024 15:06:54 -0330 Subject: [PATCH 2/7] Skip labels with no builds --- development/metamaskbot-build-announce.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index 7bb10f510551..7f7d7ad53071 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -111,16 +111,20 @@ async function start() { const verifiedBuildMap = {}; await Promise.all( Object.entries(buildMap).map(async ([label, builds]) => { - verifiedBuildMap[label] = {}; + const verifiedBuilds = {}; await Promise.all( Object.entries(builds).map(async ([platform, url]) => { if (await artifactExists(url)) { - verifiedBuildMap[label][platform] = url; + verifiedBuilds[platform] = url; } else { console.warn(`Build missing: ${url}`); } }), ); + // Skip labels with no builds + if (Object.keys(verifiedBuilds).length > 0) { + verifiedBuildMap[label] = verifiedBuilds; + } }), ); From 016f31503f94b217e1cb256a6d7ce3eee606f155 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 20 Dec 2024 15:34:09 -0330 Subject: [PATCH 3/7] Fix comment build link formatting --- development/metamaskbot-build-announce.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index 7f7d7ad53071..7a40452b8b2f 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -129,8 +129,8 @@ async function start() { ); const buildContentRows = Object.entries(verifiedBuildMap).map( - (label, builds) => { - const buildLinks = Object.entries(builds).map((platform, url) => { + ([label, builds]) => { + const buildLinks = Object.entries(builds).map(([platform, url]) => { return `${platform}`; }); return `${label}: ${buildLinks.join(', ')}`; From dad89281e25f972c2eb8be6f272571b92dc7a48a Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 20 Dec 2024 15:37:30 -0330 Subject: [PATCH 4/7] Remove validation --- development/metamaskbot-build-announce.js | 46 +++-------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index 7a40452b8b2f..4f218b4831ba 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -38,17 +38,6 @@ function getPercentageChange(from, to) { return parseFloat(((to - from) / Math.abs(from)) * 100).toFixed(2); } -/** - * Check whether an artifact exists, - * - * @param {string} url - The URL of the artifact to check. - * @returns True if the artifact exists, false if it doesn't - */ -async function artifactExists(url) { - const response = await fetch(url, { method: 'HEAD' }); - return response.ok; -} - async function start() { const { GITHUB_COMMENT_TOKEN, @@ -107,35 +96,12 @@ async function start() { }, }; - // Builds that have been verified to exist - const verifiedBuildMap = {}; - await Promise.all( - Object.entries(buildMap).map(async ([label, builds]) => { - const verifiedBuilds = {}; - await Promise.all( - Object.entries(builds).map(async ([platform, url]) => { - if (await artifactExists(url)) { - verifiedBuilds[platform] = url; - } else { - console.warn(`Build missing: ${url}`); - } - }), - ); - // Skip labels with no builds - if (Object.keys(verifiedBuilds).length > 0) { - verifiedBuildMap[label] = verifiedBuilds; - } - }), - ); - - const buildContentRows = Object.entries(verifiedBuildMap).map( - ([label, builds]) => { - const buildLinks = Object.entries(builds).map(([platform, url]) => { - return `${platform}`; - }); - return `${label}: ${buildLinks.join(', ')}`; - }, - ); + const buildContentRows = Object.entries(buildMap).map(([label, builds]) => { + const buildLinks = Object.entries(builds).map(([platform, url]) => { + return `${platform}`; + }); + return `${label}: ${buildLinks.join(', ')}`; + }); // links to bundle browser builds const bundles = {}; From d679d4cee762e7823d2519ed4100fcf8b4efcb19 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 20 Dec 2024 16:32:27 -0330 Subject: [PATCH 5/7] Fix webpack and test-flask-mv2 builds, remove test-mmi --- .circleci/config.yml | 12 ++++++------ development/metamaskbot-build-announce.js | 3 --- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7cd6843e6f28..31739328f6e1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -163,7 +163,6 @@ workflows: requires: - prep-deps - prep-build-test-flask-mv2: - <<: *main_master_rc_only requires: - prep-deps - prep-build-test-mmi: @@ -309,7 +308,6 @@ workflows: - prep-build-test-webpack - prep-build-test-flask - prep-build-test-flask-mv2 - - prep-build-test-mmi - trigger-beta-build - prep-build-storybook - prep-build-ts-migration-dashboard @@ -771,10 +769,10 @@ jobs: name: Build extension for testing command: yarn build:test:flask:mv2 - run: - name: Move test build to 'dist-test-flask' to avoid conflict with production build + name: Move test build to 'dist-test-flask-mv2' to avoid conflict with production build command: mv ./dist ./dist-test-flask-mv2 - run: - name: Move test zips to 'builds-test-flask' to avoid conflict with production build + name: Move test zips to 'builds-test-flask-mv2' to avoid conflict with production build command: mv ./builds ./builds-test-flask-mv2 - persist_to_workspace: root: . @@ -896,10 +894,14 @@ jobs: - run: name: Move test build to 'dist-test-webpack' to avoid conflict with production build command: mv ./dist ./dist-test-webpack + - run: + name: Move test zips to 'builds-test-webpack' to avoid conflict with production build + command: mv ./builds ./builds-test-webpack - persist_to_workspace: root: . paths: - dist-test-webpack + - builds-test-webpack prep-build-storybook: executor: node-linux-medium @@ -1422,8 +1424,6 @@ jobs: path: builds-test-flask - store_artifacts: path: builds-test-flask-mv2 - - store_artifacts: - path: builds-test-mmi - store_artifacts: path: test-artifacts destination: test-artifacts diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index 4f218b4831ba..3752f1c4d1da 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -91,9 +91,6 @@ async function start() { chrome: `${BUILD_LINK_BASE}/builds-test-flask/metamask-flask-chrome-${VERSION}-flask.0.zip`, firefox: `${BUILD_LINK_BASE}/builds-test-flask-mv2/metamask-flask-firefox-${VERSION}-flask.0.zip`, }, - 'builds (test-mmi)': { - chrome: `${BUILD_LINK_BASE}/builds-test-mmi/metamask-mmi-chrome-${VERSION}-mmi.0.zip`, - }, }; const buildContentRows = Object.entries(buildMap).map(([label, builds]) => { From f694c7173313226b3caa62c84c321e308eea3627 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 20 Dec 2024 16:38:16 -0330 Subject: [PATCH 6/7] Remove webpack build link (no zips) --- .circleci/config.yml | 7 ------- development/metamaskbot-build-announce.js | 3 --- 2 files changed, 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 31739328f6e1..8bcd6c44a01a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -305,7 +305,6 @@ workflows: - prep-build-flask-mv2 - prep-build-test - prep-build-test-mv2 - - prep-build-test-webpack - prep-build-test-flask - prep-build-test-flask-mv2 - trigger-beta-build @@ -894,14 +893,10 @@ jobs: - run: name: Move test build to 'dist-test-webpack' to avoid conflict with production build command: mv ./dist ./dist-test-webpack - - run: - name: Move test zips to 'builds-test-webpack' to avoid conflict with production build - command: mv ./builds ./builds-test-webpack - persist_to_workspace: root: . paths: - dist-test-webpack - - builds-test-webpack prep-build-storybook: executor: node-linux-medium @@ -1418,8 +1413,6 @@ jobs: path: builds-test - store_artifacts: path: builds-test-mv2 - - store_artifacts: - path: builds-test-webpack - store_artifacts: path: builds-test-flask - store_artifacts: diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index 3752f1c4d1da..4f1b355a1554 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -84,9 +84,6 @@ async function start() { chrome: `${BUILD_LINK_BASE}/builds-test/metamask-chrome-${VERSION}.zip`, firefox: `${BUILD_LINK_BASE}/builds-test-mv2/metamask-firefox-${VERSION}.zip`, }, - 'builds (test webpack)': { - chrome: `${BUILD_LINK_BASE}/builds-test-webpack/metamask-chrome-${VERSION}.zip`, - }, 'builds (test-flask)': { chrome: `${BUILD_LINK_BASE}/builds-test-flask/metamask-flask-chrome-${VERSION}-flask.0.zip`, firefox: `${BUILD_LINK_BASE}/builds-test-flask-mv2/metamask-flask-firefox-${VERSION}-flask.0.zip`, From de0f2dd12435c5c59604d5525bf107f1d89bafb3 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 20 Dec 2024 17:30:02 -0330 Subject: [PATCH 7/7] Remove beta link --- development/metamaskbot-build-announce.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index 4f1b355a1554..0173206d7a05 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -70,9 +70,6 @@ async function start() { chrome: `${BUILD_LINK_BASE}/builds/metamask-chrome-${VERSION}.zip`, firefox: `${BUILD_LINK_BASE}/builds-mv2/metamask-firefox-${VERSION}.zip`, }, - 'builds (beta)': { - chrome: `${BUILD_LINK_BASE}/builds-beta/metamask-flask-chrome-${VERSION}-beta.0.zip`, - }, 'builds (flask)': { chrome: `${BUILD_LINK_BASE}/builds-flask/metamask-flask-chrome-${VERSION}-flask.0.zip`, firefox: `${BUILD_LINK_BASE}/builds-flask-mv2/metamask-flask-firefox-${VERSION}-flask.0.zip`,