@@ -43,61 +43,61 @@ const upload = async (
4343 inputs : ActionInputs ,
4444 profilePath : string
4545) : Promise < void > => {
46- core . group ( "Upload Results" , async ( ) => {
47- const uploadMetadata = await getUploadMetadata ( { profilePath, inputs} ) ;
48- core . debug ( "Upload metadata:" ) ;
49- core . debug ( JSON . stringify ( uploadMetadata , null , 2 ) ) ;
50- const hash = crypto
51- . createHash ( "sha256" )
52- . update ( JSON . stringify ( uploadMetadata ) )
53- . digest ( "hex" ) ;
54- if ( inputs . tokenless ) {
55- core . info ( `CodSpeed Run Hash: "${ hash } "` ) ;
56- }
46+ core . startGroup ( "Upload Results" ) ;
47+ const uploadMetadata = await getUploadMetadata ( { profilePath, inputs} ) ;
48+ core . debug ( "Upload metadata:" ) ;
49+ core . debug ( JSON . stringify ( uploadMetadata , null , 2 ) ) ;
50+ const hash = crypto
51+ . createHash ( "sha256" )
52+ . update ( JSON . stringify ( uploadMetadata ) )
53+ . digest ( "hex" ) ;
54+ if ( inputs . tokenless ) {
55+ core . info ( `CodSpeed Run Hash: "${ hash } "` ) ;
56+ }
5757
58- core . info ( "Preparing upload" ) ;
59- let response : TypedResponse < PostResponse > ;
60- try {
61- const headers = inputs . tokenless
62- ? undefined
63- : {
64- Authorization : inputs . token ,
65- } ;
66- response = await http . postJson < PostResponse > (
67- inputs . uploadUrl ,
68- uploadMetadata ,
69- headers
70- ) ;
71- } catch ( e ) {
72- const err = e as httpm . HttpClientError ;
73- throw new Error (
74- `Upload preparation failed (${ err . statusCode } ): ${ err . message } `
75- ) ;
76- }
77- if ( ! response . result ) {
78- throw new Error ( "Upload preparation failed: no result" ) ;
79- }
80- core . info ( "Uploading profile data" ) ;
81- const profile = fs . readFileSync ( profilePath ) ;
82- core . debug ( `Uploading ${ profile . length } bytes...` ) ;
83- const uploadResponse = await http . request (
84- "PUT" ,
85- response . result . uploadUrl ,
86- Readable . from ( profile ) ,
87- {
88- "Content-Type" : "application/octet-stream" ,
89- "Content-Length" : profile . length ,
90- "Content-MD5" : uploadMetadata . profileMd5 ,
91- }
58+ core . info ( "Preparing upload" ) ;
59+ let response : TypedResponse < PostResponse > ;
60+ try {
61+ const headers = inputs . tokenless
62+ ? undefined
63+ : {
64+ Authorization : inputs . token ,
65+ } ;
66+ response = await http . postJson < PostResponse > (
67+ inputs . uploadUrl ,
68+ uploadMetadata ,
69+ headers
9270 ) ;
93- if ( uploadResponse . message . statusCode !== 200 ) {
94- throw new Error (
95- `Upload failed with status ${ uploadResponse . message . statusCode } : ${ uploadResponse . message . statusMessage } `
96- ) ;
71+ } catch ( e ) {
72+ const err = e as httpm . HttpClientError ;
73+ throw new Error (
74+ `Upload preparation failed (${ err . statusCode } ): ${ err . message } `
75+ ) ;
76+ }
77+ if ( ! response . result ) {
78+ throw new Error ( "Upload preparation failed: no result" ) ;
79+ }
80+ core . info ( "Uploading profile data..." ) ;
81+ const profile = fs . readFileSync ( profilePath ) ;
82+ core . debug ( `Uploading ${ profile . length } bytes...` ) ;
83+ const uploadResponse = await http . request (
84+ "PUT" ,
85+ response . result . uploadUrl ,
86+ Readable . from ( profile ) ,
87+ {
88+ "Content-Type" : "application/octet-stream" ,
89+ "Content-Length" : profile . length ,
90+ "Content-MD5" : uploadMetadata . profileMd5 ,
9791 }
92+ ) ;
93+ if ( uploadResponse . message . statusCode !== 200 ) {
94+ throw new Error (
95+ `Upload failed with status ${ uploadResponse . message . statusCode } : ${ uploadResponse . message . statusMessage } `
96+ ) ;
97+ }
9898
99- core . info ( "Results uploaded." ) ;
100- } ) ;
99+ core . info ( "Results uploaded." ) ;
100+ core . endGroup ( ) ;
101101} ;
102102
103103export default upload ;
0 commit comments