Reland: "Start uploading docs to GCS."

The previous cl was reverted because both "docs test" and "docs deploy"
were uploading the zip artifact and the builders were not allowing to
override the destination artifacts.

With this updated version only "docs deploy" will be uploading the
artifacts and a second change is enabling override on retry for
framework builders.

Bug: flutter/flutter#111921
Change-Id: Ifcbadfe912922544d7ce4dce50bf9392cd5c1088
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/34101
Commit-Queue: Godofredo Contreras <godofredoc@google.com>
Reviewed-by: Casey Hillers <chillers@google.com>
diff --git a/recipe_modules/adhoc_validation/__init__.py b/recipe_modules/adhoc_validation/__init__.py
index 80ac1c5..5ab5be1 100644
--- a/recipe_modules/adhoc_validation/__init__.py
+++ b/recipe_modules/adhoc_validation/__init__.py
@@ -1,4 +1,5 @@
 DEPS = [
+    'flutter/bucket_util',
     'flutter/firebase',
     'flutter/flutter_deps',
     'flutter/kms',
diff --git a/recipe_modules/adhoc_validation/api.py b/recipe_modules/adhoc_validation/api.py
index 1881191..2a87b67 100644
--- a/recipe_modules/adhoc_validation/api.py
+++ b/recipe_modules/adhoc_validation/api.py
@@ -59,9 +59,9 @@
             self.m.test_utils.run_test(validation, [resource_name])
       else:
         with self.m.context(env=env, env_prefixes=env_prefixes):
-          self.m.test_utils.run_test(validation, [resource_name])
+          docs_path = checkout_path.join('dev', 'docs')
           if validation == 'docs' and self.m.properties.get('firebase_project'):
-            docs_path = checkout_path.join('dev', 'docs')
+            self.m.bucket_util.upload_folder('Upload API Docs', docs_path, 'doc', "api_docs.zip")
             project = self.m.properties.get('firebase_project')
             self.m.firebase.deploy_docs(
                 env=env,
diff --git a/recipe_modules/adhoc_validation/examples/full.expected/linux.json b/recipe_modules/adhoc_validation/examples/full.expected/linux.json
index da960ab..94cc53e 100644
--- a/recipe_modules/adhoc_validation/examples/full.expected/linux.json
+++ b/recipe_modules/adhoc_validation/examples/full.expected/linux.json
@@ -44,7 +44,8 @@
   },
   {
     "cmd": [
-      "RECIPE_MODULE[flutter::adhoc_validation]/resources/docs.sh"
+      "python",
+      "RECIPE_MODULE[flutter::zip]/resources/zip.py"
     ],
     "env": {
       "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
@@ -63,14 +64,43 @@
         "[START_DIR]/flutter sdk/bin/cache/dart-sdk/bin"
       ]
     },
-    "name": "Docs.docs",
-    "timeout": 3600,
+    "name": "Docs.Zip doc",
+    "stdin": "{\"entries\": [{\"path\": \"[START_DIR]/flutter sdk/dev/docs/doc\", \"type\": \"dir\"}], \"output\": \"[CLEANUP]/tmp_tmp_1/api_docs.zip\", \"root\": \"[START_DIR]/flutter sdk/dev/docs\"}",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@",
-      "@@@STEP_LOG_LINE@test_stdout@@@@",
-      "@@@STEP_LOG_END@test_stdout@@@",
-      "@@@STEP_LOG_LINE@test_stderr@@@@",
-      "@@@STEP_LOG_END@test_stderr@@@"
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "rmtree",
+      "[CLEANUP]/tmp_tmp_1"
+    ],
+    "env": {
+      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
+      "GIT_BRANCH": "",
+      "LUCI_BRANCH": "",
+      "LUCI_CI": "True",
+      "LUCI_PR": "",
+      "OS": "linux",
+      "PUB_CACHE": "[START_DIR]/.pub-cache",
+      "REVISION": "",
+      "SDK_CHECKOUT_PATH": "[START_DIR]/flutter sdk"
+    },
+    "env_prefixes": {
+      "PATH": [
+        "[START_DIR]/flutter sdk/bin",
+        "[START_DIR]/flutter sdk/bin/cache/dart-sdk/bin"
+      ]
+    },
+    "infra_step": true,
+    "name": "Docs.temp dir for Upload API Docs",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
     ]
   },
   {
@@ -114,7 +144,7 @@
       "/path/to/tmp/json",
       "copy",
       "extra.secret.token.should.not.be.logged",
-      "[CLEANUP]/tmp_tmp_1"
+      "[CLEANUP]/tmp_tmp_2"
     ],
     "env": {
       "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
@@ -164,7 +194,7 @@
       "PUB_CACHE": "[START_DIR]/.pub-cache",
       "REVISION": "",
       "SDK_CHECKOUT_PATH": "[START_DIR]/flutter sdk",
-      "TOKEN_PATH": "[CLEANUP]/tmp_tmp_1"
+      "TOKEN_PATH": "[CLEANUP]/tmp_tmp_2"
     },
     "env_prefixes": {
       "PATH": [
@@ -193,7 +223,7 @@
       "PUB_CACHE": "[START_DIR]/.pub-cache",
       "REVISION": "",
       "SDK_CHECKOUT_PATH": "[START_DIR]/flutter sdk",
-      "TOKEN_PATH": "[CLEANUP]/tmp_tmp_1"
+      "TOKEN_PATH": "[CLEANUP]/tmp_tmp_2"
     },
     "env_prefixes": {
       "PATH": [
diff --git a/recipe_modules/adhoc_validation/examples/full.expected/mac_nodeps.json b/recipe_modules/adhoc_validation/examples/full.expected/mac_nodeps.json
index b70638a..b72c540 100644
--- a/recipe_modules/adhoc_validation/examples/full.expected/mac_nodeps.json
+++ b/recipe_modules/adhoc_validation/examples/full.expected/mac_nodeps.json
@@ -43,37 +43,6 @@
     ]
   },
   {
-    "cmd": [
-      "RECIPE_MODULE[flutter::adhoc_validation]/resources/docs.sh"
-    ],
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "GIT_BRANCH": "",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "darwin",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "REVISION": "",
-      "SDK_CHECKOUT_PATH": "[START_DIR]/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[START_DIR]/flutter sdk/bin",
-        "[START_DIR]/flutter sdk/bin/cache/dart-sdk/bin"
-      ]
-    },
-    "name": "Docs.docs",
-    "timeout": 3600,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@",
-      "@@@STEP_LOG_LINE@test_stdout@@@@",
-      "@@@STEP_LOG_END@test_stdout@@@",
-      "@@@STEP_LOG_LINE@test_stderr@@@@",
-      "@@@STEP_LOG_END@test_stderr@@@"
-    ]
-  },
-  {
     "name": "$result"
   }
 ]
\ No newline at end of file
diff --git a/recipe_modules/adhoc_validation/examples/full.expected/win.json b/recipe_modules/adhoc_validation/examples/full.expected/win.json
index ce40448..2ebfb5f 100644
--- a/recipe_modules/adhoc_validation/examples/full.expected/win.json
+++ b/recipe_modules/adhoc_validation/examples/full.expected/win.json
@@ -14,37 +14,6 @@
     "name": "Docs"
   },
   {
-    "cmd": [
-      "RECIPE_MODULE[flutter::adhoc_validation]\\resources\\docs.bat"
-    ],
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "GIT_BRANCH": "",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "win",
-      "PUB_CACHE": "[START_DIR]\\.pub-cache",
-      "REVISION": "",
-      "SDK_CHECKOUT_PATH": "[START_DIR]\\flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[START_DIR]\\flutter sdk\\bin",
-        "[START_DIR]\\flutter sdk\\bin\\cache\\dart-sdk\\bin"
-      ]
-    },
-    "name": "Docs.docs",
-    "timeout": 3600,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@",
-      "@@@STEP_LOG_LINE@test_stdout@@@@",
-      "@@@STEP_LOG_END@test_stdout@@@",
-      "@@@STEP_LOG_LINE@test_stderr@@@@",
-      "@@@STEP_LOG_END@test_stderr@@@"
-    ]
-  },
-  {
     "name": "$result"
   }
 ]
\ No newline at end of file
diff --git a/recipe_modules/bucket_util/api.py b/recipe_modules/bucket_util/api.py
index e7b1d40..264f98e 100644
--- a/recipe_modules/bucket_util/api.py
+++ b/recipe_modules/bucket_util/api.py
@@ -72,7 +72,8 @@
       remote_name = '%s/%s' % (platform, zip_name) if platform else zip_name
       local_zip = temp_dir.join(zip_name)
       remote_zip = self.get_cloud_path(remote_name)
-      parent_directory = self.m.path['cache'].join('builder', parent_directory)
+      if isinstance(parent_directory, str):
+        parent_directory = self.m.path['cache'].join('builder', parent_directory)
       pkg = self.m.zip.make_package(parent_directory, local_zip)
       pkg.add_directory(parent_directory.join(folder_name))
 
diff --git a/recipes/flutter/flutter.expected/validators.json b/recipes/flutter/flutter.expected/validators.json
index 9f3f0de..0e28cb2 100644
--- a/recipes/flutter/flutter.expected/validators.json
+++ b/recipes/flutter/flutter.expected/validators.json
@@ -235,40 +235,6 @@
     ]
   },
   {
-    "cmd": [
-      "RECIPE_MODULE[flutter::adhoc_validation]/resources/analyze.sh"
-    ],
-    "cwd": "[START_DIR]/flutter sdk",
-    "env": {
-      "DEPOT_TOOLS": "RECIPE_REPO[depot_tools]",
-      "GIT_BRANCH": "",
-      "LUCI_BRANCH": "",
-      "LUCI_CI": "True",
-      "LUCI_PR": "",
-      "OS": "linux",
-      "PUB_CACHE": "[START_DIR]/.pub-cache",
-      "REVISION": "",
-      "SDK_CHECKOUT_PATH": "[START_DIR]/flutter sdk"
-    },
-    "env_prefixes": {
-      "PATH": [
-        "[START_DIR]/flutter sdk/bin",
-        "[START_DIR]/flutter sdk/bin/cache/dart-sdk/bin",
-        "[START_DIR]/flutter sdk/bin",
-        "[START_DIR]/flutter sdk/bin/cache/dart-sdk/bin"
-      ]
-    },
-    "name": "dart analyze.analyze",
-    "timeout": 3600,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@",
-      "@@@STEP_LOG_LINE@test_stdout@@@@",
-      "@@@STEP_LOG_END@test_stdout@@@",
-      "@@@STEP_LOG_LINE@test_stderr@@@@",
-      "@@@STEP_LOG_END@test_stderr@@@"
-    ]
-  },
-  {
     "cmd": [],
     "name": "Killing Processes"
   },