dashboard: add linux-loong64-3a5000 builder

Updates golang/go#46229

Change-Id: Ib48e1e64d96a07d5c5282d78935124faf75c89d7
Reviewed-on: https://go-review.googlesource.com/c/build/+/347309
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
diff --git a/dashboard/builders.go b/dashboard/builders.go
index 7323c77..d3ba87c 100644
--- a/dashboard/builders.go
+++ b/dashboard/builders.go
@@ -53,6 +53,7 @@
 	"linux":                "linux-amd64",
 	"linux-arm":            "linux-arm-aws",
 	"linux-arm64":          "linux-arm64-aws",
+	"linux-loong64":        "linux-loong64-3a5000",
 	"linux-mips":           "linux-mips-rtrk",
 	"linux-mips64":         "linux-mips64-rtrk",
 	"linux-mips64le":       "linux-mips64le-mengzhuo",
@@ -579,6 +580,15 @@
 		ExpectNum:   1,
 		env:         []string{"GOROOT_BOOTSTRAP=/opt/golang/go-solaris-amd64-bootstrap"},
 	},
+	"host-linux-loong64-3a5000": &HostConfig{
+		Notes:       "Loongson 3A5000 Box hosted by Loongson; loong64 is the short name of LoongArch 64 bit version",
+		OwnerGithub: "XiaodongLoong",
+		IsReverse:   true,
+		ExpectNum:   5,
+		env: []string{
+			"GOROOT_BOOTSTRAP=/usr/lib/go-1.15",
+		},
+	},
 	"host-linux-mipsle-mengzhuo": &HostConfig{
 		Notes:       "Loongson 3A Box hosted by Meng Zhuo; actually MIPS64le despite the name",
 		OwnerGithub: "mengzhuo",
@@ -2358,6 +2368,18 @@
 		},
 	})
 	addBuilder(BuildConfig{
+		HostType:       "host-linux-loong64-3a5000",
+		Name:           "linux-loong64-3a5000",
+		SkipSnapshot:   true,
+		distTestAdjust: loong64DistTestPolicy,
+		buildsRepo:     loong64BuildsRepoPolicy,
+		env: []string{
+			"GOARCH=loong64",
+			"GOHOSTARCH=loong64",
+		},
+		KnownIssue: 46229,
+	})
+	addBuilder(BuildConfig{
 		FlakyNet:       true,
 		HostType:       "host-linux-mipsle-mengzhuo",
 		Name:           "linux-mips64le-mengzhuo",
@@ -2686,6 +2708,25 @@
 // riscvDistTestPolicy is same as mipsDistTestPolicy for now.
 var riscvDistTestPolicy = mipsDistTestPolicy
 
+// loong64DistTestPolicy is a distTestAdjust policy function
+func loong64DistTestPolicy(run bool, distTest string, isNormalTry bool) bool {
+	switch distTest {
+	case "api", "reboot":
+		return false
+	}
+	return run
+}
+
+// loong64BuildsRepoPolicy is a buildsRepo policy function
+func loong64BuildsRepoPolicy(repo, branch, goBranch string) bool {
+	switch repo {
+	case "go", "net", "sys":
+		return branch == "master" && goBranch == "master"
+	default:
+		return false
+	}
+}
+
 // TryBuildersForProject returns the builders that should run as part of
 // a TryBot set for the given project.
 // The project argument is of the form "go", "net", "sys", etc.
diff --git a/dashboard/builders_test.go b/dashboard/builders_test.go
index 6851c05..24a21f5 100644
--- a/dashboard/builders_test.go
+++ b/dashboard/builders_test.go
@@ -414,6 +414,10 @@
 		{b("linux-mips64le-mengzhuo", "sys"), onlyPost},
 		{b("linux-mips64le-mengzhuo", "net"), onlyPost},
 
+		{b("linux-loong64-3a5000", "go"), onlyPost},
+		{b("linux-loong64-3a5000", "sys"), onlyPost},
+		{b("linux-loong64-3a5000", "net"), onlyPost},
+
 		// OpenBSD.
 		{b("openbsd-amd64-68@go1.16", "go"), both},
 		{b("openbsd-amd64-68@go1.15", "go"), both},