Support openpay checkout

To enable openpay repo checkout, add property `openpay: true` to the target config in .ci.yaml.

Note that only prod builders have access to access the repo.

Change-Id: I31f039035ca2c610885469657e76b0f14ccc35ab
Bug: b/231462882
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/31583
Commit-Queue: Keyong Han <keyonghan@google.com>
Reviewed-by: Godofredo Contreras <godofredoc@google.com>
diff --git a/recipe_modules/repo_util/api.py b/recipe_modules/repo_util/api.py
index df6aa0a..858d3bb 100644
--- a/recipe_modules/repo_util/api.py
+++ b/recipe_modules/repo_util/api.py
@@ -9,13 +9,19 @@
     'infra': 'https://flutter.googlesource.com/infra',
     'monorepo': 'https://dart.googlesource.com/monorepo',
     'packages': 'https://flutter.googlesource.com/mirrors/packages',
-    'plugins': 'https://flutter.googlesource.com/mirrors/plugins'
+    'plugins': 'https://flutter.googlesource.com/mirrors/plugins',
+    'openpay': 'https://dash-internal.googlesource.com/openpay',
 }
 
 # TODO(keyonghan): deprecate when all repos are migrated to main.
 REPO_BRANCHES = {
-    'flutter': 'master', 'engine': 'main', 'cocoon': 'main', 'infra': 'main',
-    'packages': 'main', 'plugins': 'main'
+  'flutter': 'master',
+  'engine': 'main',
+  'cocoon': 'main',
+  'infra': 'main',
+  'packages': 'main',
+  'plugins': 'main',
+  'openpay': 'main',
 }
 
 import re
diff --git a/recipe_modules/repo_util/examples/full.expected/monorepo_wrong_host.json b/recipe_modules/repo_util/examples/full.expected/monorepo_wrong_host.json
index a74e0aa..597bd92 100644
--- a/recipe_modules/repo_util/examples/full.expected/monorepo_wrong_host.json
+++ b/recipe_modules/repo_util/examples/full.expected/monorepo_wrong_host.json
@@ -1005,7 +1005,7 @@
       "Traceback (most recent call last):",
       "  File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/examples/full.py\", line 32, in RunSteps",
       "    api.repo_util.monorepo_checkout(api.path['start_dir'], {}, {})",
-      "  File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/api.py\", line 120, in monorepo_checkout",
+      "  File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/api.py\", line 126, in monorepo_checkout",
       "    raise ValueError(",
       "ValueError('Input reference is not on dart.googlesource.com/monorepo')"
     ]
diff --git a/recipe_modules/repo_util/examples/unsupported.expected/unsupported.json b/recipe_modules/repo_util/examples/unsupported.expected/unsupported.json
index 04789ef..622f444 100644
--- a/recipe_modules/repo_util/examples/unsupported.expected/unsupported.json
+++ b/recipe_modules/repo_util/examples/unsupported.expected/unsupported.json
@@ -9,7 +9,7 @@
       "Traceback (most recent call last):",
       "  File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/examples/unsupported.py\", line 15, in RunSteps",
       "    api.repo_util.checkout('unsupported_repo', repo_dir)",
-      "  File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/api.py\", line 195, in checkout",
+      "  File \"RECIPE_REPO[flutter]/recipe_modules/repo_util/api.py\", line 201, in checkout",
       "    raise ValueError('Unsupported repo: %s' % name)",
       "ValueError('Unsupported repo: unsupported_repo')"
     ]
diff --git a/recipes/devicelab/devicelab_drone.expected/basic.json b/recipes/devicelab/devicelab_drone.expected/basic.json
index 3f8643b..958d1bd 100644
--- a/recipes/devicelab/devicelab_drone.expected/basic.json
+++ b/recipes/devicelab/devicelab_drone.expected/basic.json
@@ -218,6 +218,201 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Checkout flutter/openpay"
+  },
+  {
+    "cmd": [
+      "python3",
+      "-u",
+      "RECIPE_MODULE[depot_tools::git]/resources/git_setup.py",
+      "--path",
+      "[CLEANUP]/tmp_tmp_2/openpay",
+      "--url",
+      "https://dash-internal.googlesource.com/openpay"
+    ],
+    "luci_context": {
+      "realm": {
+        "name": "test:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "Checkout flutter/openpay.git setup",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "origin",
+      "main",
+      "--recurse-submodules",
+      "--progress",
+      "--tags"
+    ],
+    "cwd": "[CLEANUP]/tmp_tmp_2/openpay",
+    "env": {
+      "PATH": "RECIPE_REPO[depot_tools]:<PATH>"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "test:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "Checkout flutter/openpay.git fetch",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "-f",
+      "FETCH_HEAD"
+    ],
+    "cwd": "[CLEANUP]/tmp_tmp_2/openpay",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "test:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "Checkout flutter/openpay.git checkout",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[CLEANUP]/tmp_tmp_2/openpay",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "test:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "Checkout flutter/openpay.read revision",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@",
+      "@@@SET_BUILD_PROPERTY@got_revision@\"deadbeef\"@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "clean",
+      "-f",
+      "-d",
+      "-x"
+    ],
+    "cwd": "[CLEANUP]/tmp_tmp_2/openpay",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "test:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "Checkout flutter/openpay.git clean",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "sync"
+    ],
+    "cwd": "[CLEANUP]/tmp_tmp_2/openpay",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "test:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "Checkout flutter/openpay.submodule sync",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "update",
+      "--init",
+      "--recursive"
+    ],
+    "cwd": "[CLEANUP]/tmp_tmp_2/openpay",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "test:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "Checkout flutter/openpay.submodule update",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "git",
       "log",
@@ -335,7 +530,7 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/vpython",
+      "[CLEANUP]/tmp_tmp_3/vpython",
       "-ensure-file",
       "infra/tools/luci/vpython/${platform} latest",
       "-max-threads",
@@ -394,7 +589,7 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "luci_context": {
@@ -436,7 +631,7 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -478,10 +673,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "luci_context": {
@@ -531,10 +726,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "luci_context": {
@@ -596,10 +791,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -650,10 +845,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -712,10 +907,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -765,10 +960,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -812,10 +1007,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -859,10 +1054,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -906,10 +1101,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -953,10 +1148,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -1004,10 +1199,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
@@ -1048,10 +1243,10 @@
       "PATH": [
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython",
+        "[CLEANUP]/tmp_tmp_3/vpython",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin",
         "[CLEANUP]/tmp_tmp_1/flutter sdk/bin/cache/dart-sdk/bin",
-        "[CLEANUP]/tmp_tmp_2/vpython"
+        "[CLEANUP]/tmp_tmp_3/vpython"
       ]
     },
     "infra_step": true,
diff --git a/recipes/devicelab/devicelab_drone.py b/recipes/devicelab/devicelab_drone.py
index 0cb5017..2d73761 100644
--- a/recipes/devicelab/devicelab_drone.py
+++ b/recipes/devicelab/devicelab_drone.py
@@ -60,6 +60,15 @@
       api.properties.get('git_url'),
       api.properties.get('git_ref'),
   )
+  # Checkout openpay repo if property exists in builder config.
+  if api.properties.get('openpay'):
+    openpay_path = api.path.mkdtemp().join('openpay')
+    api.repo_util.checkout(
+        'openpay',
+        openpay_path,
+        ref='refs/heads/main',
+    )
+
   with api.context(cwd=flutter_path):
     commit_time = api.git(
         'git commit time',
@@ -316,7 +325,7 @@
   )
   yield api.test(
       "basic",
-      api.properties(buildername='Linux abc', task_name='abc', git_branch='master'),
+      api.properties(buildername='Linux abc', task_name='abc', git_branch='master', openpay=True),
       api.repo_util.flutter_environment_data(checkout_dir=checkout_path),
       api.step_data(
           'run abc',