Skip to content

Test if adding mdast-util-to-hast to allow list fixes security updat… #4616

Test if adding mdast-util-to-hast to allow list fixes security updat…

Test if adding mdast-util-to-hast to allow list fixes security updat… #4616

name: Performance Metrics Comparison
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches: [trunk]
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions: {}
jobs:
metrics:
name: Run metrics tests
# Skip performance metrics on draft PRs to save CI resources
# Tests will run automatically when PR is marked ready for review
if: github.event_name == 'push' || github.event.pull_request.draft == false
runs-on: macos-15
permissions:
contents: read
pull-requests: write
env:
ARTIFACTS_PATH: ${{ github.workspace }}/artifacts
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORCE_COLOR: '1'
CODEVITALS_AUTH_TOKEN: ${{ secrets.CODEVITALS_AUTH_TOKEN }}
SKIP_WORKER_THREAD_BUILD: 'true'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- name: Compare performance with trunk
if: github.event_name == 'pull_request'
run: cd scripts/compare-perf && npm ci && npm run compare -- perf $GITHUB_SHA trunk --tests-branch $GITHUB_SHA --rounds 3
- name: Post performance results to PR
if: github.event_name == 'pull_request' && !cancelled()
run: |
cd scripts/compare-perf
npm run post-to-github -- $GITHUB_TOKEN ${{ github.repository }} ${{ github.event.pull_request.number }} trunk $GITHUB_SHA
- name: Compare performance with base branch
if: github.event_name == 'push'
# The base hash used here need to be a commit that is compatible with the current performance tests.
# The current one is 58c52bfee7e585614ced202f43f217a01f94f029
# it needs to be updated every time it becomes unsupported by the current performance tests.
# It is used as a base comparison point to avoid fluctuation in the performance metrics.
run: |
cd scripts/compare-perf && npm ci && npm run compare -- perf $GITHUB_SHA 58c52bfee7e585614ced202f43f217a01f94f029 --tests-branch $GITHUB_SHA --rounds 3
# Log performance metrics to CodeVitals when running on trunk
- name: Log performance metrics to CodeVitals
if: github.event_name == 'push' && github.ref == 'refs/heads/trunk' && !cancelled()
run: |
COMMITTED_AT=$(git show -s $GITHUB_SHA --format="%cI")
npm ci && cd scripts/compare-perf && npm run log-to-codevitals -- $CODEVITALS_AUTH_TOKEN trunk $GITHUB_SHA 58c52bfee7e585614ced202f43f217a01f94f029 $COMMITTED_AT
- name: Archive performance results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v6
with:
name: performance-results
path: ${{ env.ARTIFACTS_PATH }}