Create empty zip files (#61828)
authorKunal Pathak <Kunal.Pathak@microsoft.com>
Fri, 19 Nov 2021 18:43:54 +0000 (10:43 -0800)
committerGitHub <noreply@github.com>
Fri, 19 Nov 2021 18:43:54 +0000 (10:43 -0800)
src/coreclr/scripts/superpmi_asmdiffs.py

index ffd1fd9..8a30850 100644 (file)
@@ -81,6 +81,7 @@ def copy_dasm_files(spmi_location, upload_directory, tag_name):
     if not os.path.isdir(upload_directory):
         os.makedirs(upload_directory)
 
+    dasm_file_present = False
     # Create temp directory to copy all issues to upload. We don't want to create a sub-folder
     # inside issues_directory because that will also get included twice.
     with TempDir() as prep_directory:
@@ -98,9 +99,18 @@ def copy_dasm_files(spmi_location, upload_directory, tag_name):
                     os.makedirs(dst_directory)
                 try:
                     shutil.copy2(dasm_src_file, dasm_dst_file)
+                    dasm_file_present = True
                 except PermissionError as pe_error:
                     print('Ignoring PermissionError: {0}'.format(pe_error))
 
+        # If there are no diffs, create an zip file with single file in it.
+        # Otherwise, Azdo considers it as failed job.
+        # See https://github.com/dotnet/arcade/issues/8200
+        if not dasm_file_present:
+            no_diff = os.path.join(prep_directory, "nodiff.txt")
+            with open(no_diff, "w") as no_diff_file:
+                no_diff_file.write("No diffs found!")
+
         # Zip compress the files we will upload
         zip_path = os.path.join(prep_directory, "Asmdiffs_" + tag_name)
         print("Creating archive: " + zip_path)