Skip to content

Commit

Permalink
ci: self-hosted runners for benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardBraham committed Jan 29, 2025
1 parent 31e2acc commit 6266945
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 23 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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: Checkout repository
uses: actions/checkout@v4

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

- 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
20 changes: 0 additions & 20 deletions .github/workflows/codespaces.yml

This file was deleted.

43 changes: 42 additions & 1 deletion .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 @@ -16,7 +17,7 @@ on:
jobs:
lint-workflows:
name: Lint workflows
uses: metamask/github-tools/.github/workflows/lint-workflows.yml@c534f265e02af2f2422a3c686bb09a11bfbf4cc2
uses: metamask/github-tools/.github/workflows/lint-workflows.yml@benchmarks

test-lint-shellcheck:
name: Test lint shellcheck
Expand Down Expand Up @@ -62,10 +63,46 @@ jobs:
name: Validate lavamoat policy webapp
uses: ./.github/workflows/validate-lavamoat-policy-webapp.yml

prep-build-test-webpack:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- 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
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 Down Expand Up @@ -106,6 +143,8 @@ 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
Expand All @@ -122,6 +161,8 @@ jobs:
- 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-storybook
- build-beta
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
uses: actions/download-artifact@v4
with:
path: coverage
pattern: coverage-*
merge-multiple: true

- name: Merge coverage reports
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-attributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.LAVAMOAT_UPDATE_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
ACTION_RUN_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
ACTION_RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
3 changes: 2 additions & 1 deletion .github/workflows/wait-for-circleci-workflow-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
done
fi
if [ "$workflow_status" != "success" ]; then
# The "not_run" only happens when you're developing CI workflows and testing weird cases
if [ "$workflow_status" != "success" ] && [ "$workflow_status" != "not_run" ]; then
echo "::error::Workflow status is '$workflow_status'. Exiting with error."
exit 1
fi
5 changes: 5 additions & 0 deletions test/e2e/webdriver/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class ChromeDriver {
args.push('--disable-gpu');
}

// It will crash if you don't do this, but there might be another way around it
if (process.env.GITHUB_ACTION) {
args.push('--no-sandbox');
}

if (isHeadless('SELENIUM')) {
// TODO: Remove notice and consider non-experimental when results are consistent
console.warn(
Expand Down

0 comments on commit 6266945

Please sign in to comment.