Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/actions/page-load-benchmark-comment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Page load benchmark comment'
description: 'Download benchmark results, create directory structure, and comment on PR'
inputs:
head-commit-hash:
description: 'The head commit hash to pass to the benchmark comment script'
required: true
pr-comment-token:
description: 'GitHub token for commenting on PR'
required: true
runs:
using: 'composite'
steps:
- name: Download page load benchmark results
uses: actions/download-artifact@v4
with:
name: benchmark-results

- name: Create expected page load benchmark results directory structure
shell: bash
run: |
mkdir -p test-artifacts/benchmarks
mv benchmark-results.json test-artifacts/benchmarks/benchmark-results.json
- name: Page load benchmark compare and comment
shell: bash
run: yarn tsx development/page-load-benchmark-pr-comment.ts
env:
PR_COMMENT_TOKEN: ${{ inputs.pr-comment-token }}
OWNER: ${{ github.repository_owner }}
REPOSITORY: ${{ github.event.repository.name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
HEAD_COMMIT_HASH: ${{ inputs.head-commit-hash }}
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ jobs:
s3-bucket: ${{ vars.AWS_S3_BUCKET }}/${{ github.event.repository.name }}/${{ github.run_id }}/bundle-size
path: test-artifacts/chrome

benchmark-pr:
page-load-benchmark-pr:
needs:
- build-dist-browserify
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref_name == 'main') }}
uses: ./.github/workflows/benchmark-pr.yml
uses: ./.github/workflows/page-load-benchmark-pr.yml
with:
browser-loads: '10'
page-loads: '10'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Benchmark PR Performance
name: Page load benchmark

on:
workflow_call:
Expand All @@ -20,7 +20,7 @@ on:
required: true

jobs:
benchmark-pr:
page-load-benchmark-pr:
name: Run Page Load Benchmarks
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -48,17 +48,13 @@ jobs:
- name: Run page load benchmarks
run: yarn test:e2e:benchmark

- name: Compare and comment
if: ${{ github.event_name == 'pull_request' }}
run: yarn tsx development/benchmark-pr-comment.ts
env:
PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPOSITORY: ${{ github.event.repository.name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_SHA: ${{ github.event.pull_request.head.sha }}
- name: Upload benchmark results (github artifacts)
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: test-artifacts/benchmarks/benchmark-results.json

- name: Upload benchmark results
- name: Upload benchmark results (historical data)
if: github.ref == 'refs/heads/main'
run: .github/scripts/benchmark-stats-commit.sh
env:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ jobs:
echo "MERGE_BASE_COMMIT_HASH=${merge_base_commit_hash}" >> "${GITHUB_ENV}"
echo "The merge base commit hash is '${merge_base_commit_hash}'"

- name: Page load benchmark comment
if: ${{ github.event_name == 'pull_request' }}
uses: ./.github/actions/page-load-benchmark-comment
with:
head-commit-hash: ${{ env.HEAD_COMMIT_HASH }}
pr-comment-token: ${{ secrets.PR_COMMENT_TOKEN }}

- name: Publish prerelease
if: ${{ env.MERGE_BASE_COMMIT_HASH && env.PR_NUMBER && env.PR_COMMENT_TOKEN && vars.AWS_CLOUDFRONT_URL }}
run: yarn tsx ./development/metamaskbot-build-announce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ function generateBenchmarkComment(
* @throws {Error} When GitHub API request fails or required environment variables are missing
*/
async function main(): Promise<void> {
const { PR_COMMENT_TOKEN, OWNER, REPOSITORY, PR_NUMBER } =
const { PR_COMMENT_TOKEN, OWNER, REPOSITORY, PR_NUMBER, HEAD_COMMIT_HASH } =
process.env as Record<string, string>;
const N_COMMITS = 10;

Expand Down Expand Up @@ -568,6 +568,7 @@ async function main(): Promise<void> {
return;
}

benchmarkData.commit = HEAD_COMMIT_HASH;
const referenceData = await fetchLatestMainBenchmarkData(N_COMMITS);

const commentBody = generateBenchmarkComment(benchmarkData, referenceData);
Expand Down
Loading