pw_presubmit: Add dry_run property

Change-Id: Iba104a78f3811a6fa12b74d3e5342b8abf4f7280
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/409699
diff --git a/recipe_modules/pw_presubmit/api.py b/recipe_modules/pw_presubmit/api.py
index c9fa42d..a6fe61e 100644
--- a/recipe_modules/pw_presubmit/api.py
+++ b/recipe_modules/pw_presubmit/api.py
@@ -394,6 +394,7 @@
                                 checkout=ctx.checkout,
                                 upload_to_cipd=(
                                     not self.m.buildbucket_util.is_dev_or_try
+                                    and not ctx.options.dry_run
                                 ),
                                 cas_digests=ctx.cas_digests,
                             )
diff --git a/recipe_modules/pw_presubmit/options.proto b/recipe_modules/pw_presubmit/options.proto
index 5ac848c..4e9b6af 100644
--- a/recipe_modules/pw_presubmit/options.proto
+++ b/recipe_modules/pw_presubmit/options.proto
@@ -62,4 +62,7 @@
 
   // Destination GCS bucket for uploads.
   string gcs_bucket = 12;
+
+  // Whether to take external actions (e.g., GCS, CIPD, etc.).
+  bool dry_run = 13;
 }
diff --git a/recipe_modules/pw_presubmit/test_api.py b/recipe_modules/pw_presubmit/test_api.py
index 4d03694..0769fc3 100644
--- a/recipe_modules/pw_presubmit/test_api.py
+++ b/recipe_modules/pw_presubmit/test_api.py
@@ -42,6 +42,7 @@
         use_time_for_rng_seed: bool = False,
         override_gn_arg: Sequence[str] = (),
         gcs_bucket: str = '',
+        dry_run: bool = False,
     ) -> options.Options:
         opts = options.Options()
         opts.command_name = command_name
@@ -57,4 +58,5 @@
         opts.use_time_for_rng_seed = use_time_for_rng_seed
         opts.override_gn_arg.extend(override_gn_arg)
         opts.gcs_bucket = gcs_bucket
+        opts.dry_run = dry_run
         return opts