Add tricium configuration for Dawn.

This cl updates the starlark files for Dawn to add tricium and
clang-tidy try runs into the build.

Change-Id: Id858c46348ba3de6e4931ce57684cd35fdb1c3ff
Bug: dawn:1414
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/175320
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
diff --git a/infra/config/global/generated/commit-queue.cfg b/infra/config/global/generated/commit-queue.cfg
index d470e08..b2ea753 100644
--- a/infra/config/global/generated/commit-queue.cfg
+++ b/infra/config/global/generated/commit-queue.cfg
@@ -117,6 +117,31 @@
         }
       }
       builders {
+        name: "chromium/try/tricium-clang-tidy"
+        location_filters {
+          gerrit_host_regexp: ".*"
+          gerrit_project_regexp: ".*"
+          path_regexp: ".+\\.h"
+        }
+        location_filters {
+          gerrit_host_regexp: ".*"
+          gerrit_project_regexp: ".*"
+          path_regexp: ".+\\.c"
+        }
+        location_filters {
+          gerrit_host_regexp: ".*"
+          gerrit_project_regexp: ".*"
+          path_regexp: ".+\\.cc"
+        }
+        location_filters {
+          gerrit_host_regexp: ".*"
+          gerrit_project_regexp: ".*"
+          path_regexp: ".+\\.cpp"
+        }
+        owner_whitelist_group: "project-dawn-tryjob-access"
+        mode_allowlist: "ANALYZER_RUN"
+      }
+      builders {
         name: "chromium/try/win-dawn-rel"
         location_filters {
           gerrit_host_regexp: ".*"
@@ -131,6 +156,11 @@
         }
       }
       builders {
+        name: "dawn/try/dawn_analysis"
+        owner_whitelist_group: "project-dawn-tryjob-access"
+        mode_allowlist: "ANALYZER_RUN"
+      }
+      builders {
         name: "dawn/try/linux-clang-dbg-x64"
         location_filters {
           gerrit_host_regexp: ".*"
diff --git a/infra/config/global/generated/cr-buildbucket.cfg b/infra/config/global/generated/cr-buildbucket.cfg
index cae6ff6..269bd1b 100644
--- a/infra/config/global/generated/cr-buildbucket.cfg
+++ b/infra/config/global/generated/cr-buildbucket.cfg
@@ -295,6 +295,10 @@
   }
   acls {
     role: SCHEDULER
+    identity: "user:tricium-prod@appspot.gserviceaccount.com"
+  }
+  acls {
+    role: SCHEDULER
     group: "project-dawn-tryjob-access"
   }
   acls {
@@ -303,6 +307,21 @@
   }
   swarming {
     builders {
+      name: "dawn_analysis"
+      swarming_host: "chromium-swarm.appspot.com"
+      dimensions: "cores:8"
+      dimensions: "cpu:x86-64"
+      dimensions: "os:Ubuntu-20.04"
+      dimensions: "pool:luci.flex.try"
+      recipe {
+        name: "dawn_analysis"
+        cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
+        cipd_version: "refs/heads/main"
+        properties_j: "builder_group:\"tryserver.client.dawn\""
+      }
+      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"
diff --git a/infra/config/global/generated/luci-milo.cfg b/infra/config/global/generated/luci-milo.cfg
index 84e9a37..9ad9529 100644
--- a/infra/config/global/generated/luci-milo.cfg
+++ b/infra/config/global/generated/luci-milo.cfg
@@ -123,6 +123,9 @@
   builders {
     name: "buildbucket/luci.dawn.try/win-msvc-rel-x64"
   }
+  builders {
+    name: "buildbucket/luci.dawn.try/dawn_analysis"
+  }
   builder_view_only: true
 }
 logo_url: "https://storage.googleapis.com/chrome-infra-public/logo/dawn-logo.png"
diff --git a/infra/config/global/generated/realms.cfg b/infra/config/global/generated/realms.cfg
index a34c211..f8b3175 100644
--- a/infra/config/global/generated/realms.cfg
+++ b/infra/config/global/generated/realms.cfg
@@ -65,6 +65,7 @@
     role: "role/buildbucket.triggerer"
     principals: "group:project-dawn-tryjob-access"
     principals: "group:service-account-cq"
+    principals: "user:tricium-prod@appspot.gserviceaccount.com"
   }
   bindings {
     role: "role/swarming.taskTriggerer"
diff --git a/infra/config/global/generated/tricium-prod.cfg b/infra/config/global/generated/tricium-prod.cfg
new file mode 100644
index 0000000..5e9098d
--- /dev/null
+++ b/infra/config/global/generated/tricium-prod.cfg
@@ -0,0 +1,54 @@
+# Auto-generated by lucicfg.
+# Do not modify manually.
+
+functions {
+  type: ANALYZER
+  name: "ChromiumTryTriciumClangTidy"
+  needs: GIT_FILE_DETAILS
+  provides: RESULTS
+  path_filters: "*.c"
+  path_filters: "*.cc"
+  path_filters: "*.cpp"
+  path_filters: "*.h"
+  impls {
+    provides_for_platform: LINUX
+    runtime_platform: LINUX
+    recipe {
+      project: "chromium"
+      bucket: "try"
+      builder: "tricium-clang-tidy"
+    }
+  }
+}
+functions {
+  type: ANALYZER
+  name: "DawnTryDawnAnalysis"
+  needs: GIT_FILE_DETAILS
+  provides: RESULTS
+  impls {
+    provides_for_platform: LINUX
+    runtime_platform: LINUX
+    recipe {
+      project: "dawn"
+      bucket: "try"
+      builder: "dawn_analysis"
+    }
+  }
+}
+selections {
+  function: "ChromiumTryTriciumClangTidy"
+  platform: LINUX
+}
+selections {
+  function: "DawnTryDawnAnalysis"
+  platform: LINUX
+}
+repos {
+  gerrit_project {
+    host: "dawn-review.googlesource.com"
+    project: "dawn"
+    git_url: "https://dawn.googlesource.com/dawn"
+  }
+  whitelisted_group: "project-dawn-tryjob-access"
+}
+service_account: "tricium-prod@appspot.gserviceaccount.com"
diff --git a/infra/config/global/main.star b/infra/config/global/main.star
index 9456948..e9fec9b 100755
--- a/infra/config/global/main.star
+++ b/infra/config/global/main.star
@@ -46,6 +46,7 @@
     notify = "luci-notify.appspot.com",
     scheduler = "luci-scheduler.appspot.com",
     swarming = "chromium-swarm.appspot.com",
+    tricium = "tricium-prod.appspot.com",
     acls = [
         acl.entry(
             roles = [
@@ -111,6 +112,10 @@
     acls = [
         acl.entry(
             acl.BUILDBUCKET_TRIGGERER,
+            # Allow Tricium prod to trigger analyzer tryjobs.
+            users = [
+                "tricium-prod@appspot.gserviceaccount.com",
+            ],
             groups = [
                 "project-dawn-tryjob-access",
                 "service-account-cq",
@@ -188,6 +193,18 @@
         cipd_version = "refs/heads/main",
     )
 
+def get_tricium_executable():
+    """Get standard executable for tricium
+
+    Returns:
+      A luci.recipe
+    """
+    return luci.recipe(
+        name = "dawn_analysis",
+        cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",
+        cipd_version = "refs/heads/main",
+    )
+
 def get_os_from_arg(arg):
     """Get OS enum for a builder name string
 
@@ -341,6 +358,25 @@
         service_account = "dawn-try-builder@chops-service-accounts.iam.gserviceaccount.com",
     )
 
+def add_tricium_builder():
+    """Add a Try builder
+    """
+    luci.builder(
+        name = "dawn_analysis",
+        bucket = "try",
+        executable = get_tricium_executable(),
+        properties = {
+            "builder_group": "tryserver.client.dawn",
+        },
+        dimensions = {
+            "cores": "8",
+            "cpu": "x86-64",
+            "os": "Ubuntu-20.04",
+            "pool": "luci.flex.try",
+        },
+        service_account = "dawn-try-builder@chops-service-accounts.iam.gserviceaccount.com",
+    )
+
 def dawn_standalone_builder(name, clang, debug, cpu, fuzzer = False):
     """Adds both the CI and Try standalone builders as appropriate
 
@@ -494,6 +530,42 @@
         )
         _add_branch_verifiers(_os_arch_to_branch_builder[os], os)
 
+def tricium_dawn_tryjob():
+    """Adds a tryjob that tests against Chromium
+
+    Args:
+      os: string for the OS, should be one or linux|mac|win
+      arch: string for the arch, or None
+    """
+
+    add_tricium_builder()
+
+    luci.cq_tryjob_verifier(
+        cq_group = "Dawn-CQ",
+        builder = "dawn:try/dawn_analysis",
+        owner_whitelist = ["project-dawn-tryjob-access"],
+        mode_allowlist = [cq.MODE_ANALYZER_RUN],
+    )
+
+    luci.cq_tryjob_verifier(
+        cq_group = "Dawn-CQ",
+        builder = "chromium:try/tricium-clang-tidy",
+        owner_whitelist = ["project-dawn-tryjob-access"],
+        mode_allowlist = [cq.MODE_ANALYZER_RUN],
+        location_filters = [
+          cq.location_filter(path_regexp = ".+\\.h"),
+          cq.location_filter(path_regexp = ".+\\.c"),
+          cq.location_filter(path_regexp = ".+\\.cc"),
+          cq.location_filter(path_regexp = ".+\\.cpp")
+        ],
+    )
+
+    luci.list_view_entry(
+        list_view = "try",
+        builder = "try/dawn_analysis",
+    )
+
+
 luci.gitiles_poller(
     name = "primary-poller",
     bucket = "ci",
@@ -586,6 +658,8 @@
 chromium_dawn_tryjob("android", "arm")
 chromium_dawn_tryjob("android", "arm64")
 
+tricium_dawn_tryjob()
+
 luci.cq_tryjob_verifier(
     cq_group = "Dawn-CQ",
     builder = "chromium:try/dawn-try-win10-x86-rel",