Add Dawn DEPS branched trybots

Sets the Chromium Dawn DEPS builders to be available as
branched trybots.

Bug: chromium:1432491
Change-Id: I319e76c3c0fc7d2bc168c0fdd6c07eebd8165046
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132272
Commit-Queue: Brian Sheedy <bsheedy@google.com>
Kokoro: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Brian Sheedy <bsheedy@google.com>
diff --git a/infra/config/global/generated/commit-queue.cfg b/infra/config/global/generated/commit-queue.cfg
index 864c2a6..b4d6da0 100644
--- a/infra/config/global/generated/commit-queue.cfg
+++ b/infra/config/global/generated/commit-queue.cfg
@@ -18,6 +18,9 @@
     projects {
       name: "dawn"
       ref_regexp: "refs/heads/.+"
+      ref_regexp_exclude: "refs/heads/chromium/5615"
+      ref_regexp_exclude: "refs/heads/chromium/5672"
+      ref_regexp_exclude: "refs/heads/chromium/5735"
     }
   }
   verifiers {
@@ -89,3 +92,237 @@
     }
   }
 }
+config_groups {
+  name: "Dawn-CQ-m112"
+  gerrit {
+    url: "https://dawn-review.googlesource.com"
+    projects {
+      name: "dawn"
+      ref_regexp: "refs/heads/chromium/5615"
+    }
+  }
+  verifiers {
+    gerrit_cq_ability {
+      committer_list: "project-dawn-committers"
+      dry_run_access_list: "project-dawn-tryjob-access"
+    }
+    tryjob {
+      builders {
+        name: "chromium-m112/try/dawn-linux-x64-deps-rel"
+      }
+      builders {
+        name: "chromium-m112/try/dawn-mac-x64-deps-rel"
+      }
+      builders {
+        name: "chromium-m112/try/dawn-win10-x64-deps-rel"
+      }
+      builders {
+        name: "chromium-m112/try/dawn-win10-x86-deps-rel"
+        includable_only: true
+      }
+      builders {
+        name: "dawn/try/linux-clang-dbg-x64"
+      }
+      builders {
+        name: "dawn/try/linux-clang-dbg-x86"
+      }
+      builders {
+        name: "dawn/try/linux-clang-rel-x64"
+      }
+      builders {
+        name: "dawn/try/linux-clang-rel-x86"
+      }
+      builders {
+        name: "dawn/try/mac-dbg"
+      }
+      builders {
+        name: "dawn/try/mac-rel"
+      }
+      builders {
+        name: "dawn/try/presubmit"
+        disable_reuse: true
+      }
+      builders {
+        name: "dawn/try/win-clang-dbg-x64"
+      }
+      builders {
+        name: "dawn/try/win-clang-dbg-x86"
+      }
+      builders {
+        name: "dawn/try/win-clang-rel-x64"
+      }
+      builders {
+        name: "dawn/try/win-clang-rel-x86"
+      }
+      builders {
+        name: "dawn/try/win-msvc-dbg-x64"
+      }
+      builders {
+        name: "dawn/try/win-msvc-rel-x64"
+      }
+      retry_config {
+        single_quota: 1
+        global_quota: 2
+        failure_weight: 1
+        transient_failure_weight: 1
+        timeout_weight: 2
+      }
+    }
+  }
+}
+config_groups {
+  name: "Dawn-CQ-m113"
+  gerrit {
+    url: "https://dawn-review.googlesource.com"
+    projects {
+      name: "dawn"
+      ref_regexp: "refs/heads/chromium/5672"
+    }
+  }
+  verifiers {
+    gerrit_cq_ability {
+      committer_list: "project-dawn-committers"
+      dry_run_access_list: "project-dawn-tryjob-access"
+    }
+    tryjob {
+      builders {
+        name: "chromium-m113/try/dawn-linux-x64-deps-rel"
+      }
+      builders {
+        name: "chromium-m113/try/dawn-mac-x64-deps-rel"
+      }
+      builders {
+        name: "chromium-m113/try/dawn-win10-x64-deps-rel"
+      }
+      builders {
+        name: "chromium-m113/try/dawn-win10-x86-deps-rel"
+        includable_only: true
+      }
+      builders {
+        name: "dawn/try/linux-clang-dbg-x64"
+      }
+      builders {
+        name: "dawn/try/linux-clang-dbg-x86"
+      }
+      builders {
+        name: "dawn/try/linux-clang-rel-x64"
+      }
+      builders {
+        name: "dawn/try/linux-clang-rel-x86"
+      }
+      builders {
+        name: "dawn/try/mac-dbg"
+      }
+      builders {
+        name: "dawn/try/mac-rel"
+      }
+      builders {
+        name: "dawn/try/presubmit"
+        disable_reuse: true
+      }
+      builders {
+        name: "dawn/try/win-clang-dbg-x64"
+      }
+      builders {
+        name: "dawn/try/win-clang-dbg-x86"
+      }
+      builders {
+        name: "dawn/try/win-clang-rel-x64"
+      }
+      builders {
+        name: "dawn/try/win-clang-rel-x86"
+      }
+      builders {
+        name: "dawn/try/win-msvc-dbg-x64"
+      }
+      builders {
+        name: "dawn/try/win-msvc-rel-x64"
+      }
+      retry_config {
+        single_quota: 1
+        global_quota: 2
+        failure_weight: 1
+        transient_failure_weight: 1
+        timeout_weight: 2
+      }
+    }
+  }
+}
+config_groups {
+  name: "Dawn-CQ-m114"
+  gerrit {
+    url: "https://dawn-review.googlesource.com"
+    projects {
+      name: "dawn"
+      ref_regexp: "refs/heads/chromium/5735"
+    }
+  }
+  verifiers {
+    gerrit_cq_ability {
+      committer_list: "project-dawn-committers"
+      dry_run_access_list: "project-dawn-tryjob-access"
+    }
+    tryjob {
+      builders {
+        name: "chromium-m114/try/dawn-linux-x64-deps-rel"
+      }
+      builders {
+        name: "chromium-m114/try/dawn-mac-x64-deps-rel"
+      }
+      builders {
+        name: "chromium-m114/try/dawn-win10-x64-deps-rel"
+      }
+      builders {
+        name: "chromium-m114/try/dawn-win10-x86-deps-rel"
+        includable_only: true
+      }
+      builders {
+        name: "dawn/try/linux-clang-dbg-x64"
+      }
+      builders {
+        name: "dawn/try/linux-clang-dbg-x86"
+      }
+      builders {
+        name: "dawn/try/linux-clang-rel-x64"
+      }
+      builders {
+        name: "dawn/try/linux-clang-rel-x86"
+      }
+      builders {
+        name: "dawn/try/mac-dbg"
+      }
+      builders {
+        name: "dawn/try/mac-rel"
+      }
+      builders {
+        name: "dawn/try/presubmit"
+        disable_reuse: true
+      }
+      builders {
+        name: "dawn/try/win-clang-dbg-x64"
+      }
+      builders {
+        name: "dawn/try/win-clang-dbg-x86"
+      }
+      builders {
+        name: "dawn/try/win-clang-rel-x64"
+      }
+      builders {
+        name: "dawn/try/win-clang-rel-x86"
+      }
+      builders {
+        name: "dawn/try/win-msvc-dbg-x64"
+      }
+      builders {
+        name: "dawn/try/win-msvc-rel-x64"
+      }
+      retry_config {
+        single_quota: 1
+        global_quota: 2
+        failure_weight: 1
+        transient_failure_weight: 1
+        timeout_weight: 2
+      }
+    }
+  }
+}
diff --git a/infra/config/global/generated/project.cfg b/infra/config/global/generated/project.cfg
index acfee71..8b350be 100644
--- a/infra/config/global/generated/project.cfg
+++ b/infra/config/global/generated/project.cfg
@@ -7,7 +7,7 @@
 name: "dawn"
 access: "group:all"
 lucicfg {
-  version: "1.31.3"
+  version: "1.39.8"
   package_dir: ".."
   config_dir: "generated"
   entry_point: "main.star"
diff --git a/infra/config/global/main.star b/infra/config/global/main.star
index d774c4f..6747e4c 100755
--- a/infra/config/global/main.star
+++ b/infra/config/global/main.star
@@ -8,6 +8,8 @@
 main.star: lucicfg configuration for Dawn's standalone builers.
 """
 
+load("//project.star", "ACTIVE_MILESTONES")
+
 # Use LUCI Scheduler BBv2 names and add Scheduler realms configs.
 lucicfg.enable_experiment("crbug.com/1182002")
 
@@ -348,6 +350,29 @@
             cq_group = "Dawn-CQ",
             builder = "dawn:try/" + name,
         )
+        # These builders run fine unbranched on branch CLs, so add them to the
+        # branch groups as well.
+        for milestone in ACTIVE_MILESTONES.keys():
+            luci.cq_tryjob_verifier(
+                cq_group = "Dawn-CQ-" + milestone,
+                builder = "dawn:try/" + name,
+            )
+
+def _add_branch_verifiers(builder_name, includable_only = False):
+  for milestone, details in ACTIVE_MILESTONES.items():
+        luci.cq_tryjob_verifier(
+            cq_group = "Dawn-CQ-" + milestone,
+            builder = "{}:try/{}".format(details.chromium_project, builder_name),
+            includable_only = includable_only,
+        )
+
+# We use the DEPS version for branches because ToT builders do not make sense on
+# branches and the DEPS versions already exist.
+_os_to_branch_builder = {
+    "linux": "dawn-linux-x64-deps-rel",
+    "mac": "dawn-mac-x64-deps-rel",
+    "win": "dawn-win10-x64-deps-rel",
+}
 
 def chromium_dawn_tryjob(os):
     """Adds a tryjob that tests against Chromium
@@ -355,10 +380,12 @@
     Args:
       os: string for the OS, should be one or linux|mac|win
     """
+
     luci.cq_tryjob_verifier(
         cq_group = "Dawn-CQ",
         builder = "chromium:try/" + os + "-dawn-rel",
     )
+    _add_branch_verifiers(_os_to_branch_builder[os])
 
 luci.gitiles_poller(
     name = "primary-poller",
@@ -417,6 +444,7 @@
     builder = "chromium:try/dawn-try-win10-x86-rel",
     includable_only = True,
 )
+_add_branch_verifiers("dawn-win10-x86-deps-rel", includable_only = True)
 
 # Views
 
@@ -444,33 +472,49 @@
     submit_burst_delay = 480 * time.second,
 )
 
-luci.cq_group(
-    name = "Dawn-CQ",
-    watch = cq.refset(
-        "https://dawn.googlesource.com/dawn",
-        refs = ["refs/heads/.+"],
-    ),
-    acls = [
-        acl.entry(
-            acl.CQ_COMMITTER,
-            groups = "project-dawn-committers",
+def _create_dawn_cq_group(name, refs, refs_exclude = None):
+    luci.cq_group(
+        name = name,
+        watch = cq.refset(
+            "https://dawn.googlesource.com/dawn",
+            refs = refs,
+            refs_exclude = refs_exclude,
         ),
-        acl.entry(
-            acl.CQ_DRY_RUNNER,
-            groups = "project-dawn-tryjob-access",
+        acls = [
+            acl.entry(
+                acl.CQ_COMMITTER,
+                groups = "project-dawn-committers",
+            ),
+            acl.entry(
+                acl.CQ_DRY_RUNNER,
+                groups = "project-dawn-tryjob-access",
+            ),
+        ],
+        verifiers = [
+            luci.cq_tryjob_verifier(
+                builder = "dawn:try/presubmit",
+                disable_reuse = True,
+            ),
+        ],
+        retry_config = cq.retry_config(
+            single_quota = 1,
+            global_quota = 2,
+            failure_weight = 1,
+            transient_failure_weight = 1,
+            timeout_weight = 2,
         ),
-    ],
-    verifiers = [
-        luci.cq_tryjob_verifier(
-            builder = "dawn:try/presubmit",
-            disable_reuse = True,
-        ),
-    ],
-    retry_config = cq.retry_config(
-        single_quota = 1,
-        global_quota = 2,
-        failure_weight = 1,
-        transient_failure_weight = 1,
-        timeout_weight = 2,
-    ),
+    )
+
+def _create_branch_groups():
+    for milestone, details in ACTIVE_MILESTONES.items():
+        _create_dawn_cq_group(
+            "Dawn-CQ-" + milestone,
+            [details.ref],
+        )
+
+_create_dawn_cq_group(
+    "Dawn-CQ",
+    ["refs/heads/.+"],
+    [details.ref for details in ACTIVE_MILESTONES.values()],
 )
+_create_branch_groups()
diff --git a/infra/config/global/milestones.json b/infra/config/global/milestones.json
new file mode 100644
index 0000000..77fd2d1
--- /dev/null
+++ b/infra/config/global/milestones.json
@@ -0,0 +1,17 @@
+{
+    "112": {
+        "name": "m112",
+        "chromium_project": "chromium-m112",
+        "ref": "refs/heads/chromium/5615"
+    },
+    "113": {
+        "name": "m113",
+        "chromium_project": "chromium-m113",
+        "ref": "refs/heads/chromium/5672"
+    },
+    "114": {
+        "name": "m114",
+        "chromium_project": "chromium-m114",
+        "ref": "refs/heads/chromium/5735"
+    }
+}
\ No newline at end of file
diff --git a/infra/config/global/project.star b/infra/config/global/project.star
new file mode 100644
index 0000000..b09b1eb
--- /dev/null
+++ b/infra/config/global/project.star
@@ -0,0 +1,25 @@
+#
+# Copyright 2023 The Dawn Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+
+def _milestone_details(*, chromium_project, ref):
+  """Define the details for an active milestone.
+
+  Args:
+    * chromium_project - The name of the LUCI project that is configured for the
+      milestone.
+    * ref - The ref in the Dawn git repository that contains the code for the
+      milestone.
+  """
+  return struct(
+      chromium_project = chromium_project,
+      ref = ref,
+  )
+
+ACTIVE_MILESTONES = {
+    m["name"]: _milestone_details(
+        chromium_project = m["chromium_project"], ref = m["ref"])
+        for m in json.decode(io.read_file("./milestones.json")).values()
+}