File tree Expand file tree Collapse file tree 2 files changed +56
-9
lines changed Expand file tree Collapse file tree 2 files changed +56
-9
lines changed Original file line number Diff line number Diff line change @@ -366,16 +366,14 @@ jobs:
366
366
- name : Build site
367
367
run : cargo build --bin site
368
368
369
+ - name : Setup Python
370
+ uses : actions/setup-python@v5
371
+
372
+ - name : Install Python dependencies
373
+ run : python3 -m pip install msgpack requests
374
+
369
375
# Check that data from the /get endpoint can be successfully queried.
370
376
- name : Query compare page data
371
377
run : |
372
378
DATABASE_URL=postgresql://postgres:[email protected] :5432/postgres cargo run --bin site &
373
- curl http://localhost:2346/perf/get \
374
- -H 'Content-Type:application/json' \
375
- -d '{"start": "version1", "end": "version2", "stat": "instructions:u" }' \
376
- --output out.msgpack \
377
- --retry-connrefused \
378
- --connect-timeout 5 \
379
- --max-time 10 \
380
- --retry 3 \
381
- --retry-delay 5
379
+ python3 ci/check-site.py version1 version2
Original file line number Diff line number Diff line change
1
+ """
2
+ Checks that the perf site running locally returns non-empty data for a set of artifacts.
3
+ """
4
+ import sys
5
+ import time
6
+
7
+ import msgpack
8
+ import requests
9
+
10
+ if __name__ == "__main__" :
11
+ if len (sys .argv ) < 3 :
12
+ print ("Usage: python3 check-site.py <version1> <version2>" )
13
+ exit (1 )
14
+ version1 = sys .argv [1 ]
15
+ version2 = sys .argv [2 ]
16
+
17
+ # Wait for the site to start
18
+ while True :
19
+ try :
20
+ response = requests .post ("http://localhost:2346/perf/get" , json = {
21
+ "start" : version1 ,
22
+ "end" : version2 ,
23
+ "stat" : "instructions:u"
24
+ })
25
+ if response .content != b"no data yet, please wait" :
26
+ break
27
+ except BaseException as e :
28
+ print (e )
29
+
30
+ print (f"Site not online yet, waiting" )
31
+ time .sleep (1 )
32
+
33
+ stats = ("instructions:u" , "size:linked_artifact" )
34
+ for stat in stats :
35
+ print (f"Checking { stat } " )
36
+ response = requests .post ("http://localhost:2346/perf/get" , json = {
37
+ "start" : version1 ,
38
+ "end" : version2 ,
39
+ "stat" : stat
40
+ })
41
+ if response .status_code != 200 :
42
+ raise Exception (f"Failure { response .status_code } : { response .content } " )
43
+ payload = msgpack .unpackb (response .content )
44
+ print (payload )
45
+ for artifact_id in ("a" , "b" ):
46
+ artifact = payload [artifact_id ]
47
+ assert artifact ["component_sizes" ].get ("librustc_driver" , 0 ) > 0
48
+ comparisons = payload ["compile_comparisons" ]
49
+ assert len (comparisons ) > 0
You can’t perform that action at this time.
0 commit comments