@@ -14,29 +14,30 @@ const {
14
14
GITHUB_RUN_ID = "local" ,
15
15
} = process . env ;
16
16
17
- async function uploadImageToCloudflare (
18
- filename : string ,
19
- filePath : string
20
- ) : Promise < string | null > {
21
- if ( ! CF_IMAGES_LINK || ! CF_IMAGES_TOKEN ) {
22
- return null ;
23
- }
24
-
17
+ async function uploadImageToCloudflare ( filename : string , filePath : string ) {
18
+ console . log ( "Uploading image to cloudflare" ) ;
25
19
const buffer = readFileSync ( filePath ) ;
26
20
const blob = new Blob ( [ buffer ] , { type : "image/png" } ) ;
27
21
const form = new FormData ( ) ;
28
22
29
23
form . append ( "file" , blob , filename ) ;
30
24
31
- return fetch ( CF_IMAGES_LINK ! , {
25
+ const res = await fetch ( CF_IMAGES_LINK ! , {
32
26
method : "POST" ,
33
27
body : form ,
34
28
headers : {
35
29
Authorization : `Bearer ${ CF_IMAGES_TOKEN } ` ,
36
30
} ,
37
- } )
38
- . then ( ( res ) => res . json ( ) )
39
- . then ( ( r ) => r . result . variants [ 0 ] ) ;
31
+ } ) ;
32
+
33
+ console . log ( `Got a response from cloudflare (status=${ res . status } )` ) ;
34
+
35
+ if ( ! res . ok ) {
36
+ throw new Error ( `Failed to upload image to Cloudflare: ${ res . statusText } ` ) ;
37
+ }
38
+
39
+ const data = await res . json ( ) ;
40
+ return data . result . variants [ 0 ] ;
40
41
}
41
42
42
43
function notEmpty < TValue > ( value : TValue | null | undefined ) : value is TValue {
@@ -57,7 +58,10 @@ async function generateReport(artifactsRootPath: string) {
57
58
withFileTypes : true ,
58
59
} )
59
60
. filter ( ( r ) => r . isDirectory ( ) && ! IGNORED_DIRS . includes ( r . name ) )
60
- . filter ( ( r ) => r . name . startsWith ( process . env . SCENARIO_ARTIFACTS_PREFIX ! ) )
61
+ . filter (
62
+ ( r ) =>
63
+ r . name . startsWith ( process . env . SCENARIO_ARTIFACTS_PREFIX ! )
64
+ )
61
65
. map ( ( r ) => r . name ) ;
62
66
63
67
console . info (
@@ -73,6 +77,7 @@ async function generateReport(artifactsRootPath: string) {
73
77
const reportsData = await Promise . all (
74
78
foundDirectories . map ( async ( dirName ) => {
75
79
const fullPath = join ( artifactsRootPath , dirName ) ;
80
+ console . log ( `Processing directory: ${ fullPath } ` ) ;
76
81
const jsonSummaryFilePath = join ( fullPath , "./k6_summary.json" ) ;
77
82
78
83
if ( ! existsSync ( jsonSummaryFilePath ) ) {
@@ -135,6 +140,8 @@ async function generateReport(artifactsRootPath: string) {
135
140
. filter ( notEmpty )
136
141
. sort ( ( a , b ) => b . rps - a . rps ) ;
137
142
143
+ console . log ( `Found ${ validReportsData . length } valid reports` ) ;
144
+
138
145
const vega : vl . TopLevelSpec = {
139
146
width : 600 ,
140
147
height : 400 ,
@@ -196,7 +203,10 @@ async function generateReport(artifactsRootPath: string) {
196
203
) ;
197
204
}
198
205
199
- const checks = v . jsonSummary . root_group . checks ;
206
+ const checks : Array < {
207
+ fails : number ;
208
+ name : string ;
209
+ } > = v . jsonSummary . root_group . checks ;
200
210
const http200Check = checks . find (
201
211
( c ) => c . name === "response code was 200"
202
212
) ;
@@ -207,6 +217,7 @@ async function generateReport(artifactsRootPath: string) {
207
217
( c ) => c . name === "valid response structure"
208
218
) ;
209
219
220
+
210
221
if ( http200Check . fails > 0 ) {
211
222
notes . push ( `${ http200Check . fails } non-200 responses` ) ;
212
223
}
0 commit comments