aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/golangorg/app.yaml1
-rw-r--r--cmd/golangorg/cloudbuild.yaml3
-rw-r--r--cmd/golangorg/server.go13
-rw-r--r--cmd/golangorg/server_test.go14
4 files changed, 23 insertions, 8 deletions
diff --git a/cmd/golangorg/app.yaml b/cmd/golangorg/app.yaml
index 597744fa..2b6ae6f2 100644
--- a/cmd/golangorg/app.yaml
+++ b/cmd/golangorg/app.yaml
@@ -8,6 +8,7 @@ main: ./cmd/golangorg
env_variables:
GOLANGORG_REQUIRE_DL_SECRET_KEY: true
GOLANGORG_ENFORCE_HOSTS: true
+ GOLANGORG_FORCE_GOROOT_ZIP: true
GOLANGORG_REDIS_ADDR: 10.0.0.4:6379 # instance "gophercache"
GOLANGORG_ANALYTICS: UA-11222381-2
DATASTORE_PROJECT_ID: golang-org
diff --git a/cmd/golangorg/cloudbuild.yaml b/cmd/golangorg/cloudbuild.yaml
index 3d85da70..29dd7ba7 100644
--- a/cmd/golangorg/cloudbuild.yaml
+++ b/cmd/golangorg/cloudbuild.yaml
@@ -20,8 +20,9 @@ steps:
args: ["rm", "-rf", "_wikitmp/.git"]
- name: golang
args: ["sh", "-c", "cp -a _wikitmp/* _content/wiki"]
- # Run tests.
+ # Run tests with GOROOT content from _goroot.zip.
- name: golang
+ env: ["GOLANGORG_FORCE_GOROOT_ZIP=true"]
args: ["go", "test", "./..."]
# Coordinate with other Cloud Build jobs to deploy only newest commit.
# May abort job here.
diff --git a/cmd/golangorg/server.go b/cmd/golangorg/server.go
index 17d55a3f..3b015f98 100644
--- a/cmd/golangorg/server.go
+++ b/cmd/golangorg/server.go
@@ -25,6 +25,7 @@ import (
"path/filepath"
"runtime"
"runtime/debug"
+ "strconv"
"strings"
"sync"
"sync/atomic"
@@ -58,6 +59,7 @@ var (
contentDir = flag.String("content", "", "path to _content directory")
runningOnAppEngine = os.Getenv("PORT") != ""
+ forceGorootZip, _ = strconv.ParseBool(os.Getenv("GOLANGORG_FORCE_GOROOT_ZIP"))
tipFlag = flag.Bool("tip", runningOnAppEngine, "load git content for tip.golang.org")
wikiFlag = flag.Bool("wiki", runningOnAppEngine, "load git content for go.dev/wiki")
@@ -73,6 +75,9 @@ func usage() {
}
func main() {
+ flag.Usage = usage
+ flag.Parse()
+
// Running locally, find the local _content directory when it's available nearby,
// so that updates to those files appear on the local dev instance without restarting.
// On App Engine, leave contentDir empty, so we use the embedded copy,
@@ -87,9 +92,12 @@ func main() {
}
}
+ if forceGorootZip {
+ *goroot = "_goroot.zip"
+ }
+
if runningOnAppEngine {
log.Print("golang.org server starting")
- *goroot = "_goroot.zip"
log.SetFlags(log.Lshortfile | log.LstdFlags)
port := "8080"
if p := os.Getenv("PORT"); p != "" {
@@ -98,9 +106,6 @@ func main() {
*httpAddr = ":" + port
}
- flag.Usage = usage
- flag.Parse()
-
// Check usage.
if flag.NArg() > 0 {
fmt.Fprintln(os.Stderr, "Unexpected arguments.")
diff --git a/cmd/golangorg/server_test.go b/cmd/golangorg/server_test.go
index 31594689..ceb1ec49 100644
--- a/cmd/golangorg/server_test.go
+++ b/cmd/golangorg/server_test.go
@@ -27,7 +27,11 @@ import (
func TestWeb(t *testing.T) {
needsGorootDocDir(t)
- h := NewHandler("../../_content", runtime.GOROOT())
+ goroot := *goroot
+ if forceGorootZip {
+ goroot = "../../_goroot.zip"
+ }
+ h := NewHandler("../../_content", goroot)
files, err := filepath.Glob("testdata/*.txt")
if err != nil {
@@ -48,7 +52,7 @@ var bads = []string{
" < ",
"<-",
"& ",
- //"{{raw <code>", // TODO(go.dev/issue/78211,dmitshur): Disabled because it breaks testing during the deploy process (the _goroot.zip file isn't passed to tests).
+ "{{raw <code>",
}
var ignoreBads = []string{
@@ -81,7 +85,11 @@ Lines:
func TestAll(t *testing.T) {
needsGorootDocDir(t)
- h := NewHandler("../../_content", runtime.GOROOT())
+ goroot := *goroot
+ if forceGorootZip {
+ goroot = "../../_goroot.zip"
+ }
+ h := NewHandler("../../_content", goroot)
get := func(url string) (code int, body string, err error) {
if url == "https://go.dev/rebuild" {