-
Notifications
You must be signed in to change notification settings - Fork 249
/
Copy pathreport-summary-merged-prs.py
executable file
·2026 lines (1787 loc) · 76.4 KB
/
report-summary-merged-prs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /usr/bin/env python3
"""
This script generates json file (like CMSSW_10_0_X.json) which is then used to render cmssdt ib page.
"""
from __future__ import print_function
from optparse import OptionParser
import subprocess
import re
import json
from pickle import Unpickler
from os.path import basename, dirname, exists, join, expanduser, getmtime
from glob import glob
from github import Github
from pprint import pformat
from cmsutils import get_config_map_properties
from github_utils import get_merge_prs
from cms_static import GH_CMSSW_REPO, GH_CMSSW_ORGANIZATION
from releases import CMSSW_DEVEL_BRANCH
from socket import setdefaulttimeout
setdefaulttimeout(120)
CMSSW_REPO_NAME = join(GH_CMSSW_ORGANIZATION, GH_CMSSW_REPO)
# -----------------------------------------------------------------------------------
# ---- Parser Options
# -----------------------------------------------------------------------------------
parser = OptionParser(
usage="usage: %prog CMSSW_REPO GITHUB_IO_REPO START_DATE"
"\n CMSSW_REPO: location of the cmssw repository. This must be a bare clone ( git clone --bare )"
"\n CMSDIST_REPO: location of the cmsdist repository. This must be a normal clone"
"\n GITHUB_IO_REPO: location of the github.io repository. This must be a normal clone"
"\n for example: cmssw.git or /afs/cern.ch/cms/git-cmssw-mirror/cmssw.git"
"\n START_DATE: the date of the earliest IB to show. It must be in the format"
"\n <year>-<day>-<month>-<hour>"
"\n For example:"
"\n 2014-10-08-1400"
)
parser.add_option(
"-v",
"--verbose",
dest="verbose",
action="store_true",
help="Do not post on Github",
default=False,
)
(options, args) = parser.parse_args()
"""
-----------------------------------------------------------------------------------
---- Output Schema
-----------------------------------------------------------------------------------
comparisons": [ <DictA>, <DictB>, <DictC> ]
Each dict contains the result of the comparison between 2 tags in cmssw. For example
CMSSW_5_3_X_2015-02-03-0200 with CMSSW_5_3_X_2015-02-04-0200 which correspond
to the IB CMSSW_5_3_X_2015-02-04-0200
The schema of the dictionary is as folows:
{
"addons": [],
"builds": [],
"fwlite": [],
"compared_tags": "",
"utests": [],
"gpu_utests": [],
"cmsdistTags": {},
"relvals": [],
"static_checks": "",
"valgrind": "",
"material_budget" : "",
"isIB": Boolean,
"tests_archs": [],
"release_name": "",
"merged_prs": [],
"RVExceptions" : Boolean
}
"""
# -----------------------------------------------------------------------------------
# ---- Review of arguments
# -----------------------------------------------------------------------------------
if len(args) < 4:
print("not enough arguments\n")
parser.print_help()
exit()
# Remember that the cmssw repo is a bare clone while cmsdist is a complete clone
CMSSW_REPO_LOCAL = args[0]
GITHUB_IO_REPO = args[1]
CMSDIST_REPO = args[2]
START_DATE = args[3]
if len(args) >= 5:
CMS_PRS = args[4]
else:
CMS_PRS = "cms-prs"
# -----------------------------------------------------------------------------------
# ---- Fuctions
# -----------------------------------------------------------------------------------
def print_verbose(msg):
"""
Takes into account the verbose option. If the option is activated it doesn't print anything.
"""
if options.verbose:
print(msg)
def parse_config_map_line(line):
"""
reads a line of config.map and returns a dictionary with is parameters
"""
params = {}
parts = line.split(";")
for part in parts:
if part == "":
continue
key = part.split("=")[0]
value = part.split("=")[1]
params[key] = value
return params
def get_config_map_params():
"""
gets the list of architectures by reading config.map, they are saved in ARCHITECTURES
gets the releases branches from config.map, they are saved in RELEASES_BRANCHES
it maps the branches for all the releases this is to take into account the case in which the base branch
is different from the release queue
"""
f = open(CONFIG_MAP_FILE, "r")
for line in f.readlines():
params = parse_config_map_line(line.rstrip())
if not params:
continue
print(params)
arch = params["SCRAM_ARCH"]
if arch not in ARCHITECTURES:
ARCHITECTURES.append(arch)
release_queue = params["RELEASE_QUEUE"]
base_branch = params.get("RELEASE_BRANCH")
if base_branch:
if base_branch == "master":
base_branch = CMSSW_DEVEL_BRANCH
RELEASES_BRANCHES[release_queue] = base_branch
else:
RELEASES_BRANCHES[release_queue] = release_queue
sp_rel_name = release_queue.split("_")[3]
if sp_rel_name != "X" and sp_rel_name not in SPECIAL_RELEASES:
SPECIAL_RELEASES.append(sp_rel_name)
if not params.get("DISABLED") or params.get("IB_WEB_PAGE"):
if not RELEASES_ARCHS.get(release_queue):
RELEASES_ARCHS_WITH_DIST_BRANCH[release_queue] = {}
RELEASES_ARCHS[release_queue] = []
RELEASES_ARCHS[release_queue].append(arch)
RELEASES_ARCHS_WITH_DIST_BRANCH[release_queue][arch] = params["CMSDIST_TAG"]
if release_queue not in RELEASE_QUEUES:
RELEASE_QUEUES.append(release_queue)
additional_tests = params.get("ADDITIONAL_TESTS")
if additional_tests:
if RELEASE_ADITIONAL_TESTS.get(release_queue):
continue
RELEASE_ADITIONAL_TESTS[release_queue] = {}
# if not RELEASE_ADITIONAL_TESTS.get( release_queue ):
# RELEASE_ADITIONAL_TESTS[ release_queue ] = {}
RELEASE_ADITIONAL_TESTS[release_queue][arch] = [
test for test in additional_tests.split(",") if test != "dqm"
]
SP_REL_REGEX = "|".join(SPECIAL_RELEASES)
RELEASE_QUEUES.sort()
print()
print("---------------------------")
print("Read config.map:")
print("ARCHS:")
print(ARCHITECTURES)
print("--")
print(RELEASES_ARCHS)
print("RELEASES_BRANCHES:")
print(RELEASES_BRANCHES)
print("special releases")
print(SPECIAL_RELEASES)
print("aditional tests")
print(RELEASE_ADITIONAL_TESTS)
print("I am going to show:")
print(RELEASE_QUEUES)
print("---------------------------")
print()
def get_tags_from_line(line, release_queue):
"""
reads a line of the output of git log and returns the tags that it contains
if there are no tags it returns an empty list
it applies filters according to the release queue to only get the
tags related to the current release queue
"""
if "tags->" not in line:
return []
tags_str = line.split("tags->")[1]
if re.match(".*SLHC$", release_queue):
filter = release_queue[:-6] + "[X|0-9]_SLHC.*"
else:
filter = release_queue[:-1] + "[X|0-9].*"
## if the tags part is equal to ," there are no tags
if tags_str != ',"':
tags = tags_str.split(",", 1)[1].strip().replace("(", "").replace(")", "").split(",")
# remove te word "tag: "
tags = [t.replace("tag: ", "") for t in tags]
# I also have to remove the branch name because it otherwise will always appear
# I also remove tags that have the string _DEBUG_TEST, they are used to create test IBs
tags = [
t
for t in tags
if re.match(filter, t.strip())
and (t.strip().replace('"', "") != release_queue)
and ("DEBUG_TEST" not in t)
]
return [t.replace('"', "").replace("tag:", "").strip() for t in tags]
else:
return []
# -----------------------------------------------------------------------------------
# ---- Fuctions -- Analize Git outputs
# -----------------------------------------------------------------------------------
def determine_build_error(nErrorInfo):
a = BuildResultsKeys.COMP_ERROR in nErrorInfo.keys()
b = BuildResultsKeys.LINK_ERROR in nErrorInfo.keys()
c = BuildResultsKeys.MISC_ERROR in nErrorInfo.keys()
d = BuildResultsKeys.DWNL_ERROR in nErrorInfo.keys()
e = BuildResultsKeys.DICT_ERROR in nErrorInfo.keys()
f = BuildResultsKeys.PYTHON_ERROR in nErrorInfo.keys()
return a or b or c or d or e or f
def determine_build_warning(nErrorInfo):
a = BuildResultsKeys.PYTHON3_ERROR in nErrorInfo.keys()
b = BuildResultsKeys.COMP_WARNING in nErrorInfo.keys()
return a or b
def get_results_one_addOn_file(file):
look_for_err_cmd = 'grep "failed" %s' % file
result, err, ret_code = get_output_command(look_for_err_cmd)
if " 0 failed" in result:
return True
else:
return False
def get_results_one_unitTests_file(file, grep_str="ERROR"):
"""
given a unitTests-summary.log it determines if the test passed or not
it returns a tuple, the first element is one of the possible values of PossibleUnitTestResults
The second element is a dictionary which indicates how many tests failed
"""
look_for_err_cmd = 'grep -h -c "%s" %s' % (grep_str, file)
result, err, ret_code = get_output_command(look_for_err_cmd)
result = result.rstrip()
details = {"num_fails": result}
if result != "0":
return PossibleUnitTestResults.FAILED, details
else:
return PossibleUnitTestResults.PASSED, details
def get_results_one_relval_file(filename):
"""
given a runall-report-step123-.log file it returns the result of the relvals
it returns a tuple, the first element indicates if the tests passed or not
the second element is a dictionary which shows the details of how many relvals pased
and how many failed
"""
summary_file = filename.replace("/runall-report-step123-.log", "/summary.json")
if exists(summary_file) and getmtime(summary_file) > getmtime(filename):
try:
details = json.load(open(summary_file))
return details["num_failed"] == 0, details
except:
pass
details = {"num_passed": 0, "num_failed": 1, "known_failed": 0}
print_verbose("Analyzing: " + filename)
lines = open(filename).read().split("\n")
results = [x for x in lines if " tests passed" in x]
if len(results) == 0:
return False, details
out = results.pop()
num_passed_sep = out.split(",")[0].replace(" tests passed", "").strip()
num_failed_sep = out.split(",")[1].replace(" failed", "").strip()
try:
details["num_passed"] = sum([int(num) for num in num_passed_sep.split(" ")])
details["num_failed"] = sum([int(num) for num in num_failed_sep.split(" ")])
except ValueError as e:
print("Error while reading file %s" % filename)
print(e)
return False, details
with open(summary_file, "w") as ref:
json.dump(details, ref, sort_keys=True)
return details["num_failed"] == 0, details
def get_results_details_one_build_file(file, type):
"""
Given a logAnalysis.pkl file, it determines if the tests passed or not
it returns a tuple, the first element is one of the values of PossibleBuildResults
The second element is a dictionary containing the details of the results.
If the tests are all ok this dictionary is empty
"""
summFile = open(file, "rb")
pklr = Unpickler(summFile)
[rel, plat, anaTime] = pklr.load()
errorKeys = pklr.load()
nErrorInfo = pklr.load()
summFile.close()
# if type=='builds':
# py3_log = join(dirname(dirname(file)),'python3.log')
# if exists (py3_log):
# py3 = open(py3_log, 'r')
# nErrorInfo[BuildResultsKeys.PYTHON3_ERROR]=len([l for l in py3.readlines() if ' Error compiling ' in l])
if determine_build_error(nErrorInfo):
return PossibleBuildResults.ERROR, nErrorInfo
elif determine_build_warning(nErrorInfo):
return PossibleBuildResults.WARNING, nErrorInfo
else:
return PossibleBuildResults.PASSED, nErrorInfo
def analyze_tests_results(output, results, arch, type):
"""
parses the tests results for each file in output. It distinguishes if it is
build, unit tests, relvals, or addon tests logs. The the result of the parsing
is saved in the parameter results.
type can be 'relvals', 'utests', 'gpu_tests', 'addON', 'builds', 'fwlite'
schema of results:
{
"<IBName>": [ result_arch1, result_arch2, ... result_archN ]
}
schema of result_arch
{
"arch" : "<architecture>"
"file" : "<location of the result>"
"passed" : <true or false> ( if not applicable the value is true )
"details" : <details for the tests> ( can be empty if not applicable, but not undefined )
}
"""
for line in output.splitlines():
m = re.search("/(CMSSW_[^/]+)/", line)
if not m:
print_verbose("Ignoring file:\n%s" % line)
continue
print("Processing ", type, ":", line)
rel_name = m.group(1)
result_arch = {}
result_arch["arch"] = arch
result_arch["file"] = line
details = {}
passed = None
if type == "relvals":
passed, details = get_results_one_relval_file(line)
result_arch["done"] = False
if exists(join(dirname(line), "done")) or exists(join(dirname(line), "all.pages")):
result_arch["done"] = True
elif type == "utests":
passed, details = get_results_one_unitTests_file(line)
elif type == "gpu_utests":
passed, details = get_results_one_unitTests_file(line)
elif type == "addOn":
passed = get_results_one_addOn_file(line)
elif type == "builds":
passed, details = get_results_details_one_build_file(line, type)
elif type == "fwlite":
passed, details = get_results_details_one_build_file(line, type)
elif type == "python3":
passed, details = get_results_one_unitTests_file(line, " Error compiling ")
elif type == "invalid-includes":
errs = len(json.load(open(line)))
if errs:
passed = PossibleUnitTestResults.FAILED
details = {"num_fails": str(errs)}
else:
passed = PossibleUnitTestResults.PASSED
else:
print("not a valid test type %s" % type)
exit(1)
result_arch["passed"] = passed
result_arch["details"] = details
if rel_name not in results.keys():
results[rel_name] = []
results[rel_name].append(result_arch)
def execute_magic_command_find_rv_exceptions_results():
"""
Searchs in github.io for the results for relvals exceptions
"""
print("Finding relval exceptions results...")
command_to_execute = MAGIC_COMMAND_FIND_EXCEPTIONS_RESULTS_RELVALS
out, err, ret_code = get_output_command(command_to_execute)
rv_exception_results = {}
for line in out.splitlines():
line_parts = line.split("/")
ib_name = line_parts[-1].replace("EXCEPTIONS.json", "") + line_parts[-2]
rv_exception_results[ib_name] = True
return rv_exception_results
def get_tags(git_log_output, release_queue):
"""
returns a list of tags based on git log output
It uses the release queue name to filter the tags, this avoids having
in the result tags from other queues that may come from automatic merges.
For example, if release_queue is 7_2_X, it will drop tags like CMSSW_7_2_THREADED_X_2014-09-15-0200
"""
tags = []
for line in git_log_output.splitlines():
tags += get_tags_from_line(line, release_queue)
if len(tags) == 0:
print("ATTENTION:")
print("looks like %s has not changed between the tags specified!" % release_queue)
command_to_execute = MAGIC_COMMAND_FIND_FIRST_MERGE_WITH_TAG.replace(
"END_TAG", release_queue
)
out, err, ret_code = get_output_command(command_to_execute)
print(out)
tags = get_tags_from_line(out, release_queue)
print(tags)
return tags
def get_day_number_tag(tag):
"""
returns the number of the day of a tag
if it is not an IB tag, it returns -1
"""
parts = tag.split("-")
if len(parts) == 1:
return -1
else:
day = parts[2]
try:
return int(day)
except ValueError:
return -1
def is_tag_list_suspicious(tags):
"""
uses some heuristics to tell if the list of tags seems to be too short
"""
if len(tags) < 7:
return True
day_first_tag = get_day_number_tag(tags[-1])
day_second_tag = get_day_number_tag(tags[-2])
return day_second_tag - day_first_tag > 1
def is_recent_branch(err):
"""
determines if the error is because one of the tags does not exist
this can happen when the branch that is being analyzed has been
created recently
"""
return "unknown revision or path not in the working tree" in err
# -----------------------------------------------------------------------------------
# ---- Fuctions -- Execute Magic commands
# -----------------------------------------------------------------------------------
def look_for_missing_tags(start_tag, release_queue):
"""
this calls the git log command with the first tag to look for missing
tags that were not found previously
"""
command_to_execute = MAGIC_COMMAND_FIND_FIRST_MERGE_WITH_TAG.replace("END_TAG", start_tag)
out, err, ret_code = get_output_command(command_to_execute)
tags = get_tags_from_line(out, release_queue)
return tags
def get_output_command(command_to_execute):
"""
Executes the command that is given as parameter, returns a tuple out,err,ret_code
with the output, error and return code obtained
"""
print_verbose("Executing:")
print_verbose(command_to_execute)
p = subprocess.Popen(
command_to_execute, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
out, err = p.communicate()
ret_code = p.returncode
out = out.decode("ascii", errors="ignore")
err = err.decode("ascii", errors="ignore")
if ret_code != 0:
print_verbose(ret_code)
print_verbose("Error:")
print_verbose(err)
return out, err, ret_code
def execute_magic_command_tags(
start_tag, end_tag, release_queue, release_branch, ignore_tags=None
):
"""
Gets the tags between start_tag and end_tag, the release_queue is used as a filter
to ignore tags that are from other releases
"""
print_verbose("Release Queue:")
print_verbose(release_queue)
print_verbose("Release Branch:")
print_verbose(release_branch)
# if it is a special release queue based on a branch with a different name, I use the release_branch as end tag
if release_queue == release_branch:
print_verbose("These IBs have a custom release branch")
real_end_tag = end_tag
else:
real_end_tag = release_branch
print_verbose("Start tag:")
print_verbose(start_tag)
print_verbose("End tag:")
print_verbose(real_end_tag)
command_to_execute = MAGIC_COMMAND_TAGS.replace("START_TAG", start_tag).replace(
"END_TAG", real_end_tag
)
command_to_execute = command_to_execute.replace("RELEASE_QUEUE", release_queue)
print("Running:", command_to_execute)
out, err, ret_code = get_output_command(command_to_execute)
# check if the end_tag exists, but the start_tag doesn't
# this could mean that the release branch has been created recently
if ret_code != 0:
if is_recent_branch(err):
print_verbose("looks like this branch has been created recently")
command_to_execute = MAGIC_COMMAND_FIND_ALL_TAGS.replace(
"END_TAG", real_end_tag
).replace("RELEASE_QUEUE", release_queue)
print("Running:", command_to_execute)
out, err, ret_code = get_output_command(command_to_execute)
tags = get_tags(out, release_queue)
tags.append(start_tag)
# check if the tags list could be missing tags
# this means that the release branch has not changed much from the start_tag
if is_tag_list_suspicious(tags):
print_verbose("this list could be missing something!")
print_verbose(tags)
new_tags = look_for_missing_tags(start_tag, release_branch)
tags.pop()
tags += new_tags
tags = [t for t in reversed(tags) if not ignore_tags or not re.match(ignore_tags, t)]
print("Found Tags:", tags)
return tags
def execute_command_compare_tags(branch, start_tag, end_tag, git_dir, repo, cache=None):
if cache is None:
cache = {}
comp = {}
comp["compared_tags"] = "%s-->%s" % (start_tag, end_tag)
comp["release_name"] = end_tag
notes = get_merge_prs(start_tag, end_tag, git_dir, CMS_PRS, cache)
prs = []
for pr_num in notes:
pr = {"is_merge_commit": False, "from_merge_commit": False}
if notes[pr_num]["branch"] != "master":
if notes[pr_num]["branch"] != branch:
pr["from_merge_commit"] = True
pr["number"] = pr_num
pr["hash"] = notes[pr_num]["hash"]
pr["author_login"] = notes[pr_num]["author"]
pr["title"] = notes[pr_num]["title"]
pr["url"] = "https://github.com/cms-sw/cmssw/pull/%s" % pr_num
prs.append(pr)
comp["merged_prs"] = prs
return comp
def compare_tags(branch, tags, git_dir, repo, cache=None):
if cache is None:
cache = {}
comparisons = []
if len(tags) > 1:
comparisons.append(
execute_command_compare_tags(branch, tags[0], tags[0], git_dir, repo, cache)
)
for i in range(len(tags) - 1):
comp = execute_command_compare_tags(branch, tags[i], tags[i + 1], git_dir, repo, cache)
comparisons.append(comp)
return comparisons
def execute_magic_command_get_cmsdist_tags():
"""
Executes the command to get the tags schema of all_tags_found:
{
"<IBName>": {
"<arch_name>" : "<tag_name>"
}
}
"""
all_tags_found = {}
for arch in ARCHITECTURES:
command_to_execute = MAGIC_COMMAND_CMSDIST_TAGS.replace("ARCHITECTURE", arch)
out, err, ret_code = get_output_command(command_to_execute)
for line in out.splitlines():
m = re.search("CMSSW.*[0-9]/", line)
if not m:
continue
rel_name = line[m.start() : m.end() - 1]
if not all_tags_found.get(rel_name):
all_tags_found[rel_name] = {}
all_tags_found[rel_name][arch] = line
if "CMSSW_10_" in rel_name:
print("CMSDIST ", rel_name, arch)
return all_tags_found
def execute_magic_command_find_results(type):
"""
Executes the a command to get the results for the relvals, unit tests,
addon tests, and compitlation tests
It saves the results in the parameter 'results'
type can be 'relvals', 'utests', 'gpu_tests', 'addON', 'builds'
"""
ex_magix_comand_finf_setuls_dict = {
"relvals": MAGIC_COMMAD_FIND_RESULTS_RELVALS,
"utests": MAGIC_COMMAND_FIND_RESULTS_UNIT_TESTS,
"gpu_utests": MAGIC_COMMAND_FIND_RESULTS_GPU_UNIT_TESTS,
"addOn": MAGIC_COMMAND_FIND_RESULTS_ADDON,
"builds": MAGIC_COMMAND_FIND_RESULTS_BUILD,
"fwlite": MAGIC_COMMAND_FIND_RESULTS_FWLITE,
"python3": MAGIC_COMMAND_FIND_RESULTS_PYTHON3,
"invalid-includes": MAGIC_COMMAND_FIND_INVALID_INCLUDES,
}
if type not in ex_magix_comand_finf_setuls_dict:
print("not a valid test type %s" % type)
exit(1)
results = {}
for arch in ARCHITECTURES:
base_command = ex_magix_comand_finf_setuls_dict[type]
command_to_execute = base_command.replace("ARCHITECTURE", arch)
print("Run>>", command_to_execute)
out, err, ret_code = get_output_command(command_to_execute)
analyze_tests_results(out, results, arch, type)
return results
def print_results(results):
print("Results:")
print()
print()
for rq in results:
print()
print(rq["release_name"])
print("/////////////////////////")
for comp in rq["comparisons"]:
print(comp["compared_tags"])
print("\t" + "HLT Tests: " + comp["hlt_tests"])
print("\t" + "Crab Tests: " + comp["crab_tests"])
print("\t" + "HEADER Tests:" + comp["check-headers"])
print("\t" + "DQM Tests: " + comp["dqm_tests"])
print("\t" + "Static Checks: " + comp["static_checks"])
print("\t" + "Valgrind: " + comp["valgrind"])
print("\t" + "Material budget: " + comp["material_budget"])
print("\t" + "Igprof: " + comp["igprof"])
print("\t" + "Profiling: " + comp["profiling"])
print("\t" + "Comparison Baseline: " + comp["comp_baseline"])
print("\t" + "Comparison Baseline State: " + comp["comp_baseline_state"])
cmsdist_tags = comp["cmsdistTags"]
print("\t" + "cmsdist Tags:" + str(cmsdist_tags))
builds_results = [
res["arch"] + ":" + str(res["passed"]) + ":" + str(res["details"])
for res in comp["builds"]
]
print("\t" + "Builds:" + str(builds_results))
fwlite_results = [
res["arch"] + ":" + str(res["passed"]) + ":" + str(res["details"])
for res in comp["fwlite"]
]
print("\t" + "FWLite:" + str(fwlite_results))
relvals_results = [
res["arch"] + ":" + str(res["passed"]) + ":" + str(res["details"])
for res in comp["relvals"]
]
print("\t" + "RelVals:" + str(relvals_results))
utests_results = [
res["arch"] + ":" + str(res["passed"]) + ":" + str(res["details"])
for res in comp["utests"]
]
print("\t" + "UnitTests:" + str(utests_results))
gpu_utests_results = [
res["arch"] + ":" + str(res["passed"]) + ":" + str(res["details"])
for res in comp["gpu_utests"]
]
print("\t" + "GPUUnitTests:" + str(gpu_utests_results))
addons_results = [res["arch"] + ":" + str(res["passed"]) for res in comp["addons"]]
print("\t" + "AddOns:" + str(addons_results))
merged_prs = [pr["number"] for pr in comp["merged_prs"]]
print("\t" + "PRs:" + str(merged_prs))
print("\t" + "Cmsdist compared tags: " + pformat(comp["cmsdist_compared_tags"]))
print("\t" + "Cmsdist merged prs: " + pformat(comp["cmsdist_merged_prs"]))
from_merge_commit = [
pr["number"] for pr in comp["merged_prs"] if pr["from_merge_commit"]
]
print("\t" + "From merge commit" + str(from_merge_commit))
print("\t" + "RVExceptions: " + str(comp.get("RVExceptions")))
print("\t" + "inProgress: " + str(comp.get("inProgress")))
def fill_missing_cmsdist_tags(results):
"""
Iterates over the IBs comparisons, if an IB doesn't have a tag for an architecture, the previous tag is
assigned. For example, for arch slc6_amd64_gcc481
1. CMSSW_7_1_X_2014-10-02-1500 was built using the tag IB/CMSSW_7_1_X_2014-10-02-1500/slc6_amd64_gcc481
2. There is no tag for CMSSW_7_1_X_2014-10-03-0200 in cmsdist
Then, it assumes that the tag used for CMSSW_7_1_X_2014-10-03-0200 was IB/CMSSW_7_1_X_2014-10-02-1500/slc6_amd64_gcc481
"""
for rq in results:
previous_cmsdist_tags = {}
for comp in rq["comparisons"]:
for arch in comp["tests_archs"]:
current_ib_tag_arch = comp["cmsdistTags"].get(arch)
if current_ib_tag_arch:
previous_cmsdist_tags[arch] = current_ib_tag_arch
else:
if previous_cmsdist_tags.get(arch):
comp["cmsdistTags"][arch] = previous_cmsdist_tags[arch]
else:
comp["cmsdistTags"][arch] = "Not Found"
def get_cmsdist_merge_commits(results):
"""
Will modiffy object in place
"""
for release_queue in results:
previous_cmsdist_tags = {}
release_queue_name = release_queue["release_name"]
for pos, comp in enumerate(release_queue["comparisons"], start=1):
comp["cmsdist_merged_prs"] = {}
comp["cmsdist_compared_tags"] = {}
if pos == len(release_queue["comparisons"]):
# this is special case when we want to compare unreleased IB with branch head
# sinces it is not an IB, there are no build archs yet.
archs_to_iterate_over = RELEASES_ARCHS[release_queue_name]
else:
archs_to_iterate_over = comp["tests_archs"]
for arch in archs_to_iterate_over:
if arch not in RELEASES_ARCHS_WITH_DIST_BRANCH[release_queue_name]:
continue
cmsdist_branch = RELEASES_ARCHS_WITH_DIST_BRANCH[release_queue_name][arch]
if pos == len(release_queue["comparisons"]):
# if this last comparison, it means its not yet an IB
# we want to compare branch HEAD with last tag
# we will compare with remote branch to avoid checking out all the time, this is the reason for
# remotes/origin/{BRANCH_NAME}
current_ib_tag_arch = "remotes/origin/" + cmsdist_branch
# when dumping JSON, we do not want 'remotes/origin/ part
current_ib_tag_arch_to_show = cmsdist_branch
else:
# else, just use current cmsdistTag
current_ib_tag_arch = comp["cmsdistTags"].get(arch)
current_ib_tag_arch_to_show = comp["cmsdistTags"].get(arch)
if arch in previous_cmsdist_tags:
previous_cmsdist_tag = previous_cmsdist_tags[arch]
else:
previous_cmsdist_tag = current_ib_tag_arch
previous_cmsdist_tags[arch] = current_ib_tag_arch
notes = get_merge_prs(
previous_cmsdist_tag,
current_ib_tag_arch,
"{0}/.git".format(CMSDIST_REPO),
CMS_PRS,
repo_name="cmsdist",
)
prs = []
for pr_num in notes:
pr = {"is_merge_commit": False, "from_merge_commit": False}
if notes[pr_num]["branch"] != "master":
if notes[pr_num]["branch"] != cmsdist_branch:
pr["from_merge_commit"] = True
pr["number"] = pr_num
pr["hash"] = notes[pr_num]["hash"]
pr["author_login"] = notes[pr_num]["author"]
pr["title"] = notes[pr_num]["title"]
pr["url"] = "https://github.com/cms-sw/cmsdist/pull/%s" % pr_num
prs.append(pr)
comp["cmsdist_merged_prs"][arch] = prs
comp["cmsdist_compared_tags"][arch] = "{0}..{1}".format(
previous_cmsdist_tag, current_ib_tag_arch_to_show
)
def add_tests_to_results(
results,
unit_tests,
relvals_results,
addon_results,
build_results,
cmsdist_tags_results,
rv_Exceptions_Results,
fwlite_results,
gpu_unit_tests,
python3_results,
invalid_includes,
):
"""
merges the results of the tests with the structure of the IBs tags and the pull requests
it also marks the comparisons that correspond to an IB
"""
for rq in results:
for comp in rq["comparisons"]:
rel_name = comp["compared_tags"].split("-->")[1]
rvsres = relvals_results.get(rel_name)
utres = unit_tests.get(rel_name)
gpu_utres = gpu_unit_tests.get(rel_name)
python3_res = python3_results.get(rel_name)
invalid_includes_res = invalid_includes.get(rel_name)
adonres = addon_results.get(rel_name)
buildsres = build_results.get(rel_name)
fwliteres = fwlite_results.get(rel_name)
cmsdist_tags = cmsdist_tags_results.get(rel_name)
print("CMDIST ", rel_name, ":", cmsdist_tags)
# for tests with arrays
comp["relvals"] = rvsres if rvsres else []
comp["utests"] = utres if utres else []
comp["gpu_utests"] = gpu_utres if gpu_utres else []
comp["python3_tests"] = python3_res if python3_res else []
comp["invalid_includes"] = invalid_includes_res if invalid_includes_res else []
comp["addons"] = adonres if adonres else []
comp["builds"] = buildsres if buildsres else []
comp["fwlite"] = fwliteres if fwliteres else []
comp["cmsdistTags"] = cmsdist_tags if cmsdist_tags else {}
comp["isIB"] = "-" in rel_name
comp["RVExceptions"] = rv_Exceptions_Results.get(rel_name)
if "_X_" in rel_name:
comp["ib_date"] = rel_name.split("_X_", 1)[-1]
else:
comp["ib_date"] = ""
comp["inProgress"] = False
if not comp.get("static_checks"):
comp["static_checks"] = "not-found"
if not comp.get("hlt_tests"):
comp["hlt_tests"] = "not-found"
if not comp.get("crab_tests"):
comp["crab_tests"] = "not-found"
if not comp.get("check-headers"):
comp["check-headers"] = "not-found"
if not comp.get("valgrind"):
comp["valgrind"] = "not-found"
if not comp.get("material_budget"):
comp["material_budget"] = "not-found"
if not comp.get("igprof"):
comp["igprof"] = "not-found"
if not comp.get("vtune"):
comp["vtune"] = "not-found"
if not comp.get("profiling"):
comp["profiling"] = "not-found"
if not comp.get("comp_baseline"):
comp["comp_baseline"] = "not-found"
comp["comp_baseline_state"] = "errors"
if not comp.get("dqm_tests"):
comp["dqm_tests"] = "not-found"
# custom details for new IB page
if not comp.get("material_budget_v2"):
comp["material_budget_v2"] = "not-found"
if not comp.get("material_budget_comparison"):
comp["material_budget_comparison"] = "not-found"
if not comp.get("static_checks_v2"):
comp["static_checks_v2"] = "not-found"
if not comp.get("static_checks_failures"):
comp["static_checks_failures"] = "not-found"
a = [t["arch"] for t in utres] if utres else []
b = [t["arch"] for t in rvsres] if rvsres else []
c = [t["arch"] for t in buildsres] if buildsres else []
not_complete_archs = [arch for arch in c if arch not in a]
for nca in not_complete_archs:
result = {}
result["arch"] = nca
result["file"] = str([res["file"] for res in buildsres if res["arch"] == nca])
result["passed"] = PossibleUnitTestResults.UNKNOWN
result["details"] = {}
comp["utests"].append(result)
comp["tests_archs"] = list(set(a + b + c))
def find_material_budget_results(comparisons, architecture):
"""
Finds for an IB the results of the material_budget
"""
for comp in comparisons:
rel_name = comp["compared_tags"].split("-->")[1]
print("Looking for material_budget results for ", rel_name)
arch, comparison, status = find_one_material_budget(rel_name, architecture)
if arch is None:
comp["material_budget"] = status # returns 'inprogress'
else:
comp["material_budget"] = arch + ":" + comparison
comp["material_budget_v2"] = {"status": status, "arch": arch}
if comparison in [None, "-1"]:
pass
elif comparison == "0":
comp["material_budget_comparison"] = {"status": "found", "results": "ok", "arch": arch}
else:
comp["material_budget_comparison"] = {
"status": "found",
"results": "warning",
"arch": arch,
}
def find_one_test_results(command_to_execute):
print("Running ", command_to_execute)
out, err, ret_code = get_output_command(command_to_execute)
print("Ran:", out, err, ret_code, command_to_execute)
if ret_code == 0:
print("found")
return "found"
print("inprogress")
return "inprogress"
# def find_dup_dict_result(command_to_execute):
# # todo delete
# print("Running ", command_to_execute)
# out, err, ret_code = get_output_command(command_to_execute)
# print("Ran:", out, err, ret_code, command_to_execute)
# if ret_code == 0:
# if int(out) == 0:
# print('passed')