From 2edee26a556735db266d7d00c476cf1c66900b7b Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 20 Dec 2024 18:58:06 -0330 Subject: [PATCH] WIP --- .circleci/config.yml | 4 --- .github/workflows/build-lavamoat-viz.yml | 23 ++++++++++++++ .github/workflows/main.yml | 2 -- .github/workflows/publish-prerelease.yml | 31 +++++++++++++++++++ .../create-lavamoat-viz.sh | 0 development/metamaskbot-build-announce.js | 4 ++- 6 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build-lavamoat-viz.yml rename {.circleci/scripts => development}/create-lavamoat-viz.sh (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 61493189a8b6..037ecd9126ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1413,10 +1413,6 @@ jobs: - store_artifacts: path: test-artifacts destination: test-artifacts - # important: generate lavamoat viz AFTER uploading builds as artifacts - - run: - name: build:lavamoat-viz - command: ./.circleci/scripts/create-lavamoat-viz.sh - store_artifacts: path: build-artifacts destination: build-artifacts diff --git a/.github/workflows/build-lavamoat-viz.yml b/.github/workflows/build-lavamoat-viz.yml new file mode 100644 index 000000000000..505dbcc7709a --- /dev/null +++ b/.github/workflows/build-lavamoat-viz.yml @@ -0,0 +1,23 @@ +name: Build LavaMoat visualization + +on: + workflow_call: + +jobs: + build-lavamoat-viz: + name: Build LavaMoat visualization + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup environment + uses: metamask/github-tools/.github/actions/setup-environment@main + + - name: Build LavaMoat visualization + run: ./development/create-lavamoat-viz.sh + + - uses: actions/upload-artifact@v4 + with: + name: lavamoat-build-viz + path: ./build-artifacts/build-viz/ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2b64d6379825..26d07e840bcb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,8 +67,6 @@ jobs: publish-prerelease: name: Publish prerelease if: ${{ github.event_name == 'pull_request' }} - needs: - - wait-for-circleci-workflow-status uses: ./.github/workflows/publish-prerelease.yml secrets: PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }} diff --git a/.github/workflows/publish-prerelease.yml b/.github/workflows/publish-prerelease.yml index 9b4e460d546a..3e21e631415e 100644 --- a/.github/workflows/publish-prerelease.yml +++ b/.github/workflows/publish-prerelease.yml @@ -7,8 +7,32 @@ on: required: true jobs: + lavamoat-build-viz: + name: Build LavaMoat build visualization + runs-on: ubuntu-latest + outputs: + ARTIFACT_ID: ${{ steps.artifact-upload-step.outputs.artifact-id }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup environment + uses: metamask/github-tools/.github/actions/setup-environment@main + + - name: Build LavaMoat visualization + run: ./development/create-lavamoat-viz.sh + env: + INFURA_PROJECT_ID: 00000000000 + + - uses: actions/upload-artifact@v4 + id: artifact-upload-step + with: + name: lavamoat-build-viz + path: ./build-artifacts/build-viz/ + publish-prerelease: name: Publish prerelease + needs: lavamoat-build-viz runs-on: ubuntu-latest steps: - name: Checkout repository @@ -61,6 +85,12 @@ jobs: mkdir "storybook-build" echo "${stories}" > "storybook-build/stories.json" + - name: Download LavaMoat build visualization + uses: actions/download-artifact@v4 + with: + name: lavamoat-build-viz + path: ./build-artifacts/build-viz/ + - name: Publish prerelease env: PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }} @@ -69,4 +99,5 @@ jobs: MERGE_BASE_COMMIT_HASH: ${{ steps.get-merge-base.outputs.MERGE_BASE }} CIRCLE_BUILD_NUM: ${{ steps.get-circleci-job-details.outputs.CIRCLE_BUILD_NUM }} CIRCLE_WORKFLOW_JOB_ID: ${{ steps.get-circleci-job-details.outputs.CIRCLE_WORKFLOW_JOB_ID }} + LAVAMOAT_BUILD_VIZ_ID: ${{needs.lavamoat-build-viz.outputs.ARTIFACT_ID}} run: ./development/metamaskbot-build-announce.js diff --git a/.circleci/scripts/create-lavamoat-viz.sh b/development/create-lavamoat-viz.sh similarity index 100% rename from .circleci/scripts/create-lavamoat-viz.sh rename to development/create-lavamoat-viz.sh diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index d449c8ce7259..65911f73d9e4 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -58,6 +58,7 @@ async function start() { MERGE_BASE_COMMIT_HASH, CIRCLE_BUILD_NUM, CIRCLE_WORKFLOW_JOB_ID, + LAVAMOAT_BUILD_VIZ_ID, } = process.env; console.log('PR_NUMBER', PR_NUMBER); @@ -65,6 +66,7 @@ async function start() { console.log('MERGE_BASE_COMMIT_HASH', MERGE_BASE_COMMIT_HASH); console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM); console.log('CIRCLE_WORKFLOW_JOB_ID', CIRCLE_WORKFLOW_JOB_ID); + console.log('LAVAMOAT_BUILD_VIZ_ID', LAVAMOAT_BUILD_VIZ_ID); if (!PR_NUMBER) { console.warn(`No pull request detected for commit "${HEAD_COMMIT_HASH}"`); @@ -165,7 +167,7 @@ async function start() { const tsMigrationDashboardLink = `Dashboard`; // links to bundle browser builds - const depVizUrl = `${BUILD_LINK_BASE}/build-artifacts/build-viz/index.html`; + const depVizUrl = `https://api.github.com/repos/MetaMask/metamask-extension/actions/artifacts/${LAVAMOAT_BUILD_VIZ_ID}/zip`; const depVizLink = `Build System`; const moduleInitStatsBackgroundUrl = `${BUILD_LINK_BASE}/test-artifacts/chrome/initialisation/background/index.html`; const moduleInitStatsBackgroundLink = `Background Module Init Stats`;