Skip to content

Commit c9f1e1e

Browse files
committed
ci: self-hosted runners for benchmarks
1 parent 08365f0 commit c9f1e1e

7 files changed

+94
-23
lines changed

.github/workflows/benchmarks.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
name:
5+
required: true
6+
type: string
7+
command:
8+
required: true
9+
type: string
10+
11+
jobs:
12+
benchmarks:
13+
name: ${{ inputs.name }}
14+
runs-on: gha-mm-scale-set-ubuntu-22.04-amd64-med
15+
container:
16+
image: cimg/node:22.13-browsers
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup environment
22+
uses: metamask/github-tools/.github/actions/setup-environment@benchmarks
23+
24+
- name: Download artifact prep-build-test-webpack
25+
uses: actions/download-artifact@v4
26+
with:
27+
path: ./dist/
28+
pattern: prep-build-test-webpack
29+
merge-multiple: true
30+
31+
# Xvfb initializes a virtual "screen" where the browser opens
32+
- name: Configure Xvfb
33+
run: Xvfb -ac :99 -screen 0 1280x1024x16 &
34+
35+
- name: Run the benchmark
36+
run: ${{ inputs.command }}
37+
38+
- name: Upload Artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: ${{ inputs.name }}
42+
path: test-artifacts/chrome/benchmark/
43+
retention-days: 5

.github/workflows/codespaces.yml

-20
This file was deleted.

.github/workflows/main.yml

+42-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- master
88
- Version-v*
9+
- trigger-ci*
910
pull_request:
1011
types:
1112
- opened
@@ -16,7 +17,7 @@ on:
1617
jobs:
1718
lint-workflows:
1819
name: Lint workflows
19-
uses: metamask/github-tools/.github/workflows/lint-workflows.yml@c534f265e02af2f2422a3c686bb09a11bfbf4cc2
20+
uses: metamask/github-tools/.github/workflows/lint-workflows.yml@benchmarks
2021

2122
test-lint-shellcheck:
2223
name: Test lint shellcheck
@@ -62,10 +63,46 @@ jobs:
6263
name: Validate lavamoat policy webapp
6364
uses: ./.github/workflows/validate-lavamoat-policy-webapp.yml
6465

66+
prep-build-test-webpack:
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
72+
- name: Setup environment
73+
uses: metamask/github-tools/.github/actions/setup-environment@main
74+
75+
- run: yarn webpack --test --no-lavamoat --no-cache --browser=chrome --lockdown --sentry --snow --env production
76+
env:
77+
SEGMENT_PROD_WRITE_KEY: '-' # A fake key just to make the build succeed
78+
79+
- name: Upload artifact prep-build-test-webpack
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: prep-build-test-webpack
83+
path: ./dist/
84+
retention-days: 1
85+
6586
run-tests:
6687
name: Run tests
6788
uses: ./.github/workflows/run-tests.yml
6889

90+
run-pageload-benchmark:
91+
name: Run Benchmarks # So that the level 1 name will be "Run Benchmarks" in the GitHub Actions UI
92+
needs: prep-build-test-webpack
93+
uses: ./.github/workflows/benchmarks.yml
94+
with:
95+
name: run-pageload-benchmark # The level 2 name
96+
command: 'yarn benchmark:chrome --out test-artifacts/chrome/benchmark/pageload.json --retries 2'
97+
98+
run-user-actions-benchmark:
99+
name: Run Benchmarks # So that the level 1 name will be "Run Benchmarks" in the GitHub Actions UI
100+
needs: prep-build-test-webpack
101+
uses: ./.github/workflows/benchmarks.yml
102+
with:
103+
name: run-user-actions-benchmark # The level 2 name
104+
command: 'yarn user-actions-benchmark:chrome --out test-artifacts/chrome/benchmark/user_actions.json --retries 2'
105+
69106
wait-for-circleci-workflow-status:
70107
name: Wait for CircleCI workflow status
71108
uses: ./.github/workflows/wait-for-circleci-workflow-status.yml
@@ -106,6 +143,8 @@ jobs:
106143
secrets:
107144
PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }}
108145

146+
# Explanation for all-jobs-completed and all-jobs-pass being separate:
147+
# https://github.com/MetaMask/metamask-module-template/pull/151
109148
all-jobs-completed:
110149
name: All jobs completed
111150
runs-on: ubuntu-latest
@@ -122,6 +161,8 @@ jobs:
122161
- validate-lavamoat-policy-build
123162
- validate-lavamoat-policy-webapp
124163
- run-tests
164+
# - run-pageload-benchmark # Will enable this as a required job in a later PR
165+
# - run-user-actions-benchmark # Will enable this as a required job in a later PR
125166
- wait-for-circleci-workflow-status
126167
- build-storybook
127168
- build-beta

.github/workflows/run-tests.yml

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
uses: actions/download-artifact@v4
9999
with:
100100
path: coverage
101+
pattern: coverage-*
101102
merge-multiple: true
102103

103104
- name: Merge coverage reports

.github/workflows/update-attributions.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,4 @@ jobs:
182182
env:
183183
GITHUB_TOKEN: ${{ secrets.LAVAMOAT_UPDATE_TOKEN }}
184184
PR_NUMBER: ${{ github.event.issue.number }}
185-
ACTION_RUN_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
185+
ACTION_RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'

.github/workflows/wait-for-circleci-workflow-status.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
done
3131
fi
3232
33-
if [ "$workflow_status" != "success" ]; then
33+
# The "not_run" only happens when you're developing CI workflows and testing weird cases
34+
if [ "$workflow_status" != "success" ] && [ "$workflow_status" != "not_run" ]; then
3435
echo "::error::Workflow status is '$workflow_status'. Exiting with error."
3536
exit 1
3637
fi

test/e2e/webdriver/chrome.js

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class ChromeDriver {
6161
args.push('--disable-gpu');
6262
}
6363

64+
// It will crash if you don't do this, but there might be another way around it
65+
if (process.env.GITHUB_ACTION) {
66+
args.push('--no-sandbox');
67+
}
68+
6469
if (isHeadless('SELENIUM')) {
6570
// TODO: Remove notice and consider non-experimental when results are consistent
6671
console.warn(

0 commit comments

Comments
 (0)