[dart_ci] Special case CIPD package name for arm64

Change-Id: Id1a7a3f11dcf5f4693663074dbbc331e21d8e8cb
Reviewed-on: https://dart-review.googlesource.com/c/recipes/+/203881
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Karl Klose <karlklose@google.com>
diff --git a/recipes/dart/package_dart_ci.expected/basic-mac-arm64.json b/recipes/dart/package_dart_ci.expected/basic-mac-arm64.json
new file mode 100644
index 0000000..c61214a
--- /dev/null
+++ b/recipes/dart/package_dart_ci.expected/basic-mac-arm64.json
@@ -0,0 +1,172 @@
+[
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "RECIPE_MODULE[depot_tools::git]/resources/git_setup.py",
+      "--path",
+      "[START_DIR]/dart_ci",
+      "--url",
+      "https://dart.googlesource.com/dart_ci"
+    ],
+    "name": "git setup"
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "origin",
+      "--progress"
+    ],
+    "cwd": "[START_DIR]/dart_ci",
+    "env": {
+      "PATH": "RECIPE_REPO[depot_tools]:<PATH>"
+    },
+    "infra_step": true,
+    "name": "git fetch"
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "-f",
+      "2d72510e447ab60a9728aeea2362d8be2cbd7789"
+    ],
+    "cwd": "[START_DIR]/dart_ci",
+    "infra_step": true,
+    "name": "git checkout"
+  },
+  {
+    "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/dart_ci",
+    "infra_step": true,
+    "name": "read revision",
+    "~followup_annotations": [
+      "@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@",
+      "@@@SET_BUILD_PROPERTY@got_revision@\"deadbeef\"@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "clean",
+      "-f",
+      "-d",
+      "-x"
+    ],
+    "cwd": "[START_DIR]/dart_ci",
+    "infra_step": true,
+    "name": "git clean"
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "sync"
+    ],
+    "cwd": "[START_DIR]/dart_ci",
+    "infra_step": true,
+    "name": "submodule sync"
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "update",
+      "--init",
+      "--recursive"
+    ],
+    "cwd": "[START_DIR]/dart_ci",
+    "infra_step": true,
+    "name": "submodule update"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CACHE]/cipd_packages",
+      "-ensure-file",
+      "dart/dart-sdk/${platform} version:2.13.1",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:2.13.1--\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"dart/dart-sdk/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[CACHE]/cipd_packages/dart-sdk/bin/dart",
+      "pub",
+      "get"
+    ],
+    "cwd": "[START_DIR]/dart_ci/builder",
+    "env": {
+      "PUB_CACHE": "[CLEANUP]/tmp_tmp_2"
+    },
+    "name": "pub get"
+  },
+  {
+    "cmd": [
+      "[CACHE]/cipd_packages/dart-sdk/bin/dart",
+      "compile",
+      "exe",
+      "[START_DIR]/dart_ci/builder/bin/update_results_database.dart",
+      "-o",
+      "[CLEANUP]/tmp_tmp_1/update_results_database"
+    ],
+    "cwd": "[START_DIR]/dart_ci/builder",
+    "env": {
+      "PUB_CACHE": "[CLEANUP]/tmp_tmp_2"
+    },
+    "name": "compile script"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "create",
+      "-pkg-def",
+      "{\"data\": [{\"file\": \"update_results_database\"}], \"install_mode\": \"copy\", \"package\": \"dart/ci/builder_scripts/mac-arm64\", \"root\": \"[CLEANUP]/tmp_tmp_1\"}",
+      "-hash-algo",
+      "sha256",
+      "-ref",
+      "latest",
+      "-tag",
+      "git_revision:deadbeef",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "create dart/ci/builder_scripts/mac-arm64",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
+      "@@@STEP_LOG_LINE@json.output@    \"package\": \"dart/ci/builder_scripts/mac-arm64\"@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@",
+      "@@@STEP_LINK@40-chars-fake-of-the-package-instance_id@https://chrome-infra-packages.appspot.com/p/dart/ci/builder_scripts/mac-arm64/+/40-chars-fake-of-the-package-instance_id@@@"
+    ]
+  },
+  {
+    "name": "$result"
+  }
+]
\ No newline at end of file
diff --git a/recipes/dart/package_dart_ci.py b/recipes/dart/package_dart_ci.py
index 165fbcc..6f0db4c 100644
--- a/recipes/dart/package_dart_ci.py
+++ b/recipes/dart/package_dart_ci.py
@@ -44,7 +44,9 @@
     api.step('compile script',
              [dart, 'compile', 'exe', input_file, '-o', output_file])
   # Create CIPD package from scripts.
-  package_name = 'dart/ci/builder_scripts/${platform}'
+  builder = str(api.buildbucket.builder_name)
+  package_name = 'dart/ci/builder_scripts/mac-arm64' if builder.endswith(
+      'mac-arm64') else 'dart/ci/builder_scripts/${platform}'
   pkg = api.cipd.PackageDefinition(package_name, output_root, 'copy')
   pkg.add_file(output_file)
   api.cipd.create_from_pkg(
@@ -54,17 +56,16 @@
 def GenTests(api):
   yield api.test(
       'basic',
-      api.buildbucket.ci_build(
-          builder='dart_ci_scripts',
-          git_repo='https://dart.googlesource.com/sdk',
-          project='dart'),
+      api.buildbucket.ci_build(builder='dart-ci-scripts-linux'),
+  )
+
+  yield api.test(
+      'basic-mac-arm64',
+      api.buildbucket.ci_build(builder='dart-ci-scripts-mac-arm64'),
   )
 
   yield api.test(
       'basic-with-revision',
       api.buildbucket.ci_build(
-          builder='dart_ci_scripts',
-          revision='refs/changes/20/203220/9',
-          git_repo='https://dart.googlesource.com/sdk',
-          project='dart'),
+          builder='dart-ci-scripts', revision='refs/changes/20/203220/9'),
   )