Skip to content

[DRAFT] ci: prep builds #61451

[DRAFT] ci: prep builds

[DRAFT] ci: prep builds #61451

Workflow file for this run

name: Main
on:
push:
branches:
- main
- master
- Version-v*
- trigger-ci*
pull_request:
types:
- opened
- reopened
- synchronize
merge_group:
jobs:
prep-deps:
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
cache-node-modules: true
get-changed-files-with-git-diff:
needs: prep-deps
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Get changed files with git diff
run: yarn git-diff-default-branch:github
- name: Upload changed files artifact
uses: actions/upload-artifact@v4
with:
name: changed-files
path: ./changed-files/
lint-workflows:
name: Lint workflows
uses: metamask/github-tools/.github/workflows/lint-workflows.yml@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
test-lint:
needs: prep-deps
uses: ./.github/workflows/test-lint.yml
test-circular-deps:
name: Test circular deps
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Check circular dependencies
run: yarn circular-deps:check
repository-health-checks:
needs: prep-deps
uses: ./.github/workflows/repository-health-checks.yml
test-storybook:
name: Test storybook
needs: prep-deps
uses: ./.github/workflows/test-storybook.yml
validate-lavamoat-policy-build:
needs: prep-deps
uses: ./.github/workflows/validate-lavamoat-policy-build.yml
validate-lavamoat-policy-webapp:
needs: prep-deps
uses: ./.github/workflows/validate-lavamoat-policy-webapp.yml
prep-build-test-browserify:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- run: yarn build:test
- name: Upload artifact prep-build-test-browserify
uses: actions/upload-artifact@v4
with:
name: prep-build-test-browserify
path: ./dist/
prep-build-test-webpack:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- run: yarn webpack --test --no-lavamoat --no-cache --browser=chrome --lockdown --sentry --snow --env production
env:
SEGMENT_PROD_WRITE_KEY: ${{ secrets.SEGMENT_PROD_WRITE_KEY }}
- name: Upload artifact prep-build-test-webpack
uses: actions/upload-artifact@v4
with:
name: prep-build-test-webpack
path: ./dist/
prep-build-test:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- run: yarn build:test
- name: Move test build to dist-test
run: mv ./dist ./dist-test
- name: Move test zips to builds-test
run: mv ./builds ./builds-test
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: builds-test
path: ./builds-test/
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist-test
path: ./dist-test/
prep-build-test-mv2:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- run: yarn build:test:mv2
- name: Move test build to dist-test-mv2
run: mv ./dist ./dist-test-mv2
- name: Move test zips to builds-test-mv2
run: mv ./builds ./builds-test-mv2
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: builds-test-mv2
path: ./builds-test-mv2/
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist-test-mv2
path: ./dist-test-mv2/
prep-build-test-flask:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- run: yarn build:test:flask
- name: Move test build to dist-test-flask
run: mv ./dist ./dist-test-flask
- name: Move test zips to builds-test-flask
run: mv ./builds ./builds-test-flask
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: builds-test-flask
path: ./builds-test-flask/
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist-test-flask
path: ./dist-test-flask/
prep-build-test-flask-mv2:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- run: yarn build:test:flask:mv2
- name: Move test build to dist-test-flask-mv2
run: mv ./dist ./dist-test-flask-mv2
- name: Move test zips to builds-test-flask-mv2
run: mv ./builds ./builds-test-flask-mv2
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: builds-test-flask-mv2
path: ./builds-test-flask-mv2/
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist-test-flask-mv2
path: ./dist-test-flask-mv2/
prep-build-ts-migration-dashboard:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- run: yarn ts-migration:dashboard:build
- name: Upload ts-migration-dashboard
uses: actions/upload-artifact@v4
with:
name: ts-migration-dashboard
path: ./development/ts-migration-dashboard/build/final/
#test-e2e-chrome-webpack:
# needs:
# - prep-build-test-webpack
# - get-changed-files-with-git-diff
# runs-on: ubuntu-22.04
# container:
# image: cimg/node:22.13-browsers
# strategy:
# fail-fast: false
# matrix:
# index:
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
# env:
# MATRIX_INDEX: ${{ matrix.index }}
# MATRIX_TOTAL: 20
# steps:
# - name: Install dependencies
# run: |
# sudo apt-get update && sudo apt-get install zstd
# sudo corepack enable
# shell: bash
#
# - name: Checkout and setup environment
# uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
# with:
# is-high-risk-environment: false
#
# - name: Install anvil (not installed by checkout-and-setup when cache is restored)
# run: yarn foundryup
#
# - name: Download prep-build-test-webpack artifact
# uses: actions/download-artifact@v4
# with:
# name: prep-build-test-webpack
# path: ./dist/
#
# - name: Configure Xvfb
# run: Xvfb -ac :99 -screen 0 1280x1024x16 &
#
# - name: Download changed-files artifact
# continue-on-error: true
# uses: actions/download-artifact@v4
# with:
# name: changed-files
# path: ./changed-files/
#
# - name: Run e2e tests
# run: .github/scripts/test-run-e2e.sh yarn test:e2e:chrome:webpack
# env:
# TIMEOUT: 30
#
# - name: Upload test results and artifacts
# if: always()
# uses: actions/upload-artifact@v4
# with:
# name: test-e2e-chrome-webpack-${{ matrix.index }}
# path: |
# ./test-artifacts
# ./test/test-results/e2e
test-e2e-chrome:
needs:
- prep-build-test
- get-changed-files-with-git-diff
runs-on: ubuntu-22.04
container:
image: cimg/node:22.13-browsers
strategy:
fail-fast: false
matrix:
index:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
env:
MATRIX_INDEX: ${{ matrix.index }}
MATRIX_TOTAL: 20
steps:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install zstd
sudo corepack enable
shell: bash
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Install anvil (not installed by checkout-and-setup when cache is restored)
run: yarn foundryup
- name: Download prep-build-test artifact
uses: actions/download-artifact@v4
with:
name: dist-test
path: ./dist/
- name: Download builds-test artifact
uses: actions/download-artifact@v4
with:
name: builds-test
path: ./builds/
- name: Configure Xvfb
run: Xvfb -ac :99 -screen 0 1280x1024x16 &
- name: Download changed-files artifact
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: changed-files
path: ./changed-files/
- name: Run e2e tests
run: .github/scripts/test-run-e2e.sh yarn test:e2e:chrome
env:
TIMEOUT: 30
- name: Upload test results and artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-e2e-chrome-${{ matrix.index }}
path: |
./test-artifacts
./test/test-results/e2e
test-e2e-chrome-flask:
needs:
- prep-build-test-flask
- get-changed-files-with-git-diff
runs-on: ubuntu-22.04
container:
image: cimg/node:22.13-browsers
strategy:
fail-fast: false
matrix:
index: [0, 1, 2, 3, 4, 5, 6, 7]
env:
MATRIX_INDEX: ${{ matrix.index }}
MATRIX_TOTAL: 8
steps:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install zstd
sudo corepack enable
shell: bash
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Install anvil (not installed by checkout-and-setup when cache is restored)
run: yarn foundryup
- name: Download prep-build-test-flask artifact
uses: actions/download-artifact@v4
with:
name: dist-test-flask
path: ./dist/
- name: Download builds-test-flask artifact
uses: actions/download-artifact@v4
with:
name: builds-test-flask
path: ./builds/
- name: Configure Xvfb
run: Xvfb -ac :99 -screen 0 1280x1024x16 &
- name: Download changed-files artifact
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: changed-files
path: ./changed-files/
- name: Run e2e tests
run: .github/scripts/test-run-e2e.sh yarn test:e2e:chrome:flask
env:
TIMEOUT: 30
- name: Upload test results and artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-e2e-chrome-flask-${{ matrix.index }}
path: |
./test-artifacts
./test/test-results/e2e
test-e2e-chrome-multiple-providers:
needs:
- prep-build-test
- get-changed-files-with-git-diff
runs-on: ubuntu-22.04
container:
image: cimg/node:22.13-browsers
steps:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install zstd
sudo corepack enable
shell: bash
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Install anvil (not installed by checkout-and-setup when cache is restored)
run: yarn foundryup
- name: Download prep-build-test artifact
uses: actions/download-artifact@v4
with:
name: dist-test
path: ./dist/
- name: Download builds-test artifact
uses: actions/download-artifact@v4
with:
name: builds-test
path: ./builds/
- name: Configure Xvfb
run: Xvfb -ac :99 -screen 0 1280x1024x16 &
- name: Download changed-files artifact
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: changed-files
path: ./changed-files/
- name: Run e2e tests
run: .github/scripts/test-run-e2e.sh yarn test:e2e:chrome:multi-provider
env:
TIMEOUT: 30
- name: Upload test results and artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-e2e-chrome-multiple-providers
path: |
./test-artifacts
./test/test-results/e2e
test-e2e-chrome-rpc:
needs:
- prep-build-test
- get-changed-files-with-git-diff
runs-on: ubuntu-22.04
container:
image: cimg/node:22.13-browsers
steps:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install zstd
sudo corepack enable
shell: bash
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Install anvil (not installed by checkout-and-setup when cache is restored)
run: yarn foundryup
- name: Download prep-build-test artifact
uses: actions/download-artifact@v4
with:
name: dist-test
path: ./dist/
- name: Download builds-test artifact
uses: actions/download-artifact@v4
with:
name: builds-test
path: ./builds/
- name: Configure Xvfb
run: Xvfb -ac :99 -screen 0 1280x1024x16 &
- name: Download changed-files artifact
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: changed-files
path: ./changed-files/
- name: Run e2e tests
run: .github/scripts/test-run-e2e.sh yarn test:e2e:chrome:rpc
env:
TIMEOUT: 30
- name: Upload test results and artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-e2e-chrome-rpc
path: |
./test-artifacts
./test/test-results/e2e
prep-build:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Build for non-master branch
if: github.ref != 'refs/heads/master'
run: yarn build dist
env:
INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }}
- name: Build for master branch
if: github.ref == 'refs/heads/master'
run: yarn build prod
env:
INFURA_PROD_PROJECT_ID: ${{ secrets.INFURA_PROD_PROJECT_ID }}
SEGMENT_PROD_WRITE_KEY: ${{ secrets.SEGMENT_PROD_WRITE_KEY }}
- name: Debug build
run: find dist/ -type f -exec md5sum {} \; | sort -k 2
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: builds
path: ./builds/
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist/
prep-build-mv2:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Build for non-master branch
if: github.ref != 'refs/heads/master'
run: ENABLE_MV3=false yarn build dist
env:
INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }}
- name: Build for master branch
if: github.ref == 'refs/heads/master'
run: ENABLE_MV3=false yarn build prod
env:
INFURA_PROD_PROJECT_ID: ${{ secrets.INFURA_PROD_PROJECT_ID }}
SEGMENT_PROD_WRITE_KEY: ${{ secrets.SEGMENT_PROD_WRITE_KEY }}
- name: Debug build
run: find dist/ -type f -exec md5sum {} \; | sort -k 2
- name: Move build to dist-mv2
run: mv ./dist ./dist-mv2
- name: Move zips to builds-mv2
run: mv ./builds ./builds-mv2
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: builds-mv2
path: ./builds-mv2/
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist-mv2
path: ./dist-mv2/
prep-build-flask:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Build for non-master branch
if: github.ref != 'refs/heads/master'
run: yarn build --build-type flask dist
env:
INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }}
- name: Build for master branch
if: github.ref == 'refs/heads/master'
run: yarn build --build-type flask prod
env:
INFURA_FLASK_PROJECT_ID: ${{ secrets.INFURA_FLASK_PROJECT_ID }}
SEGMENT_FLASK_WRITE_KEY: ${{ secrets.SEGMENT_FLASK_WRITE_KEY }}
- name: Debug build
run: find dist/ -type f -exec md5sum {} \; | sort -k 2
- name: Move build to dist-flask
run: mv ./dist ./dist-flask
- name: Move zips to builds-flask
run: mv ./builds ./builds-flask
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: builds-flask
path: ./builds-flask/
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist-flask
path: ./dist-flask/
prep-build-flask-mv2:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: metamask/github-tools/.github/actions/checkout-and-setup@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
with:
is-high-risk-environment: false
- name: Build for non-master branch
if: github.ref != 'refs/heads/master'
run: ENABLE_MV3=false yarn build --build-type flask dist
env:
INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }}
- name: Build for master branch
if: github.ref == 'refs/heads/master'
run: ENABLE_MV3=false yarn build --build-type flask prod
env:
INFURA_FLASK_PROJECT_ID: ${{ secrets.INFURA_FLASK_PROJECT_ID }}
SEGMENT_FLASK_WRITE_KEY: ${{ secrets.SEGMENT_FLASK_WRITE_KEY }}
- name: Debug build
run: find dist/ -type f -exec md5sum {} \; | sort -k 2
- name: Move build to dist-flask-mv2
run: mv ./dist ./dist-flask-mv2
- name: Move zips to builds-flask-mv2
run: mv ./builds ./builds-flask-mv2
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: builds-flask-mv2
path: ./builds-flask-mv2/
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist-flask-mv2
path: ./dist-flask-mv2/
run-tests:
name: Run tests
needs: prep-deps
uses: ./.github/workflows/run-tests.yml
run-benchmarks:
uses: ./.github/workflows/run-benchmarks.yml
needs:
- prep-build-test-browserify
- prep-build-test-webpack
wait-for-circleci-workflow-status:
name: Wait for CircleCI workflow status
uses: ./.github/workflows/wait-for-circleci-workflow-status.yml
runway:
name: Runway
# For a `pull_request` event, the branch is `github.head_ref``.
# For a `push` event, the branch is `github.ref_name`.
if: ${{ startsWith(github.head_ref || github.ref_name, 'Version-v') }}
needs:
- wait-for-circleci-workflow-status
uses: ./.github/workflows/runway.yml
build-storybook:
name: Build storybook
uses: ./.github/workflows/build-storybook.yml
secrets:
STORYBOOK_TOKEN: ${{ secrets.STORYBOOK_TOKEN }}
permissions:
contents: read
# id-token permission is required for uploading to s3
id-token: write
build-beta:
name: Build beta
uses: ./.github/workflows/build-beta.yml
permissions:
contents: read
# id-token permission is required for uploading to s3
id-token: write
publish-prerelease:
name: Publish prerelease
if: ${{ github.event_name == 'pull_request' }}
needs:
- wait-for-circleci-workflow-status
- build-storybook
- build-beta
uses: ./.github/workflows/publish-prerelease.yml
secrets:
PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }}
# Explanation for all-jobs-completed and all-jobs-pass being separate:
# https://github.com/MetaMask/metamask-module-template/pull/151
all-jobs-completed:
name: All jobs completed
runs-on: ubuntu-latest
needs:
- lint-workflows
- test-lint
- repository-health-checks
- test-storybook
- validate-lavamoat-policy-build
- validate-lavamoat-policy-webapp
- run-tests
- wait-for-circleci-workflow-status
- build-storybook
- build-beta
- prep-build
- prep-build-mv2
- prep-build-flask
- prep-build-flask-mv2
- prep-build-test
- prep-build-test-mv2
- prep-build-test-flask
- prep-build-test-flask-mv2
- prep-build-ts-migration-dashboard
- prep-build-test-browserify
- prep-build-test-webpack
- get-changed-files-with-git-diff
- test-e2e-chrome
- test-e2e-chrome-flask
- test-e2e-chrome-multiple-providers
- test-e2e-chrome-rpc
outputs:
PASSED: ${{ steps.set-output.outputs.PASSED }}
steps:
- name: Set PASSED output
id: set-output
run: echo "PASSED=true" >> "$GITHUB_OUTPUT"
all-jobs-pass:
name: All jobs pass
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- all-jobs-completed
steps:
- name: Check that all jobs have passed
run: |
passed="${{ needs.all-jobs-completed.outputs.PASSED }}"
if [[ $passed != "true" ]]; then
exit 1
fi
log-merge-group-failure:
name: Log merge group failure
# Only run this job if the merge group event fails, skip on forks
if: ${{ github.event_name == 'merge_group' && failure() && !github.event.repository.fork }}
needs:
- all-jobs-pass
uses: metamask/github-tools/.github/workflows/log-merge-group-failure.yml@6bbad335a01fce1a9ec1eabd9515542c225d46c0
secrets:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
SPREADSHEET_ID: ${{ secrets.GOOGLE_MERGE_QUEUE_SPREADSHEET_ID }}
SHEET_NAME: ${{ secrets.GOOGLE_MERGE_QUEUE_SHEET_NAME }}