File tree Expand file tree Collapse file tree 4 files changed +22
-8
lines changed
Expand file tree Collapse file tree 4 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ inputs:
3232 to :
3333 description : ' Timing JSON file to write (for convert)'
3434 required : false
35+ path-prefix :
36+ description : ' Prefix to prepend to file paths (for convert) - use to match paths with split pattern'
37+ required : false
3538 # merge inputs
3639 prefix :
3740 description : ' Prefix to match timing JSON files (for merge)'
@@ -101,7 +104,8 @@ runs:
101104 run : |
102105 bun run ${{ github.action_path }}/index.ts convert \
103106 --from "${{ inputs.from }}" \
104- --to "${{ inputs.to }}"
107+ --to "${{ inputs.to }}" \
108+ ${{ inputs.path-prefix != '' && format('--path-prefix "{0}"', inputs.path-prefix) || '' }}
105109
106110 - name : Run merge
107111 if : inputs.command == 'merge'
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ const { positionals, values } = parseArgs({
1919 to : {
2020 type : "string" ,
2121 } ,
22+ [ "path-prefix" ] : {
23+ type : "string" ,
24+ } ,
2225 // merge options
2326 [ "timings-file" ] : {
2427 type : "string" ,
@@ -78,10 +81,13 @@ fairsplice convert
7881Convert JUnit XML to timing JSON (for a single worker).
7982
8083Required options:
81- --from <file> JUnit XML file to read
82- --to <file> Timing JSON file to write
84+ --from <file> JUnit XML file to read
85+ --to <file> Timing JSON file to write
86+
87+ Optional:
88+ --path-prefix <prefix> Prefix to prepend to all file paths (e.g., "src/tests/")
8389
84- Example: fairsplice convert --from junit.xml --to timing.json
90+ Example: fairsplice convert --from junit.xml --to timing.json --path-prefix "frontends/apps/e2e/"
8591
8692
8793fairsplice merge
@@ -125,7 +131,7 @@ if (command === "split") {
125131 ) ;
126132 process . exit ( 1 ) ;
127133 }
128- await convert ( { from : values . from , to : values . to } ) ;
134+ await convert ( { from : values . from , to : values . to , pathPrefix : values [ "path-prefix" ] } ) ;
129135 process . exit ( 0 ) ;
130136} else if ( command === "merge" ) {
131137 if ( ! values [ "timings-file" ] || ! values . prefix ) {
Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ import { parseJunit } from "../lib/junit";
33export async function convert ( {
44 from,
55 to,
6+ pathPrefix,
67} : {
78 from : string ;
89 to : string ;
10+ pathPrefix ?: string ;
911} ) {
1012 // check if input file exists
1113 const junitXmlFile = Bun . file ( from ) ;
@@ -27,10 +29,12 @@ export async function convert({
2729 if ( testCase . file . includes ( ".." ) ) {
2830 continue ;
2931 }
30- if ( ! timingByFile [ testCase . file ] ) {
31- timingByFile [ testCase . file ] = 0 ;
32+ // Apply path prefix if provided
33+ const filePath = pathPrefix ? `${ pathPrefix } ${ testCase . file } ` : testCase . file ;
34+ if ( ! timingByFile [ filePath ] ) {
35+ timingByFile [ filePath ] = 0 ;
3236 }
33- timingByFile [ testCase . file ] += testCase . time ;
37+ timingByFile [ filePath ] += testCase . time ;
3438 }
3539
3640 // convert to ms
You can’t perform that action at this time.
0 commit comments