[bazel] Add CanvasKit build with CPU-backend only

This adds a small change to the test harness that allows
skipped tests (e.g. gms that exercises GPU specific code) to
not upload anything to Gold. Previously, they would upload
a blank canvas, which was marked "positive" because the CPU
backend would not support this.

The CPU build still needs the legacy shader context for
perlin noise drawing.

Change-Id: I3ee9cbd8b9538367bad673250965b9d7c7fa311a
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/565014
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/infra/bots/gen_tasks_logic/gen_tasks_logic.go b/infra/bots/gen_tasks_logic/gen_tasks_logic.go
index 847b2a8..a17f8a1 100644
--- a/infra/bots/gen_tasks_logic/gen_tasks_logic.go
+++ b/infra/bots/gen_tasks_logic/gen_tasks_logic.go
@@ -2161,7 +2161,6 @@
 
 		switch taskdriverName {
 		case "canvaskit_gold":
-			// TODO(kjlubick) pass in appropriate keys (e.g. webgl vs webgpu vs cpu)
 			cmd = append(cmd,
 				"--goldctl_path=./cipd_bin_packages/goldctl",
 				"--git_commit="+specs.PLACEHOLDER_REVISION,
@@ -2172,7 +2171,18 @@
 				// Middleman ...tests-runfiles failed: missing input file 'external/npm/node_modules/karma-chrome-launcher/...'
 				"--expunge_cache")
 			b.cipd(CIPD_PKGS_GOLDCTL)
-			break
+			switch config {
+			case "ck_full_cpu_release_chrome":
+				cmd = append(cmd, "--cpu_or_gpu=CPU", "--cpu_or_gpu_value=CPU",
+					"--compilation_mode=Release", "--browser=Chrome")
+			case "ck_full_webgl2_release_chrome":
+				cmd = append(cmd, "--cpu_or_gpu=GPU", "--cpu_or_gpu_value=WebGL2",
+					"--compilation_mode=Release", "--browser=Chrome")
+			default:
+				panic("Gold keys not specified for config " + config)
+			}
+		default:
+			panic("Unsupported Bazel taskdriver " + taskdriverName)
 		}
 
 		if cross != "" {
diff --git a/infra/bots/jobs.json b/infra/bots/jobs.json
index 2cc4bf6..75ec4be 100644
--- a/infra/bots/jobs.json
+++ b/infra/bots/jobs.json
@@ -9,6 +9,9 @@
     "cq_config": {}
   },
   {"name": "BazelBuild-skia_public-release-linux_x64"},
+  {"name": "BazelTest-canvaskit_gold-ck_full_cpu_release_chrome-linux_x64",
+    "cq_config": {"location_regexes": ["modules/canvaskit/.*"]}
+  },
   {"name": "BazelTest-canvaskit_gold-ck_full_webgl2_release_chrome-linux_x64",
     "cq_config": {"location_regexes": ["modules/canvaskit/.*"]}
   },
diff --git a/infra/bots/task_drivers/canvaskit_gold/BUILD.bazel b/infra/bots/task_drivers/canvaskit_gold/BUILD.bazel
index 0c0d867..8a15b06 100644
--- a/infra/bots/task_drivers/canvaskit_gold/BUILD.bazel
+++ b/infra/bots/task_drivers/canvaskit_gold/BUILD.bazel
@@ -7,6 +7,7 @@
     visibility = ["//visibility:private"],
     deps = [
         "@org_skia_go_infra//go/exec",
+        "@org_skia_go_infra//go/skerr",
         "@org_skia_go_infra//task_driver/go/lib/bazel",
         "@org_skia_go_infra//task_driver/go/lib/os_steps",
         "@org_skia_go_infra//task_driver/go/td",
diff --git a/infra/bots/task_drivers/canvaskit_gold/canvaskit_gold.go b/infra/bots/task_drivers/canvaskit_gold/canvaskit_gold.go
index 0877d74..3f93866 100644
--- a/infra/bots/task_drivers/canvaskit_gold/canvaskit_gold.go
+++ b/infra/bots/task_drivers/canvaskit_gold/canvaskit_gold.go
@@ -18,6 +18,7 @@
 	"strings"
 
 	sk_exec "go.skia.org/infra/go/exec"
+	"go.skia.org/infra/go/skerr"
 	"go.skia.org/infra/task_driver/go/lib/bazel"
 	"go.skia.org/infra/task_driver/go/lib/os_steps"
 	"go.skia.org/infra/task_driver/go/td"
@@ -32,7 +33,7 @@
 	taskId     = flag.String("task_id", "", "ID of this task.")
 	taskName   = flag.String("task_name", "", "Name of the task.")
 	workdir    = flag.String("workdir", ".", "Working directory, the root directory of a full Skia checkout")
-	testConfig = flag.String("test_config", "release", "The config name (defined in //bazel/buildrc), which indicates how CanvasKit should be compiled and tested.")
+	testConfig = flag.String("test_config", "", "The config name (defined in //bazel/buildrc), which indicates how CanvasKit should be compiled and tested.")
 	cross      = flag.String("cross", "", "[not yet supported] For use with cross-compiling.")
 	// goldctl data
 	goldctlPath      = flag.String("goldctl_path", "", "The path to the golctl binary on disk.")
@@ -40,6 +41,11 @@
 	changelistID     = flag.String("changelist_id", "", "Should be non-empty only when run on the CQ.")
 	patchsetOrderStr = flag.String("patchset_order", "", "Should be non-zero only when run on the CQ.")
 	tryjobID         = flag.String("tryjob_id", "", "Should be non-zero only when run on the CQ.")
+	// goldctl keys
+	browser         = flag.String("browser", "Chrome", "The browser running the tests")
+	compilationMode = flag.String("compilation_mode", "Release", "How the binary was compiled")
+	cpuOrGPU        = flag.String("cpu_or_gpu", "GPU", "The render backend")
+	cpuOrGPUValue   = flag.String("cpu_or_gpu_value", "WebGL2", "What variant of the render backend")
 
 	// Optional flags.
 	bazelCacheDir = flag.String("bazel_cache_dir", "/mnt/pd0/bazel_cache", "Override the Bazel cache directory with this path")
@@ -64,6 +70,9 @@
 			td.Fatal(ctx, err)
 		}
 	}
+	if *testConfig == "" {
+		td.Fatal(ctx, skerr.Fmt("Must specify --test_config"))
+	}
 
 	opts := bazel.BazelOptions{
 		// We want the cache to be on a bigger disk than default. The root disk, where the home
@@ -96,13 +105,12 @@
 		tryjobID:      *tryjobID,
 		corpus:        "canvaskit",
 		keys: map[string]string{
-			"arch":          "wasm32", // https://github.com/bazelbuild/platforms/blob/da5541f26b7de1dc8e04c075c99df5351742a4a2/cpu/BUILD#L109
-			"configuration": *testConfig,
-			// TODO(kjlubick) These should be deduced from testConfig
-			"browser":          "Chrome",
-			"compilation_mode": "Release",
-			"cpu_or_gpu":       "GPU",
-			"cpu_or_gpu_value": "WebGL",
+			"arch":             "wasm32", // https://github.com/bazelbuild/platforms/blob/da5541f26b7de1dc8e04c075c99df5351742a4a2/cpu/BUILD#L109
+			"configuration":    *testConfig,
+			"browser":          *browser,
+			"compilation_mode": *compilationMode,
+			"cpu_or_gpu":       *cpuOrGPU,
+			"cpu_or_gpu_value": *cpuOrGPUValue,
 		},
 	}
 	if err := uploadDataToGold(ctx, skiaDir, conf); err != nil {
diff --git a/infra/bots/tasks.json b/infra/bots/tasks.json
index c3402b5..d0911de 100755
--- a/infra/bots/tasks.json
+++ b/infra/bots/tasks.json
@@ -30,6 +30,11 @@
         "BazelBuild-skia_public-release-linux_x64"
       ]
     },
+    "BazelTest-canvaskit_gold-ck_full_cpu_release_chrome-linux_x64": {
+      "tasks": [
+        "BazelTest-canvaskit_gold-ck_full_cpu_release_chrome-linux_x64"
+      ]
+    },
     "BazelTest-canvaskit_gold-ck_full_webgl2_release_chrome-linux_x64": {
       "tasks": [
         "BazelTest-canvaskit_gold-ck_full_webgl2_release_chrome-linux_x64"
@@ -3594,6 +3599,57 @@
       "max_attempts": 1,
       "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
     },
+    "BazelTest-canvaskit_gold-ck_full_cpu_release_chrome-linux_x64": {
+      "casSpec": "compile",
+      "cipd_packages": [
+        {
+          "name": "skia/bots/bazelisk",
+          "path": "bazelisk",
+          "version": "version:0"
+        },
+        {
+          "name": "skia/tools/goldctl/${platform}",
+          "path": "cipd_bin_packages",
+          "version": "git_revision:34ecdc8775563915792e05ba9d921342808ae2dc"
+        }
+      ],
+      "command": [
+        "./canvaskit_gold",
+        "--project_id=skia-swarming-bots",
+        "--task_id=<(TASK_ID)",
+        "--task_name=BazelTest-canvaskit_gold-ck_full_cpu_release_chrome-linux_x64",
+        "--test_config=ck_full_cpu_release_chrome",
+        "--workdir=.",
+        "--goldctl_path=./cipd_bin_packages/goldctl",
+        "--git_commit=<(REVISION)",
+        "--changelist_id=<(ISSUE)",
+        "--patchset_order=<(PATCHSET)",
+        "--tryjob_id=<(BUILDBUCKET_BUILD_ID)",
+        "--expunge_cache",
+        "--cpu_or_gpu=CPU",
+        "--cpu_or_gpu_value=CPU",
+        "--compilation_mode=Release",
+        "--browser=Chrome"
+      ],
+      "dependencies": [
+        "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64"
+      ],
+      "dimensions": [
+        "cpu:x86-64-Haswell_GCE",
+        "gpu:none",
+        "machine_type:n1-standard-16",
+        "os:Debian-10.3",
+        "pool:Skia"
+      ],
+      "env_prefixes": {
+        "PATH": [
+          "bazelisk"
+        ]
+      },
+      "idempotent": true,
+      "max_attempts": 1,
+      "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
+    },
     "BazelTest-canvaskit_gold-ck_full_webgl2_release_chrome-linux_x64": {
       "casSpec": "compile",
       "cipd_packages": [
@@ -3620,7 +3676,11 @@
         "--changelist_id=<(ISSUE)",
         "--patchset_order=<(PATCHSET)",
         "--tryjob_id=<(BUILDBUCKET_BUILD_ID)",
-        "--expunge_cache"
+        "--expunge_cache",
+        "--cpu_or_gpu=GPU",
+        "--cpu_or_gpu_value=WebGL2",
+        "--compilation_mode=Release",
+        "--browser=Chrome"
       ],
       "dependencies": [
         "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64"
@@ -86592,6 +86652,11 @@
   "commit_queue": {
     "BazelBuild-example_hello_world_dawn-release-linux_x64": {},
     "BazelBuild-skia_public-enforce_iwyu-linux_x64": {},
+    "BazelTest-canvaskit_gold-ck_full_cpu_release_chrome-linux_x64": {
+      "location_regexes": [
+        "modules/canvaskit/.*"
+      ]
+    },
     "BazelTest-canvaskit_gold-ck_full_webgl2_release_chrome-linux_x64": {
       "location_regexes": [
         "modules/canvaskit/.*"