File tree Expand file tree Collapse file tree 2 files changed +53
-2
lines changed Expand file tree Collapse file tree 2 files changed +53
-2
lines changed Original file line number Diff line number Diff line change
1
+ name : Monitor Metrics
2
+
3
+ on :
4
+ # schedule:
5
+ # - cron: '0 21 * * *'
6
+ workflow_dispatch :
7
+
8
+ jobs :
9
+ monitor :
10
+ strategy :
11
+ matrix :
12
+ include :
13
+ - product : MODERNJS_FRAMEWORK
14
+ - product : MODERNJS_MODULE
15
+ - product : RSPRESS
16
+ - product : RSBUILD
17
+ runs-on : ubuntu-latest
18
+ steps :
19
+ - name : Checkout
20
+ uses : actions/checkout@v3
21
+ with :
22
+ fetch-depth : 1
23
+
24
+ - name : Setup Node.js
25
+ uses : actions/setup-node@v3
26
+ with :
27
+ node-version : 16
28
+ cache-dependency-path : pnpm-lock.yaml
29
+
30
+ - name : Install Pnpm
31
+ run : corepack enable && pnpm -v && pnpm store path
32
+
33
+ - name : Install Dependencies
34
+ run : pnpm run install:scripts
35
+
36
+ - name : Build Scripts
37
+ run : cd scripts && pnpm run build
38
+
39
+ - name : Monitor Metrics
40
+ run : |
41
+ result=$(cd scripts && MONITOR=1 node ./dist/compare.js ${{ matrix.product }})
42
+ echo "$result"
43
+ echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
44
+ if [[ $result =~ "Threshold exceeded" ]]; then
45
+ echo "Some benchmark metrics exceed the threshold, please visit the previous step for more information"
46
+ exit 1
47
+ fi
Original file line number Diff line number Diff line change
1
+ import axios from 'axios' ;
1
2
import { readJson } from 'fs-extra' ;
2
3
import { Metrics } from './shared/types' ;
3
4
import { DefaultBenchCase , getCommitLink , getMetricsPath } from './shared' ;
@@ -75,8 +76,11 @@ export async function compare(productName: string) {
75
76
const caseName =
76
77
process . argv [ 3 ] ||
77
78
DefaultBenchCase [ productName as keyof typeof DefaultBenchCase ] ;
78
- const { jsonPath } = await getMetricsPath ( productName , caseName ) ;
79
- const allMetrics : Metrics [ ] = await readJson ( jsonPath ) ;
79
+ const { jsonPath, remoteURL } = await getMetricsPath ( productName , caseName ) ;
80
+ const allMetrics : Metrics [ ] =
81
+ process . env . MONITOR === '1'
82
+ ? ( await axios . get ( remoteURL ) ) . data
83
+ : await readJson ( jsonPath ) ;
80
84
const keys = Object . keys ( allMetrics ) ;
81
85
const currentKey = keys [ keys . length - 1 ] ;
82
86
const baseKey = keys [ keys . length - 2 ] ;
You can’t perform that action at this time.
0 commit comments