Skip to content

Commit

Permalink
ci: self-hosted runners for benchmarks, with a new prep-deps workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardBraham committed Jan 29, 2025
1 parent 2cf7e67 commit e5a4333
Show file tree
Hide file tree
Showing 26 changed files with 222 additions and 263 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/add-release-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ jobs:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
fetch-depth: 0 # This is needed to checkout all branches

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main

- name: Get the next semver version
id: get-next-semver-version
env:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
workflow_call:
inputs:
name:
required: true
type: string
command:
required: true
type: string

jobs:
benchmarks:
name: ${{ inputs.name }}
runs-on: gha-mm-scale-set-ubuntu-22.04-amd64-med
container:
image: cimg/node:22.13-browsers
steps:
- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
should-cache-restore: ${{ vars.USE_CACHING }}

- name: Download artifact prep-build-test-webpack
uses: actions/download-artifact@v4
with:
path: ./dist/
pattern: prep-build-test-webpack
merge-multiple: true

# Xvfb initializes a virtual "screen" where the browser opens
- name: Configure Xvfb
run: Xvfb -ac :99 -screen 0 1280x1024x16 &

- name: Run the benchmark
run: ${{ inputs.command }}

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}
path: test-artifacts/chrome/benchmark/
retention-days: 5
4 changes: 3 additions & 1 deletion .github/workflows/build-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ jobs:
- name: Setup environment
if: ${{ steps.needs-beta-build.outputs.NEEDS_BETA_BUILD == 'true' }}
uses: metamask/github-tools/.github/actions/setup-environment@main
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
no-cache-for-release: 'true' # Turn off yarn cache as well

- name: Run beta build
if: ${{ steps.needs-beta-build.outputs.NEEDS_BETA_BUILD == 'true' }}
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/check-attributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ jobs:
check-attributions:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main
uses: metamask/github-tools/.github/actions/setup-environment@caching

- name: Check attributions changes
run: yarn attributions:check
5 changes: 1 addition & 4 deletions .github/workflows/check-pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ jobs:
pull-requests: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main
uses: metamask/github-tools/.github/actions/setup-environment@caching

- name: Check PR has required labels
env:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/check-template-and-add-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ jobs:
check-template-and-add-labels:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main
uses: metamask/github-tools/.github/actions/setup-environment@caching

- name: Check template and add labels
id: check-template-and-add-labels
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/close-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ jobs:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'Version-v')
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main
uses: metamask/github-tools/.github/actions/setup-environment@caching

- name: Close release bug report issue
env:
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/codespaces.yml

This file was deleted.

7 changes: 2 additions & 5 deletions .github/workflows/fitness-functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
fetch-depth: 0 # This is needed to checkout all branches

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main

- name: Run fitness functions
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
Expand Down
103 changes: 64 additions & 39 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
- master
- Version-v*
- trigger-ci.*
pull_request:
types:
- opened
Expand All @@ -14,54 +15,79 @@ on:
merge_group:

jobs:
prep-deps:
runs-on: ubuntu-latest
steps:
- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
should-cache-restore: 'false'
should-cache-save: ${{ vars.USE_CACHING }}
# -- If you're a repo admin, you can change vars.USE_CACHING at:
# https://github.com/MetaMask/metamask-extension/settings/variables/actions
# -- If you're just a contributor, you can change vars.USE_CACHING by following this documentation:
# https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-a-repository-variable

lint-workflows:
name: Lint workflows
uses: metamask/github-tools/.github/workflows/lint-workflows.yml@c534f265e02af2f2422a3c686bb09a11bfbf4cc2

test-lint-shellcheck:
name: Test lint shellcheck
uses: ./.github/workflows/test-lint-shellcheck.yml
uses: metamask/github-tools/.github/workflows/lint-workflows.yml@caching

test-lint:
name: Test lint
needs: prep-deps
uses: ./.github/workflows/test-lint.yml

test-lint-changelog:
name: Test lint changelog
uses: ./.github/workflows/test-lint-changelog.yml

test-lint-lockfile:
name: Test lint lockfile
uses: ./.github/workflows/test-lint-lockfile.yml

test-deps-audit:
name: Test deps audit
uses: ./.github/workflows/test-deps-audit.yml

test-yarn-dedupe:
name: Test yarn dedupe
uses: ./.github/workflows/test-yarn-dedupe.yml

test-deps-depcheck:
name: Test deps depcheck
uses: ./.github/workflows/test-deps-depcheck.yml

validate-lavamoat-allow-scripts:
name: Validate lavamoat allow scripts
uses: ./.github/workflows/validate-lavamoat-allow-scripts.yml
test-short-suite:
needs: prep-deps
uses: ./.github/workflows/test-short-suite.yml

validate-lavamoat-policy-build:
name: Validate lavamoat policy build
needs: prep-deps
uses: ./.github/workflows/validate-lavamoat-policy-build.yml

validate-lavamoat-policy-webapp:
name: Validate lavamoat policy webapp
needs: prep-deps
uses: ./.github/workflows/validate-lavamoat-policy-webapp.yml

prep-build-test-webpack:
needs: prep-deps
runs-on: ubuntu-latest
steps:
- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
should-cache-restore: ${{ vars.USE_CACHING }}

- run: yarn webpack --test --no-lavamoat --no-cache --browser=chrome --lockdown --sentry --snow --env production
env:
SEGMENT_PROD_WRITE_KEY: '-' # A fake key just to make the build succeed

- name: Upload artifact prep-build-test-webpack
uses: actions/upload-artifact@v4
with:
name: prep-build-test-webpack
path: ./dist/
retention-days: 1

run-tests:
name: Run tests
needs: prep-deps
uses: ./.github/workflows/run-tests.yml

run-pageload-benchmark:
name: Run Benchmarks # So that the level 1 name will be "Run Benchmarks" in the GitHub Actions UI
needs: prep-build-test-webpack
uses: ./.github/workflows/benchmarks.yml
with:
name: run-pageload-benchmark # The level 2 name
command: 'yarn benchmark:chrome --out test-artifacts/chrome/benchmark/pageload.json --retries 2'

run-user-actions-benchmark:
name: Run Benchmarks # So that the level 1 name will be "Run Benchmarks" in the GitHub Actions UI
needs: prep-build-test-webpack
uses: ./.github/workflows/benchmarks.yml
with:
name: run-user-actions-benchmark # The level 2 name
command: 'yarn user-actions-benchmark:chrome --out test-artifacts/chrome/benchmark/user_actions.json --retries 2'

wait-for-circleci-workflow-status:
name: Wait for CircleCI workflow status
uses: ./.github/workflows/wait-for-circleci-workflow-status.yml
Expand All @@ -76,7 +102,7 @@ jobs:
uses: ./.github/workflows/runway.yml

build-beta:
name: Build beta
needs: prep-deps
uses: ./.github/workflows/build-beta.yml
permissions:
contents: read
Expand All @@ -92,21 +118,20 @@ jobs:
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-shellcheck
- test-lint
- test-lint-changelog
- test-lint-lockfile
- test-yarn-dedupe
- test-deps-depcheck
- validate-lavamoat-allow-scripts
- test-short-suite
- validate-lavamoat-policy-build
- validate-lavamoat-policy-webapp
- run-tests
# - run-pageload-benchmark # Will enable this as a required job in a later PR
# - run-user-actions-benchmark # Will enable this as a required job in a later PR
- wait-for-circleci-workflow-status
- build-beta
outputs:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ jobs:
name: Publish prerelease
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
fetch-depth: 0 # This is needed to get merge base to calculate bundle size diff

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main
no-cache-for-release: 'true' # Turn off yarn cache as well

- name: Get merge base commit hash
id: get-merge-base
Expand Down
29 changes: 13 additions & 16 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ jobs:
matrix:
shard: [1, 2, 3, 4, 5, 6]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
should-cache-restore: ${{ vars.USE_CACHING }}

- name: test:unit:coverage
run: yarn test:unit:coverage --shard=${{ matrix.shard }}/${{ strategy.job-total }}
Expand All @@ -39,11 +38,10 @@ jobs:
name: Webpack tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
should-cache-restore: ${{ vars.USE_CACHING }}

- name: test:unit:webpack:coverage
run: yarn test:unit:webpack:coverage
Expand All @@ -60,11 +58,10 @@ jobs:
name: Integration tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
should-cache-restore: ${{ vars.USE_CACHING }}

- name: test:integration:coverage
run: yarn test:integration:coverage
Expand All @@ -88,16 +85,16 @@ jobs:
current-coverage: ${{ steps.get-current-coverage.outputs.CURRENT_COVERAGE }}
stored-coverage: ${{ steps.get-stored-coverage.outputs.STORED_COVERAGE }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main
uses: metamask/github-tools/.github/actions/setup-environment@caching
with:
should-cache-restore: ${{ vars.USE_CACHING }}

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: coverage
pattern: coverage-*
merge-multiple: true

- name: Merge coverage reports
Expand Down
Loading

0 comments on commit e5a4333

Please sign in to comment.