Skip to content

Monitor Metrics

Monitor Metrics #17

name: Monitor Metrics
on:
schedule:
- cron: '0 21 * * *'
workflow_dispatch:
jobs:
monitor:
continue-on-error: true
strategy:
matrix:
include:
- product: MODERNJS_FRAMEWORK
- product: MODERNJS_MODULE
- product: RSPRESS
- product: RSBUILD
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
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 pnpm compare ${{ 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@v6
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 issueTitle = `Benchmark Performance Degradation`
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"
}
await github.rest.issues.create({
owner: context.repo.owner,
repo: repo,
title: issueTitle,
body: issueBody,
});