Add Fuchsia Perf bot

Bug: b/232740856
Change-Id: I901c283262cc444f835a099a99ee9a6e09d6b759
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285442
Reviewed-by: Jeremy Leconte <jleconte@google.com>
Commit-Queue: Christoffer Jansson <jansson@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38758}
diff --git a/infra/config/config.star b/infra/config/config.star
index 7fb7194..27722be 100755
--- a/infra/config/config.star
+++ b/infra/config/config.star
@@ -787,8 +787,10 @@
 linux_try_job("linux_more_configs")
 linux_try_job("linux_chromium_compile", recipe = "chromium_trybot", branch_cq = False)
 linux_try_job("linux_chromium_compile_dbg", recipe = "chromium_trybot", branch_cq = False)
+linux_builder("Fuchsia Builder", ci_cat = None, perf_cat = "Fuchsia|x64|Builder", prioritized = True)
 linux_builder("Fuchsia Release", "Fuchsia|x64|rel")
 linux_try_job("fuchsia_rel", cq = None)
+perf_builder("Perf Fuchsia", "Fuchsia|x64|Tester", triggered_by = ["Fuchsia Builder"])
 
 mac_builder("Mac64 Debug", "Mac|x64|dbg")
 mac_try_job("mac_dbg", cq = None)
diff --git a/infra/config/cr-buildbucket.cfg b/infra/config/cr-buildbucket.cfg
index 10efd3f..11830e2 100644
--- a/infra/config/cr-buildbucket.cfg
+++ b/infra/config/cr-buildbucket.cfg
@@ -2335,6 +2335,57 @@
       }
     }
     builders {
+      name: "Fuchsia Builder"
+      swarming_host: "chromium-swarm.appspot.com"
+      swarming_tags: "vpython:native-python-wrapper"
+      dimensions: "cpu:x86-64"
+      dimensions: "inside_docker:0"
+      dimensions: "os:Linux"
+      dimensions: "pool:luci.webrtc.ci"
+      exe {
+        cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
+        cipd_version: "refs/heads/main"
+        cmd: "luciexe"
+      }
+      properties:
+        '{'
+        '  "$build/goma": {'
+        '    "server_host": "goma.chromium.org",'
+        '    "use_luci_auth": true'
+        '  },'
+        '  "$build/reclient": {'
+        '    "instance": "rbe-webrtc-trusted",'
+        '    "metrics_project": "chromium-reclient-metrics"'
+        '  },'
+        '  "$recipe_engine/resultdb/test_presentation": {'
+        '    "column_keys": [],'
+        '    "grouping_keys": ['
+        '      "status",'
+        '      "v.test_suite"'
+        '    ]'
+        '  },'
+        '  "builder_group": "client.webrtc",'
+        '  "recipe": "webrtc/standalone"'
+        '}'
+      priority: 29
+      execution_timeout_secs: 7200
+      build_numbers: YES
+      service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
+      experiments {
+        key: "luci.recipes.use_python3"
+        value: 100
+      }
+      resultdb {
+        enable: true
+        bq_exports {
+          project: "webrtc-ci"
+          dataset: "resultdb"
+          table: "perf_test_results"
+          test_results {}
+        }
+      }
+    }
+    builders {
       name: "Linux64 Builder"
       swarming_host: "chromium-swarm.appspot.com"
       swarming_tags: "vpython:native-python-wrapper"
@@ -2836,6 +2887,55 @@
       }
     }
     builders {
+      name: "Perf Fuchsia"
+      swarming_host: "chromium-swarm.appspot.com"
+      swarming_tags: "vpython:native-python-wrapper"
+      dimensions: "os:Linux"
+      dimensions: "pool:luci.webrtc.perf"
+      exe {
+        cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
+        cipd_version: "refs/heads/main"
+        cmd: "luciexe"
+      }
+      properties:
+        '{'
+        '  "$build/goma": {'
+        '    "server_host": "goma.chromium.org",'
+        '    "use_luci_auth": true'
+        '  },'
+        '  "$build/reclient": {'
+        '    "instance": "rbe-webrtc-trusted",'
+        '    "metrics_project": "chromium-reclient-metrics"'
+        '  },'
+        '  "$recipe_engine/resultdb/test_presentation": {'
+        '    "column_keys": [],'
+        '    "grouping_keys": ['
+        '      "status",'
+        '      "v.test_suite"'
+        '    ]'
+        '  },'
+        '  "builder_group": "client.webrtc.perf",'
+        '  "recipe": "webrtc/standalone"'
+        '}'
+      priority: 30
+      execution_timeout_secs: 10800
+      build_numbers: YES
+      service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
+      experiments {
+        key: "luci.recipes.use_python3"
+        value: 100
+      }
+      resultdb {
+        enable: true
+        bq_exports {
+          project: "webrtc-ci"
+          dataset: "resultdb"
+          table: "perf_test_results"
+          test_results {}
+        }
+      }
+    }
+    builders {
       name: "Perf Linux Bionic"
       swarming_host: "chromium-swarm.appspot.com"
       swarming_tags: "vpython:native-python-wrapper"
diff --git a/infra/config/luci-milo.cfg b/infra/config/luci-milo.cfg
index 09d75a4..835054a 100644
--- a/infra/config/luci-milo.cfg
+++ b/infra/config/luci-milo.cfg
@@ -343,6 +343,16 @@
     short_name: "Bionic"
   }
   builders {
+    name: "buildbucket/luci.webrtc.perf/Fuchsia Builder"
+    category: "Fuchsia|x64"
+    short_name: "Builder"
+  }
+  builders {
+    name: "buildbucket/luci.webrtc.perf/Perf Fuchsia"
+    category: "Fuchsia|x64"
+    short_name: "Tester"
+  }
+  builders {
     name: "buildbucket/luci.webrtc.perf/Mac64 Builder"
     category: "Mac|x64|Builder"
   }
diff --git a/infra/config/luci-notify.cfg b/infra/config/luci-notify.cfg
index 609875d..8e77146 100644
--- a/infra/config/luci-notify.cfg
+++ b/infra/config/luci-notify.cfg
@@ -1166,6 +1166,33 @@
   }
   builders {
     bucket: "perf"
+    name: "Fuchsia Builder"
+    repository: "https://webrtc.googlesource.com/src"
+  }
+  tree_closers {
+    tree_status_host: "webrtc-status.appspot.com"
+    failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn"
+    failed_step_regexp_exclude: ".*\\(experimental\\).*"
+  }
+}
+notifiers {
+  notifications {
+    on_new_status: INFRA_FAILURE
+    email {
+      recipients: "webrtc-troopers-robots@google.com"
+    }
+    template: "infra_failure"
+  }
+  notifications {
+    on_new_status: FAILURE
+    email {
+      recipients: "webrtc-troopers-robots@google.com"
+    }
+    template: "build_failure"
+    notify_blamelist {}
+  }
+  builders {
+    bucket: "perf"
     name: "Linux64 Builder"
     repository: "https://webrtc.googlesource.com/src"
   }
@@ -1401,6 +1428,28 @@
   }
   builders {
     bucket: "perf"
+    name: "Perf Fuchsia"
+    repository: "https://webrtc.googlesource.com/src"
+  }
+}
+notifiers {
+  notifications {
+    on_new_status: INFRA_FAILURE
+    email {
+      recipients: "webrtc-troopers-robots@google.com"
+    }
+    template: "infra_failure"
+  }
+  notifications {
+    on_new_status: FAILURE
+    email {
+      recipients: "webrtc-troopers-robots@google.com"
+    }
+    template: "build_failure"
+    notify_blamelist {}
+  }
+  builders {
+    bucket: "perf"
     name: "Perf Linux Bionic"
     repository: "https://webrtc.googlesource.com/src"
   }
diff --git a/infra/config/luci-scheduler.cfg b/infra/config/luci-scheduler.cfg
index 3e79cdd..b8cdab9 100644
--- a/infra/config/luci-scheduler.cfg
+++ b/infra/config/luci-scheduler.cfg
@@ -116,6 +116,21 @@
   }
 }
 job {
+  id: "Fuchsia Builder"
+  realm: "perf"
+  acl_sets: "perf"
+  triggering_policy {
+    kind: GREEDY_BATCHING
+    max_concurrent_invocations: 3
+    max_batch_size: 1
+  }
+  buildbucket {
+    server: "cr-buildbucket.appspot.com"
+    bucket: "perf"
+    builder: "Fuchsia Builder"
+  }
+}
+job {
   id: "Fuchsia Release"
   realm: "ci"
   acl_sets: "ci"
@@ -477,6 +492,24 @@
   }
 }
 job {
+  id: "Perf Fuchsia"
+  realm: "perf"
+  acls {
+    role: TRIGGERER
+    granted_to: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
+  }
+  acl_sets: "perf"
+  triggering_policy {
+    kind: LOGARITHMIC_BATCHING
+    log_base: 1.7
+  }
+  buildbucket {
+    server: "cr-buildbucket.appspot.com"
+    bucket: "perf"
+    builder: "Perf Fuchsia"
+  }
+}
+job {
   id: "Perf Linux Bionic"
   realm: "perf"
   acls {
@@ -750,6 +783,7 @@
   triggers: "iOS64 Sim Debug (iOS 14)"
   triggers: "Android32 Builder arm"
   triggers: "Android64 Builder arm64"
+  triggers: "Fuchsia Builder"
   triggers: "Linux64 Builder"
   triggers: "Mac64 Builder"
   triggers: "MacArm64 Builder"
diff --git a/infra/config/realms.cfg b/infra/config/realms.cfg
index 4fd8685..4d06b29 100644
--- a/infra/config/realms.cfg
+++ b/infra/config/realms.cfg
@@ -118,6 +118,7 @@
         values: "Perf Android64 (M Nexus5X)"
         values: "Perf Android64 (O Pixel2)"
         values: "Perf Android64 (R Pixel5)"
+        values: "Perf Fuchsia"
         values: "Perf Linux Bionic"
         values: "Perf Mac 11"
         values: "Perf Mac M1 Arm64 12"
diff --git a/infra/specs/client.webrtc.json b/infra/specs/client.webrtc.json
index 2425d39..f57c11f 100644
--- a/infra/specs/client.webrtc.json
+++ b/infra/specs/client.webrtc.json
@@ -2094,6 +2094,7 @@
   },
   "Android64 Builder arm64": {},
   "Android64 Builder x64 (dbg)": {},
+  "Fuchsia Builder": {},
   "Fuchsia Release": {
     "isolated_scripts": [
       {
diff --git a/infra/specs/client.webrtc.perf.json b/infra/specs/client.webrtc.perf.json
index 7937877..9e98887 100644
--- a/infra/specs/client.webrtc.perf.json
+++ b/infra/specs/client.webrtc.perf.json
@@ -539,6 +539,81 @@
       }
     ]
   },
+  "Perf Fuchsia": {
+    "isolated_scripts": [
+      {
+        "args": [
+          ".",
+          "--remove",
+          "--isolated-script-test-perf-output=${ISOLATED_OUTDIR}/perftest-output.pb"
+        ],
+        "isolate_name": "low_bandwidth_audio_perf_test",
+        "merge": {
+          "args": [
+            "--test-suite",
+            "low_bandwidth_audio_perf_test"
+          ],
+          "script": "//tools_webrtc/perf/process_perf_results.py"
+        },
+        "name": "low_bandwidth_audio_perf_test",
+        "resultdb": {
+          "enable": true,
+          "has_native_resultdb_integration": true
+        },
+        "swarming": {
+          "can_use_on_swarming_builders": true,
+          "dimension_sets": [
+            {
+              "cpu": "x86-64",
+              "os": "Ubuntu-18.04",
+              "pool": "WebRTC-perf"
+            }
+          ],
+          "hard_timeout": 10800,
+          "idempotent": false,
+          "io_timeout": 10800,
+          "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
+        },
+        "test_id_prefix": "ninja://audio:low_bandwidth_audio_perf_test/"
+      },
+      {
+        "args": [
+          "--test_artifacts_dir=${ISOLATED_OUTDIR}",
+          "--save_worst_frame",
+          "--isolated-script-test-perf-output=${ISOLATED_OUTDIR}/perftest-output.pb",
+          "--nologs"
+        ],
+        "isolate_name": "webrtc_perf_tests",
+        "merge": {
+          "args": [
+            "--test-suite",
+            "webrtc_perf_tests"
+          ],
+          "script": "//tools_webrtc/perf/process_perf_results.py"
+        },
+        "name": "webrtc_perf_tests",
+        "resultdb": {
+          "enable": true,
+          "has_native_resultdb_integration": true
+        },
+        "swarming": {
+          "can_use_on_swarming_builders": true,
+          "dimension_sets": [
+            {
+              "cpu": "x86-64",
+              "os": "Ubuntu-18.04",
+              "pool": "WebRTC-perf"
+            }
+          ],
+          "hard_timeout": 10800,
+          "idempotent": false,
+          "io_timeout": 10800,
+          "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
+        },
+        "test_id_prefix": "ninja://:webrtc_perf_tests/"
+      }
+    ]
+  },
   "Perf Linux Bionic": {
     "isolated_scripts": [
       {
diff --git a/infra/specs/waterfalls.pyl b/infra/specs/waterfalls.pyl
index 5a93be5..f83e647 100644
--- a/infra/specs/waterfalls.pyl
+++ b/infra/specs/waterfalls.pyl
@@ -65,6 +65,7 @@
       },
       'Android64 Builder arm64': {},
       'Android64 Builder x64 (dbg)': {},
+      'Fuchsia Builder': {},
       'Fuchsia Release': {
         'os_type': 'linux',
         'mixins':
@@ -320,6 +321,17 @@
           'gtest_tests': 'android_perf_tests',
         },
       },
+      'Perf Fuchsia': {
+        'os_type':
+        'linux',
+        'mixins': [
+          'linux-bionic', 'x86-64', 'perf-pool', 'timeout-3h', 'perf-output',
+          'has_native_resultdb_integration', 'chromium-tester-service-account'
+        ],
+        'test_suites': {
+          'isolated_scripts': 'desktop_perf_tests',
+        }
+      },
       'Perf Linux Bionic': {
         'os_type':
         'linux',
diff --git a/tools_webrtc/mb/mb_config.pyl b/tools_webrtc/mb/mb_config.pyl
index f01a7e2..ab12245 100644
--- a/tools_webrtc/mb/mb_config.pyl
+++ b/tools_webrtc/mb/mb_config.pyl
@@ -48,6 +48,7 @@
       'Android64 Builder x64 (dbg)': 'android_debug_static_bot_x64',
 
       # Fuchsia
+      'Fuchsia Builder': 'release_bot_x64_fuchsia',
       'Fuchsia Release': 'release_bot_x64_fuchsia',
 
       # Linux
@@ -130,6 +131,7 @@
       'Perf Android64 (M Nexus5X)': 'release_bot_x64',
       'Perf Android64 (O Pixel2)': 'release_bot_x64',
       'Perf Android64 (R Pixel5)': 'release_bot_x64',
+      'Perf Fuchsia': 'release_bot_x64_fuchsia',
       'Perf Linux Bionic': 'release_bot_x64',
       'Perf Linux Trusty': 'release_bot_x64',
       'Perf Mac 11': 'release_bot_x64',