File tree Expand file tree Collapse file tree 4 files changed +19
-17
lines changed Expand file tree Collapse file tree 4 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -67,10 +67,13 @@ jobs:
67
67
- name : Install Dependencies
68
68
run : pnpm run install:scripts
69
69
70
+ - name : 🚀 Run specified benchmark
71
+ run : cd scripts && PR_NUMBER=${{ inputs.prNumber }} GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} pnpm start ${{ inputs.product }}
72
+
70
73
- id : print-results
71
- name : 🚀 Run specified benchmark and Print results
74
+ name : Print results
72
75
run : |
73
- result=$(cd scripts && PR_NUMBER=${{ inputs.prNumber }} pnpm start ${{ inputs.product }})
76
+ result=$(cd scripts && node ./dist/compare.js ${{ inputs.product }})
74
77
echo "$result"
75
78
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
76
79
update-comment :
Original file line number Diff line number Diff line change 1
1
import { readJson } from 'fs-extra' ;
2
- import { Metrics } from './types' ;
2
+ import { Metrics } from './shared/types' ;
3
+ import { DefaultBenchCase , getMetricsPath } from './shared' ;
4
+
5
+ const productName = process . argv [ 2 ] || 'MODERNJS_FRAMEWORK' ;
3
6
4
7
const formatFileSize = ( size : number , target = 'KB' ) => {
5
8
if ( target === 'KB' ) {
@@ -60,7 +63,11 @@ function generateTable(
60
63
return table . join ( '\n' ) ;
61
64
}
62
65
63
- export async function compare ( jsonPath : string ) {
66
+ export async function compare ( productName : string ) {
67
+ const caseName =
68
+ process . argv [ 3 ] ||
69
+ DefaultBenchCase [ productName as keyof typeof DefaultBenchCase ] ;
70
+ const { jsonPath } = await getMetricsPath ( productName , caseName ) ;
64
71
const allMetrics : Metrics [ ] = await readJson ( jsonPath ) ;
65
72
const keys = Object . keys ( allMetrics ) ;
66
73
const currentKey = keys [ keys . length - 1 ] ;
@@ -71,3 +78,5 @@ export async function compare(jsonPath: string) {
71
78
const formatTable = generateTable ( base , current ) ;
72
79
console . log ( formatTable ) ;
73
80
}
81
+
82
+ compare ( productName ) ;
Original file line number Diff line number Diff line change 9
9
} from './shared' ;
10
10
import { remove } from 'fs-extra' ;
11
11
import { yarnInstall } from './runners/yarn-install' ;
12
- import { compare } from './shared/compare' ;
13
12
14
13
const productName = process . argv [ 2 ] || 'MODERNJS_FRAMEWORK' ;
15
14
const caseName =
@@ -43,11 +42,7 @@ async function main() {
43
42
console . log ( 'failed to collect install size metrics:' , err ) ;
44
43
}
45
44
46
- const jsonPath = await mergeMetrics ( productName , caseName ) ;
47
-
48
- if ( process . env . PR_NUMBER ) {
49
- await compare ( jsonPath ) ;
50
- }
45
+ await mergeMetrics ( productName , caseName ) ;
51
46
} else {
52
47
logger . error ( `Case not found: ${ productName } ${ caseName } ` ) ;
53
48
}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export async function updateFile(
40
40
}
41
41
}
42
42
43
- async function getMetricsPath ( productName : string , caseName : string ) {
43
+ export async function getMetricsPath ( productName : string , caseName : string ) {
44
44
const jsonName = `${ caseName } .json` ;
45
45
return {
46
46
jsonName,
@@ -102,10 +102,7 @@ const cleanData = (nums: number[]) => {
102
102
return nums ;
103
103
} ;
104
104
105
- export async function mergeMetrics (
106
- productName : string ,
107
- caseName : string ,
108
- ) : Promise < string > {
105
+ export async function mergeMetrics ( productName : string , caseName : string ) {
109
106
const { jsonPath, jsonName, remoteURL } = await getMetricsPath (
110
107
productName ,
111
108
caseName ,
@@ -146,6 +143,4 @@ export async function mergeMetrics(
146
143
await outputJson ( jsonPath , allData ) ;
147
144
logger . success ( `Successfully merged metrics to ${ jsonName } .` ) ;
148
145
}
149
-
150
- return jsonPath ;
151
146
}
You can’t perform that action at this time.
0 commit comments