Add Dawn standalone builders

Adds Buildbucket configs for a parent/child CI pair + their trybot
mirror using the new gn_v2/gn_v2_trybot recipes. The CI parent builder
is not set up to be automatically triggered, so this should functionally
be a no-op, but getting the configs in now will allow us to confirm
that everything works as expected and make further development easier.

Bug: 385317083
Change-Id: I58c3e7901e7c64928f08573a5fdd663d960eaa13
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/236757
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@google.com>
diff --git a/infra/config/global/constants.star b/infra/config/global/constants.star
new file mode 100644
index 0000000..93bdcc1
--- /dev/null
+++ b/infra/config/global/constants.star
@@ -0,0 +1,40 @@
+# Copyright 2025 The Dawn & Tint Authors
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+#    list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+#    this list of conditions and the following disclaimer in the documentation
+#    and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its
+#    contributors may be used to endorse or promote products derived from
+#    this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Copied from Chromium's lib/builders.star and trimmed.
+siso = struct(
+    project = struct(
+        DEFAULT_TRUSTED = "rbe-chromium-trusted",
+        DEFAULT_UNTRUSTED = "rbe-chromium-untrusted",
+    ),
+    remote_jobs = struct(
+        DEFAULT = 250,
+        LOW_JOBS_FOR_CI = 80,
+        HIGH_JOBS_FOR_CI = 500,
+        LOW_JOBS_FOR_CQ = 150,
+    ),
+)
diff --git a/infra/config/global/generated/cr-buildbucket.cfg b/infra/config/global/generated/cr-buildbucket.cfg
index 6e17d0f..da1ed8a 100644
--- a/infra/config/global/generated/cr-buildbucket.cfg
+++ b/infra/config/global/generated/cr-buildbucket.cfg
@@ -561,6 +561,91 @@
       service_account: "dawn-automated-expectations@chops-service-accounts.iam.gserviceaccount.com"
     }
     builders {
+      name: "dawn-linux-x64-builder-rel"
+      swarming_host: "chromium-swarm.appspot.com"
+      dimensions: "cores:8"
+      dimensions: "os:Ubuntu-22.04"
+      dimensions: "pool:luci.chromium.gpu.ci"
+      exe {
+        cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
+        cipd_version: "refs/heads/main"
+        cmd: "luciexe"
+      }
+      properties:
+        '{'
+        '  "$build/reclient": {'
+        '    "instance": "rbe-chromium-trusted",'
+        '    "jobs": 250,'
+        '    "metrics_project": "chromium-reclient-metrics",'
+        '    "scandeps_server": true'
+        '  },'
+        '  "$build/siso": {'
+        '    "configs": ['
+        '      "builder"'
+        '    ],'
+        '    "enable_cloud_monitoring": true,'
+        '    "enable_cloud_profiler": true,'
+        '    "enable_cloud_trace": true,'
+        '    "metrics_project": "chromium-reclient-metrics",'
+        '    "project": "rbe-chromium-trusted",'
+        '    "remote_jobs": 250'
+        '  },'
+        '  "recipe": "dawn/gn_v2"'
+        '}'
+      service_account: "dawn-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
+      experiments {
+        key: "luci.recipes.use_python3"
+        value: 100
+      }
+      shadow_builder_adjustments {
+        service_account: "dawn-try-builder@chops-service-accounts.iam.gserviceaccount.com"
+        properties:
+          '{'
+          '  "$build/reclient": {'
+          '    "instance": "rbe-chromium-untrusted",'
+          '    "jobs": 250,'
+          '    "metrics_project": "chromium-reclient-metrics",'
+          '    "scandeps_server": true'
+          '  },'
+          '  "$build/siso": {'
+          '    "configs": ['
+          '      "builder"'
+          '    ],'
+          '    "enable_cloud_monitoring": true,'
+          '    "enable_cloud_profiler": true,'
+          '    "enable_cloud_trace": true,'
+          '    "metrics_project": "chromium-reclient-metrics",'
+          '    "project": "rbe-chromium-untrusted",'
+          '    "remote_jobs": 250'
+          '  }'
+          '}'
+      }
+    }
+    builders {
+      name: "dawn-linux-x64-sws-rel"
+      swarming_host: "chromium-swarm.appspot.com"
+      dimensions: "cores:2"
+      dimensions: "os:Ubuntu-22.04"
+      dimensions: "pool:luci.chromium.gpu.ci"
+      exe {
+        cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
+        cipd_version: "refs/heads/main"
+        cmd: "luciexe"
+      }
+      properties:
+        '{'
+        '  "recipe": "dawn/gn_v2"'
+        '}'
+      service_account: "dawn-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
+      experiments {
+        key: "luci.recipes.use_python3"
+        value: 100
+      }
+      shadow_builder_adjustments {
+        service_account: "dawn-try-builder@chops-service-accounts.iam.gserviceaccount.com"
+      }
+    }
+    builders {
       name: "linux-clang-dbg-x64"
       swarming_host: "chromium-swarm.appspot.com"
       dimensions: "cpu:x86-64"
@@ -1339,6 +1424,44 @@
       service_account: "dawn-try-builder@chops-service-accounts.iam.gserviceaccount.com"
     }
     builders {
+      name: "dawn-cq-linux-x64-sws-rel"
+      swarming_host: "chromium-swarm.appspot.com"
+      dimensions: "cores:8"
+      dimensions: "os:Ubuntu-22.04"
+      dimensions: "pool:luci.chromium.gpu.try"
+      exe {
+        cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
+        cipd_version: "refs/heads/main"
+        cmd: "luciexe"
+      }
+      properties:
+        '{'
+        '  "$build/reclient": {'
+        '    "instance": "rbe-chromium-untrusted",'
+        '    "jobs": 250,'
+        '    "metrics_project": "chromium-reclient-metrics",'
+        '    "scandeps_server": true'
+        '  },'
+        '  "$build/siso": {'
+        '    "configs": ['
+        '      "builder"'
+        '    ],'
+        '    "enable_cloud_monitoring": true,'
+        '    "enable_cloud_profiler": true,'
+        '    "enable_cloud_trace": true,'
+        '    "metrics_project": "chromium-reclient-metrics",'
+        '    "project": "rbe-chromium-untrusted",'
+        '    "remote_jobs": 250'
+        '  },'
+        '  "recipe": "dawn/gn_v2_trybot"'
+        '}'
+      service_account: "dawn-try-builder@chops-service-accounts.iam.gserviceaccount.com"
+      experiments {
+        key: "luci.recipes.use_python3"
+        value: 100
+      }
+    }
+    builders {
       name: "linux-clang-dbg-x64"
       swarming_host: "chromium-swarm.appspot.com"
       dimensions: "cpu:x86-64"
diff --git a/infra/config/global/generated/luci-scheduler.cfg b/infra/config/global/generated/luci-scheduler.cfg
index f9f54f5..9756032 100644
--- a/infra/config/global/generated/luci-scheduler.cfg
+++ b/infra/config/global/generated/luci-scheduler.cfg
@@ -127,6 +127,20 @@
   }
 }
 job {
+  id: "dawn-linux-x64-sws-rel"
+  realm: "ci"
+  acls {
+    role: TRIGGERER
+    granted_to: "dawn-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
+  }
+  acl_sets: "ci"
+  buildbucket {
+    server: "cr-buildbucket.appspot.com"
+    bucket: "ci"
+    builder: "dawn-linux-x64-sws-rel"
+  }
+}
+job {
   id: "linux-clang-dbg-x64"
   realm: "ci"
   acl_sets: "ci"
diff --git a/infra/config/global/generated/realms.cfg b/infra/config/global/generated/realms.cfg
index adf1343..616e398 100644
--- a/infra/config/global/generated/realms.cfg
+++ b/infra/config/global/generated/realms.cfg
@@ -47,6 +47,16 @@
     role: "role/buildbucket.reader"
     principals: "group:all"
   }
+  bindings {
+    role: "role/scheduler.triggerer"
+    principals: "user:dawn-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
+    conditions {
+      restrict {
+        attribute: "scheduler.job.name"
+        values: "dawn-linux-x64-sws-rel"
+      }
+    }
+  }
 }
 realms {
   name: "ci.shadow"
diff --git a/infra/config/global/gn_standalone_ci.star b/infra/config/global/gn_standalone_ci.star
new file mode 100644
index 0000000..f0d886e
--- /dev/null
+++ b/infra/config/global/gn_standalone_ci.star
@@ -0,0 +1,118 @@
+# Copyright 2025 The Dawn & Tint Authors
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+#    list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+#    this list of conditions and the following disclaimer in the documentation
+#    and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its
+#    contributors may be used to endorse or promote products derived from
+#    this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Starlark file for Buildbucket entries of CI builders using the gn_v2 recipe.
+# Note that builders must first be defined the the build repo in
+# https://source.chromium.org/chromium/infra/infra_superproject/+/main:build/recipes/recipe_modules/dawn/builders.py
+
+load("//constants.star", "siso")
+
+luci.recipe(
+    name = "recipe:dawn/gn_v2",
+    cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",
+    recipe = "dawn/gn_v2",
+    use_bbagent = True,
+    use_python3 = True,
+)
+
+LINUX_BUILDER_DIMENSIONS = {
+    "pool": "luci.chromium.gpu.ci",
+    "os": "Ubuntu-22.04",
+    "cores": "8",
+}
+
+CI_SERVICE_ACCOUNT = "dawn-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
+CI_SHADOW_SERVICE_ACCOUNT = "dawn-try-builder@chops-service-accounts.iam.gserviceaccount.com"
+
+def generate_properties_for_project(project):
+    properties = {
+        "$build/siso": {
+            "project": project,
+            "remote_jobs": siso.remote_jobs.DEFAULT,
+            "configs": ["builder"],
+            "enable_cloud_monitoring": True,
+            "enable_cloud_profiler": True,
+            "enable_cloud_trace": True,
+            "metrics_project": "chromium-reclient-metrics",
+        },
+        "$build/reclient": {
+            "instance": project,
+            "jobs": siso.remote_jobs.DEFAULT,
+            "metrics_project": "chromium-reclient-metrics",
+            "scandeps_server": True,
+        },
+    }
+    return properties
+
+def parent_builder(name, dimensions, **kwargs):
+    """Adds a CI parent builder.
+
+    Args:
+      name: The name of the builder.
+      dimensions: The Swarming dimensions the builder should target.
+    """
+    luci.builder(
+        name = name,
+        bucket = "ci",
+        # TODO(crbug.com/385317083): Switch this to be triggered by
+        # "primary-poller" once we're ready to begin migration to this recipe.
+        triggered_by = None,
+        executable = "recipe:dawn/gn_v2",
+        dimensions = dimensions,
+        properties = generate_properties_for_project(siso.project.DEFAULT_TRUSTED),
+        shadow_properties = generate_properties_for_project(siso.project.DEFAULT_UNTRUSTED),
+        # TODO(crbug.com/385317083): Make CI builders notify the gardeners once
+        # migration to this recipe has begun.
+        service_account = CI_SERVICE_ACCOUNT,
+        shadow_service_account = CI_SHADOW_SERVICE_ACCOUNT,
+    )
+
+def child_tester(name, parent_builder):
+    """Adds a CI child tester.
+
+    Args:
+        name: The name of the tester.
+        parent_builder: The name of the parent builder that will trigger the
+            tester.
+    """
+    luci.builder(
+        name = name,
+        bucket = "ci",
+        triggered_by = [parent_builder],
+        executable = "recipe:dawn/gn_v2",
+        dimensions = {
+            "pool": "luci.chromium.gpu.ci",
+            "os": "Ubuntu-22.04",
+            "cores": "2",
+        },
+        service_account = CI_SERVICE_ACCOUNT,
+        shadow_service_account = CI_SHADOW_SERVICE_ACCOUNT,
+    )
+
+parent_builder("dawn-linux-x64-builder-rel", LINUX_BUILDER_DIMENSIONS)
+
+child_tester("dawn-linux-x64-sws-rel", "ci/dawn-linux-x64-builder-rel")
diff --git a/infra/config/global/gn_standalone_try.star b/infra/config/global/gn_standalone_try.star
new file mode 100644
index 0000000..dd7deb4
--- /dev/null
+++ b/infra/config/global/gn_standalone_try.star
@@ -0,0 +1,89 @@
+# Copyright 2025 The Dawn & Tint Authors
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+#    list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+#    this list of conditions and the following disclaimer in the documentation
+#    and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its
+#    contributors may be used to endorse or promote products derived from
+#    this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Starlark file for Buildbucket entries of trybots using the gn_v2_trybot
+# recipe. Note that builders must first be defined the the build repo in
+# https://source.chromium.org/chromium/infra/infra_superproject/+/main:build/recipes/recipe_modules/dawn/trybots.py
+
+load("//constants.star", "siso")
+
+luci.recipe(
+    name = "recipe:dawn/gn_v2_trybot",
+    cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",
+    recipe = "dawn/gn_v2_trybot",
+    use_bbagent = True,
+    use_python3 = True,
+)
+
+LINUX_BUILDER_DIMENSIONS = {
+    "pool": "luci.chromium.gpu.try",
+    "os": "Ubuntu-22.04",
+    "cores": "8",
+}
+
+TRY_SERVICE_ACCOUNT = "dawn-try-builder@chops-service-accounts.iam.gserviceaccount.com"
+
+def generate_properties():
+    properties = {
+        "$build/siso": {
+            "project": siso.project.DEFAULT_UNTRUSTED,
+            "remote_jobs": siso.remote_jobs.DEFAULT,
+            "configs": ["builder"],
+            "enable_cloud_monitoring": True,
+            "enable_cloud_profiler": True,
+            "enable_cloud_trace": True,
+            "metrics_project": "chromium-reclient-metrics",
+        },
+        "$build/reclient": {
+            "instance": siso.project.DEFAULT_UNTRUSTED,
+            "jobs": siso.remote_jobs.DEFAULT,
+            "metrics_project": "chromium-reclient-metrics",
+            "scandeps_server": True,
+        },
+    }
+    return properties
+
+def trybot(name, dimensions):
+    """Adds a trybot.
+
+    Note that the mirroring configuration is handled in the build-side
+    trybots.py file.
+
+    Args:
+        name: The name of the trybot being added.
+        dimensions: The Swarming dimensions the trybot should target.
+    """
+    luci.builder(
+        name = name,
+        bucket = "try",
+        executable = "recipe:dawn/gn_v2_trybot",
+        properties = generate_properties(),
+        dimensions = dimensions,
+        service_account = TRY_SERVICE_ACCOUNT,
+    )
+
+trybot("dawn-cq-linux-x64-sws-rel", LINUX_BUILDER_DIMENSIONS)
diff --git a/infra/config/global/main.star b/infra/config/global/main.star
index 420511a..d197d88 100755
--- a/infra/config/global/main.star
+++ b/infra/config/global/main.star
@@ -32,6 +32,7 @@
 """
 
 load("//project.star", "ACTIVE_MILESTONES")
+load("//constants.star", "siso")
 
 # Use LUCI Scheduler BBv2 names and add Scheduler realms configs.
 lucicfg.enable_experiment("crbug.com/1182002")
@@ -235,17 +236,6 @@
 
     return "Invalid Dimension"
 
-siso = struct(
-    project = struct(
-        DEFAULT_TRUSTED = "rbe-chromium-trusted",
-        DEFAULT_UNTRUSTED = "rbe-chromium-untrusted",
-    ),
-    remote_jobs = struct(
-        HIGH_JOBS_FOR_CI = 250,
-        LOW_JOBS_FOR_CQ = 150,
-    ),
-)
-
 # File exclusion filters meant for use on cmake and msvc trybots since these
 # files do not affect compilation for either.
 cmake_msvc_file_exclusions = [
@@ -404,14 +394,14 @@
         os,
         clang,
         siso.project.DEFAULT_TRUSTED,
-        siso.remote_jobs.HIGH_JOBS_FOR_CI,
+        siso.remote_jobs.DEFAULT,
     )
     properties_ci.update(properties)
     shadow_properties_ci = get_common_properties(
         os,
         clang,
         siso.project.DEFAULT_UNTRUSTED,
-        siso.remote_jobs.HIGH_JOBS_FOR_CI,
+        siso.remote_jobs.DEFAULT,
     )
     shadow_properties_ci.update(properties)
     schedule_ci = None
@@ -988,3 +978,7 @@
     [details.ref for details in ACTIVE_MILESTONES.values()],
 )
 _create_branch_groups()
+
+# Handle any other builders defined in other files.
+exec("//gn_standalone_ci.star")
+exec("//gn_standalone_try.star")