Monitor Metrics #388
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Monitor Metrics | |
on: | |
schedule: | |
- cron: '0 2 * * *' | |
workflow_dispatch: | |
jobs: | |
monitor: | |
continue-on-error: true | |
strategy: | |
matrix: | |
include: | |
- product: RSBUILD | |
- product: RSPRESS | |
- product: RSLIB | |
- product: MODERNJS_FRAMEWORK | |
- product: MODERNJS_MODULE | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache-dependency-path: pnpm-lock.yaml | |
- name: Install Pnpm | |
run: corepack enable && pnpm -v && pnpm store path | |
- name: Install Dependencies | |
run: pnpm run install:scripts | |
- name: Build Scripts | |
run: cd scripts && pnpm run build | |
- name: Monitor Metrics | |
id: monitor | |
run: | | |
result=$(cd scripts && MONITOR=1 node ./dist/compare.js ${{ matrix.product }}) | |
echo "$result" | |
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT | |
if [[ $result =~ "Threshold exceeded" ]]; then | |
echo "Some benchmark metrics exceed the threshold, please visit the previous step for more information" | |
exit 1 | |
fi | |
- name: Create Issue on Failure | |
if: failure() | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }} | |
script: | | |
const diffResult = `${{ steps.monitor.outputs.diff-result }}` | |
let result = "task ${{ steps.monitor.outputs.result }}" | |
if (diffResult) { | |
result = diffResult.replace(/@@/g, "\n"); | |
} | |
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` | |
const urlLink = `[Open](${url})` | |
const date = new Date(); | |
const year = date.getFullYear(); | |
const month = ('0' + (date.getMonth() + 1)).slice(-2); | |
const day = ('0' + date.getDate()).slice(-2); | |
const today = `${year}-${month}-${day}` | |
const issueTitle = `Benchmark Performance Degradation (${today})` | |
const issueBody = ` | |
📝 Benchmark detail: ${urlLink} | |
${result} | |
` | |
let repo = context.repo.repo | |
const product = "${{ matrix.product }}" | |
if (product === "MODERNJS_FRAMEWORK" || product === "MODERNJS_MODULE") { | |
repo = "modern.js" | |
} else if (product === "RSBUILD") { | |
repo = "rsbuild" | |
} else if (product === "RSPRESS") { | |
repo = "rspress" | |
} else if (product === "RSLIB") { | |
repo = "rslib" | |
} | |
await github.rest.issues.create({ | |
owner: context.repo.owner, | |
repo: repo, | |
title: issueTitle, | |
body: issueBody, | |
}); |