Skip to content

Commit 2725208

Browse files
authored
chore: create issue when monitor failed (#60)
1 parent 1d2fdb9 commit 2725208

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

.github/workflows/monitor-metrics.yaml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name: Monitor Metrics
22

33
on:
4-
# schedule:
5-
# - cron: '0 21 * * *'
4+
schedule:
5+
- cron: '0 21 * * *'
66
workflow_dispatch:
77

88
jobs:
99
monitor:
10+
continue-on-error: true
1011
strategy:
1112
matrix:
1213
include:
@@ -37,6 +38,7 @@ jobs:
3738
run: cd scripts && pnpm run build
3839

3940
- name: Monitor Metrics
41+
id: monitor
4042
run: |
4143
result=$(cd scripts && MONITOR=1 node ./dist/compare.js ${{ matrix.product }})
4244
echo "$result"
@@ -45,3 +47,39 @@ jobs:
4547
echo "Some benchmark metrics exceed the threshold, please visit the previous step for more information"
4648
exit 1
4749
fi
50+
- name: Create Issue on Failure
51+
if: failure()
52+
uses: actions/github-script@v6
53+
with:
54+
github-token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }}
55+
script: |
56+
const diffResult = `${{ steps.monitor.outputs.diff-result }}`
57+
let result = "task ${{ steps.monitor.outputs.result }}"
58+
if (diffResult) {
59+
result = diffResult.replace(/@@/g, "\n");
60+
}
61+
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
62+
const urlLink = `[Open](${url})`
63+
const issueTitle = `Benchmark Performance Degradation`
64+
const issueBody = `
65+
📝 Benchmark detail: ${urlLink}
66+
67+
${result}
68+
`
69+
70+
let repo = context.repo.repo
71+
const product = "${{ matrix.product }}"
72+
if (product === "MODERNJS_FRAMEWORK" || product === "MODERNJS_MODULE") {
73+
repo = "modern.js"
74+
} else if (product === "RSBUILD") {
75+
repo = "rsbuild"
76+
} else if (product === "RSPRESS") {
77+
repo = "rspress"
78+
}
79+
80+
await github.rest.issues.create({
81+
owner: context.repo.owner,
82+
repo: repo,
83+
title: issueTitle,
84+
body: issueBody,
85+
});

0 commit comments

Comments
 (0)