Skip to content

Commit 69a7421

Browse files
committed
playground: add a goprevplay service, hosting the previous go release
Change-Id: Ibdd5f45062960cd09965df63c12cde394dca1f8b Reviewed-on: https://go-review.googlesource.com/c/playground/+/367814 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org>
1 parent f648226 commit 69a7421

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

app.goprev.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
service: golast-play
2+
runtime: custom
3+
env: flex
4+
5+
network:
6+
name: projects/golang-org/global/networks/golang
7+
8+
resources:
9+
cpu: 2
10+
memory_gb: 2
11+
12+
automatic_scaling:
13+
min_num_instances: 5
14+
15+
readiness_check:
16+
path: "/_ah/health"
17+
check_interval_sec: 10
18+
19+
env_variables:
20+
MEMCACHED_ADDR: 'memcached-play-golang:11211'
21+
GOTIP: "true"
22+

cmd/latestgo/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ package main
77

88
import (
99
"context"
10+
"flag"
1011
"fmt"
1112
"log"
1213

1314
"golang.org/x/build/maintner/maintnerd/apipb"
1415
grpc "grpc.go4.org"
1516
)
1617

18+
var prev = flag.Bool("prev", false, "whether to query the previous Go release, rather than the last (e.g. 1.17 versus 1.18)")
19+
1720
const maintnerURI = "https://maintner.golang.org"
1821

1922
func main() {
23+
flag.Parse()
24+
2025
conn, err := grpc.NewClient(nil, maintnerURI)
2126
if err != nil {
2227
log.Fatalf("error creating grpc client for %q: %v", maintnerURI, err)
@@ -27,6 +32,10 @@ func main() {
2732
if err != nil {
2833
log.Fatalln(err)
2934
}
35+
idx := 0
36+
if *prev {
37+
idx = 1
38+
}
3039
// On success, the maintner API always returns at least two releases.
31-
fmt.Print(resp.GetReleases()[0].GetTagName())
40+
fmt.Print(resp.GetReleases()[idx].GetTagName())
3241
}

deploy/deploy_goprev.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"steps": [
3+
{
4+
"name": "golang",
5+
"env": [
6+
"GO111MODULE=on"
7+
],
8+
"entrypoint": "bash",
9+
"args": [
10+
"-c",
11+
"go run golang.org/x/playground/cmd/latestgo -prev > /workspace/goversion; echo GO_VERSION=`cat /workspace/goversion`"
12+
]
13+
},
14+
{
15+
"name": "gcr.io/cloud-builders/docker",
16+
"entrypoint": "bash",
17+
"args": [
18+
"-c",
19+
"docker build --build-arg GO_VERSION=`cat /workspace/goversion` -t gcr.io/$PROJECT_ID/playground ."
20+
]
21+
},
22+
{
23+
"name": "gcr.io/cloud-builders/docker",
24+
"args": [
25+
"push",
26+
"gcr.io/$PROJECT_ID/playground"
27+
]
28+
},
29+
{
30+
"name": "gcr.io/cloud-builders/gcloud",
31+
"args": [
32+
"app",
33+
"deploy",
34+
"app.goprev.yaml",
35+
"--project=$PROJECT_ID",
36+
"--image-url=gcr.io/$PROJECT_ID/playground-goprev:latest"
37+
]
38+
}
39+
],
40+
"timeout": "3600s"
41+
}

0 commit comments

Comments
 (0)