Skip to content

Performance E2E Tests for Release Builds #9250

Performance E2E Tests for Release Builds

Performance E2E Tests for Release Builds #9250

name: Performance E2E Tests for Release Builds
on:
schedule:
- cron: '*/30 * * * *' # Every 30 minutes to check for metamaskbot commits
workflow_dispatch:
inputs:
sentry_target:
description: 'Sentry target for performance events (test or real)'
required: false
type: choice
options:
- test
- real
default: test
push:
branches:
- 'release/*'
# Required so the reusable workflow run-performance-e2e.yml can use id-token and actions
permissions:
contents: read
id-token: write
actions: write
jobs:
check-release-trigger:
name: Check if Release Performance Tests Should Run
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.check.outputs.should-run }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check release trigger conditions
id: check
run: |
# Always run for manual dispatch or release branch pushes
if [[ "${{ github.event_name }}" == "workflow_dispatch" || ("${{ github.event_name }}" == "push" && "${{ github.ref_name }}" =~ ^release/) ]]; then
echo "should-run=true" >> "$GITHUB_OUTPUT"
echo "Performance tests triggered by ${{ github.event_name }}"
# For scheduled runs, check for recent metamaskbot version bumps
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
git fetch --all
# Get the most recent metamaskbot version bump commit
RECENT_VERSION_BUMP=$(git log --oneline --grep="Bump version number" --author="metamaskbot" --since="2 hours ago" --all | head -1)
if [[ -n "$RECENT_VERSION_BUMP" ]]; then
# Extract the commit hash
COMMIT_HASH=$(echo "$RECENT_VERSION_BUMP" | cut -d' ' -f1)
# Check if the commit message contains "Bump version number" (ignore [skip ci])
COMMIT_MESSAGE=$(git log -1 --format="%s" "$COMMIT_HASH")
if [[ "$COMMIT_MESSAGE" =~ "Bump version number" ]]; then
# Check if we've already processed this commit by looking for a workflow run with this commit
# We'll use a simple approach: check if the commit is from the last 30 minutes
COMMIT_TIME=$(git log -1 --format="%ct" "$COMMIT_HASH")
CURRENT_TIME=$(date +%s)
TIME_DIFF=$((CURRENT_TIME - COMMIT_TIME))
# Only run if the commit is from the last 30 minutes (to avoid re-running the same commit)
if [[ $TIME_DIFF -lt 1800 ]]; then
echo "should-run=true" >> "$GITHUB_OUTPUT"
echo "Recent metamaskbot version bump found (within last 30 min): $RECENT_VERSION_BUMP"
echo "Commit message: $COMMIT_MESSAGE"
else
echo "should-run=false" >> "$GITHUB_OUTPUT"
echo "Metamaskbot version bump found but older than 30 minutes: $RECENT_VERSION_BUMP"
fi
else
echo "should-run=false" >> "$GITHUB_OUTPUT"
echo "Metamaskbot commit found but not a version bump: $RECENT_VERSION_BUMP"
echo "Commit message: $COMMIT_MESSAGE"
fi
else
echo "should-run=false" >> "$GITHUB_OUTPUT"
echo "No recent metamaskbot version bumps found"
fi
else
echo "should-run=false" >> "$GITHUB_OUTPUT"
fi
run-performance-e2e-release:
name: Run Performance E2E Tests for Release Builds
uses: ./.github/workflows/run-performance-e2e.yml
needs: [check-release-trigger]
if: needs.check-release-trigger.outputs.should-run == 'true'
with:
sentry_target: ${{ inputs.sentry_target || 'test' }}
secrets: inherit