74
74
75
75
git_hash_help = "git hash"
76
76
77
+ use_latest_jit_change_help = """\
78
+ Starting with the given git hash, look backwards in the git log for the first change that includes any JIT
79
+ change. We want to ensure that any git hash uploaded to the JIT rolling build store is a JIT change. This
80
+ addresses a problem where Azure DevOps sometimes builds changes that come soon after a JIT change, instead of
81
+ the JIT change itself.
82
+ """
83
+
77
84
target_dir_help = "Directory to put the downloaded JIT."
78
85
79
86
skip_cleanup_help = "Skip intermediate file removal."
97
104
upload_parser = subparsers .add_parser ("upload" , description = upload_description , parents = [common_parser ])
98
105
99
106
upload_parser .add_argument ("-git_hash" , required = True , help = git_hash_help )
107
+ upload_parser .add_argument ("--use_latest_jit_change" , action = "store_true" , help = use_latest_jit_change_help )
100
108
upload_parser .add_argument ("-az_storage_key" , help = "Key for the clrjit Azure Storage location. Default: use the value of the CLRJIT_AZ_KEY environment variable." )
101
109
upload_parser .add_argument ("--skip_cleanup" , action = "store_true" , help = skip_cleanup_help )
102
110
@@ -458,6 +466,32 @@ def upload_blob(file, blob_name):
458
466
# pdb_paths = [os.path.join(pdb_dir, item) for item in os.listdir(pdb_dir) if re.match(r'.*clrjit.*', item)]
459
467
# files += pdb_paths
460
468
469
+ # Figure out which git hash to use for the upload. By default, it is the required coreclr_args.git_hash argument.
470
+ # However, if "--use_latest_jit_change" is passed, we look backwards in the git log for the nearest git commit
471
+ # with a JIT change (it could, and often will be, the same as the argument git_hash).
472
+ jit_git_hash = coreclr_args .git_hash
473
+
474
+ if coreclr_args .use_latest_jit_change :
475
+ # Do all the remaining commands, including a number of 'git' commands including relative paths,
476
+ # from the root of the runtime repo.
477
+
478
+ with ChangeDir (coreclr_args .runtime_repo_location ):
479
+ # Enumerate the last change, starting with the jit_git_hash, that included JIT changes.
480
+ command = [ "git" , "log" , "--pretty=format:%H" , jit_git_hash , "-1" , "--" , "src/coreclr/jit/*" ]
481
+ print ("Invoking: {}" .format (" " .join (command )))
482
+ proc = subprocess .Popen (command , stdout = subprocess .PIPE )
483
+ stdout_change_list , _ = proc .communicate ()
484
+ return_code = proc .returncode
485
+ change_list_hashes = []
486
+ if return_code == 0 :
487
+ change_list_hashes = stdout_change_list .decode ('utf-8' ).strip ().splitlines ()
488
+
489
+ if len (change_list_hashes ) == 0 :
490
+ print ("Couldn't find any JIT changes! Just using the argument git_hash" )
491
+ else :
492
+ jit_git_hash = change_list_hashes [0 ]
493
+ print ("Using git_hash {}" .format (jit_git_hash ))
494
+
461
495
print ("Uploading:" )
462
496
for item in files :
463
497
print (" {}" .format (item ))
@@ -472,7 +506,7 @@ def upload_blob(file, blob_name):
472
506
raise RuntimeError ("Missing azure storage package." )
473
507
474
508
blob_service_client = BlobServiceClient (account_url = az_blob_storage_account_uri , credential = coreclr_args .az_storage_key )
475
- blob_folder_name = "{}/{}/{}/{}/{}" .format (az_builds_root_folder , coreclr_args . git_hash , coreclr_args .host_os , coreclr_args .arch , coreclr_args .build_type )
509
+ blob_folder_name = "{}/{}/{}/{}/{}" .format (az_builds_root_folder , jit_git_hash , coreclr_args .host_os , coreclr_args .arch , coreclr_args .build_type )
476
510
477
511
total_bytes_uploaded = 0
478
512
@@ -684,6 +718,11 @@ def setup_spmi_location_arg(spmi_location):
684
718
lambda unused : True ,
685
719
"Unable to set git_hash" )
686
720
721
+ coreclr_args .verify (args ,
722
+ "use_latest_jit_change" ,
723
+ lambda unused : True ,
724
+ "Unable to set use_latest_jit_change" )
725
+
687
726
coreclr_args .verify (args ,
688
727
"az_storage_key" ,
689
728
lambda item : item is not None ,
0 commit comments