cmd/release, dashboard: implement builder plan for Go 1.16

See https://golang.org/issues/40561#issuecomment-731482962
for the plan description and rationale.

Add new builder definitions that are needed for the plan.
Don't rely on generic builder name like "linux-amd64" to
avoid a repeat of golang.org/issue/31293; use a specific
builder name instead.

Remove support and test cases for Go 1.13, it's unsupported
per release policy.

For golang/go#40561.

Change-Id: I070744e15be9f1932d649a27ee7e4599e467553f
Reviewed-on: https://go-review.googlesource.com/c/build/+/276034
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
diff --git a/cmd/release/release.go b/cmd/release/release.go
index 1949a69..3838068 100644
--- a/cmd/release/release.go
+++ b/cmd/release/release.go
@@ -151,29 +151,30 @@
 		Builder: "linux-amd64",
 	},
 	{
+		GoQuery: ">= go1.16beta1",
 		OS:      "linux",
 		Arch:    "386",
-		Builder: "linux-386",
+		Builder: "linux-386-stretch",
 	},
 	{
+		GoQuery: ">= go1.16beta1",
 		OS:      "linux",
 		Arch:    "arm",
-		Builder: "linux-arm",
-		Goarm:   6, // for compatibility with all Raspberry Pi models.
-		// The tests take too long for the release packaging.
-		// Much of the time the whole buildlet times out.
-		SkipTests: true,
+		Builder: "linux-arm-aws",
+		Goarm:   6, // For compatibility with all Raspberry Pi models.
 	},
 	{
+		GoQuery: ">= go1.16beta1",
 		OS:      "linux",
 		Arch:    "amd64",
 		Race:    true,
-		Builder: "linux-amd64-jessie", // using Jessie for at least [Go 1.11, Go 1.13] due to golang.org/issue/31293
+		Builder: "linux-amd64-stretch", // Using Stretch as of Go 1.16 because Jessie LTS has ended (golang.org/issue/40561#issuecomment-731482962).
 	},
 	{
+		GoQuery: ">= go1.16beta1",
 		OS:      "linux",
 		Arch:    "arm64",
-		Builder: "linux-arm64-packet",
+		Builder: "linux-arm64-aws",
 	},
 	{
 		GoQuery: ">= go1.15rc2", // See #40563.
@@ -224,6 +225,35 @@
 
 	// Older builds.
 	{
+		GoQuery: "< go1.16beta1",
+		OS:      "linux",
+		Arch:    "386",
+		Builder: "linux-386-jessie",
+	},
+	{
+		GoQuery: "< go1.16beta1",
+		OS:      "linux",
+		Arch:    "arm",
+		Builder: "linux-arm",
+		Goarm:   6, // For compatibility with all Raspberry Pi models.
+		// The tests take too long for the release packaging.
+		// Much of the time the whole buildlet times out.
+		SkipTests: true,
+	},
+	{
+		GoQuery: "< go1.16beta1",
+		OS:      "linux",
+		Arch:    "amd64",
+		Race:    true,
+		Builder: "linux-amd64-jessie", // Using Jessie for Go 1.11 through Go 1.15 inclusive due to golang.org/issue/31293.
+	},
+	{
+		GoQuery: "< go1.16beta1",
+		OS:      "linux",
+		Arch:    "arm64",
+		Builder: "linux-arm64-packet",
+	},
+	{
 		GoQuery: "< go1.15",
 		OS:      "freebsd",
 		Arch:    "386",
@@ -960,9 +990,9 @@
 	// TODO(amedee,dmitshur,golang.org/issue/40558): Use a version package to compare versions of Go.
 
 	// The minimum supported version of macOS with each version of go:
-	// go1.13 - macOS 10.11
 	// go1.14 - macOS 10.11
 	// go1.15 - macOS 10.12
+	// go1.16 - macOS 10.12
 	minMacVersion := "10.12"
 	if match("< go1.15", goVer) {
 		minMacVersion = "10.11"
@@ -979,14 +1009,18 @@
 	switch query {
 	case "": // A special case to make the zero Build.GoQuery value useful.
 		return true
+	case ">= go1.16beta1":
+		return !strings.HasPrefix(goVer, "go1.15") && !strings.HasPrefix(goVer, "go1.14")
+	case "< go1.16beta1":
+		return strings.HasPrefix(goVer, "go1.15") || strings.HasPrefix(goVer, "go1.14")
 	case ">= go1.15rc2":
 		// By the time this code is added, Go 1.15 RC 1 has already been released and
 		// won't be modified, that's why we only care about matching RC 2 and onwards.
 		// (We could've just done ">= go1.15", but that could be misleading in future.)
 		return goVer != "go1.15rc1" && !strings.HasPrefix(goVer, "go1.15beta") &&
-			!strings.HasPrefix(goVer, "go1.14") && !strings.HasPrefix(goVer, "go1.13")
+			!strings.HasPrefix(goVer, "go1.14")
 	case "< go1.15":
-		return strings.HasPrefix(goVer, "go1.14") || strings.HasPrefix(goVer, "go1.13")
+		return strings.HasPrefix(goVer, "go1.14")
 	default:
 		panic(fmt.Errorf("match: query %q is not supported", query))
 	}
diff --git a/cmd/release/release_test.go b/cmd/release/release_test.go
index bcacef6..a980221 100644
--- a/cmd/release/release_test.go
+++ b/cmd/release/release_test.go
@@ -42,19 +42,20 @@
 
 func TestMinSupportedMacOSVersion(t *testing.T) {
 	testCases := []struct {
-		desc      string
 		goVer     string
 		wantMacOS string
 	}{
-		{"minor_release_13", "go1.13", "10.11"},
-		{"minor_release_14", "go1.14", "10.11"},
-		{"rc_release_13", "go1.13rc1", "10.11"},
-		{"beta_release_13", "go1.13beta1", "10.11"},
-		{"minor_release_15", "go1.15", "10.12"},
-		{"patch_release_15", "go1.15.1", "10.12"},
+		{"go1.14", "10.11"},
+		{"go1.14.14", "10.11"},
+		{"go1.15", "10.12"},
+		{"go1.15.7", "10.12"},
+		{"go1.16beta1", "10.12"},
+		{"go1.16rc1", "10.12"},
+		{"go1.16", "10.12"},
+		{"go1.16.1", "10.12"},
 	}
 	for _, tc := range testCases {
-		t.Run(tc.desc, func(t *testing.T) {
+		t.Run(tc.goVer, func(t *testing.T) {
 			got := minSupportedMacOSVersion(tc.goVer)
 			if got != tc.wantMacOS {
 				t.Errorf("got %s; want %s", got, tc.wantMacOS)
@@ -63,7 +64,7 @@
 	}
 }
 
-func TestFreeBSDBuilder(t *testing.T) {
+func TestBuilderSelectionPerGoVersion(t *testing.T) {
 	matchBuilds := func(target, goVer string) (matched []*Build) {
 		for _, b := range builds {
 			if b.String() != target || !match(b.GoQuery, goVer) {
@@ -79,12 +80,23 @@
 		target      string
 		wantBuilder string
 	}{
-		// Go 1.14.x and 1.13.x still use the FreeBSD 11.1 builder.
-		{"go1.13.55", "freebsd-amd64", "freebsd-amd64-11_1"},
-		{"go1.13.55", "freebsd-386", "freebsd-386-11_1"},
+		// Go 1.15.x and 1.14.x still use the Jessie builders.
+		{"go1.14.55", "linux-amd64", "linux-amd64-jessie"},
+		{"go1.15.55", "linux-386", "linux-386-jessie"},
+		// Go 1.16 starts to use the the Stretch builders.
+		{"go1.16", "linux-amd64", "linux-amd64-stretch"},
+		{"go1.16", "linux-386", "linux-386-stretch"},
+
+		// Go 1.15.x and 1.14.x still use the Packet and Scaleway builders.
+		{"go1.14.55", "linux-arm64", "linux-arm64-packet"},
+		{"go1.15.55", "linux-armv6l", "linux-arm"},
+		// Go 1.16 starts to use the the AWS builders.
+		{"go1.16", "linux-arm64", "linux-arm64-aws"},
+		{"go1.16", "linux-armv6l", "linux-arm-aws"},
+
+		// Go 1.14.x still use the FreeBSD 11.1 builder.
 		{"go1.14.55", "freebsd-amd64", "freebsd-amd64-11_1"},
 		{"go1.14.55", "freebsd-386", "freebsd-386-11_1"},
-
 		// Go 1.15 RC 2+ starts to use the the FreeBSD 11.2 builder.
 		{"go1.15rc2", "freebsd-amd64", "freebsd-amd64-11_2"},
 		{"go1.15rc2", "freebsd-386", "freebsd-386-11_2"},
@@ -92,14 +104,12 @@
 		{"go1.15", "freebsd-386", "freebsd-386-11_2"},
 		{"go1.15.1", "freebsd-amd64", "freebsd-amd64-11_2"},
 		{"go1.15.1", "freebsd-386", "freebsd-386-11_2"},
-
-		// May change further during the 1.16 dev cycle,
-		// but expect same builder as 1.15 for now.
+		// Go 1.16 continues to use the the FreeBSD 11.2 builder.
 		{"go1.16", "freebsd-amd64", "freebsd-amd64-11_2"},
 		{"go1.16", "freebsd-386", "freebsd-386-11_2"},
 	}
 	for _, tc := range testCases {
-		t.Run(tc.goVer, func(t *testing.T) {
+		t.Run(tc.target+"@"+tc.goVer, func(t *testing.T) {
 			builds := matchBuilds(tc.target, tc.goVer)
 			if len(builds) != 1 {
 				t.Fatalf("got %d matching builds; want 1", len(builds))
diff --git a/dashboard/builders.go b/dashboard/builders.go
index 9f914d2..332dd48 100644
--- a/dashboard/builders.go
+++ b/dashboard/builders.go
@@ -1790,6 +1790,15 @@
 		},
 	})
 	addBuilder(BuildConfig{
+		Name:       "linux-amd64-stretch",
+		HostType:   "host-linux-stretch",
+		Notes:      "Debian Stretch. Same as the normal 'linux-amd64' builder at this time, but with -stretch suffix. Used for release builds.",
+		buildsRepo: disabledBuilder, // Disabled because the "linux-amd64" builder does identical work.
+		env: []string{
+			"GO_DISABLE_OUTBOUND_NETWORK=1",
+		},
+	})
+	addBuilder(BuildConfig{
 		Name:     "linux-amd64-buster",
 		HostType: "host-linux-buster",
 		Notes:    "Debian Buster.",
@@ -1798,6 +1807,27 @@
 		},
 	})
 	addBuilder(BuildConfig{
+		Name:       "linux-386-jessie",
+		HostType:   "host-linux-jessie",
+		Notes:      "Debian Jessie, 32-bit builder. Same as the normal 'linux-386' builder at this time, but with -jessie suffix. Used for release builds.",
+		buildsRepo: disabledBuilder, // Disabled because the "linux-386" builder does identical work.
+		env: []string{
+			"GOARCH=386",
+			"GOHOSTARCH=386",
+			"GO_DISABLE_OUTBOUND_NETWORK=1",
+		},
+	})
+	addBuilder(BuildConfig{
+		Name:     "linux-386-stretch",
+		HostType: "host-linux-stretch",
+		Notes:    "Debian Stretch, 32-bit builder.",
+		env: []string{
+			"GOARCH=386",
+			"GOHOSTARCH=386",
+			"GO_DISABLE_OUTBOUND_NETWORK=1",
+		},
+	})
+	addBuilder(BuildConfig{
 		Name:     "linux-amd64-longtest",
 		HostType: "host-linux-stretch-morecpu",
 		Notes:    "Debian Stretch with go test -short=false",