From b83413b16774e0436e6ef1074a526fcd556acd2b Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 30 Jul 2019 09:57:11 -0700 Subject: [PATCH] Use GOPROXY to speed up builds (#7984) Read more here https://proxy.golang.org proposal for go1.13 --- .travis.yml | 2 ++ Dockerfile.simpleci | 1 + Makefile | 30 +++++++++++++++--------------- README.md | 2 +- buildscripts/cross-compile.sh | 1 + buildscripts/go-coverage.sh | 2 +- buildscripts/verify-build.sh | 1 + mint/build/aws-sdk-go/install.sh | 2 +- mint/build/healthcheck/install.sh | 2 +- mint/build/minio-go/install.sh | 2 +- mint/build/security/install.sh | 2 +- mint/build/worm/install.sh | 2 +- mint/mint.sh | 2 ++ 13 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9387386c5..2f7388420 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ matrix: - ARCH=x86_64 - CGO_ENABLED=0 - GO111MODULE=on + - GOPROXY=https://proxy.golang.org # Enable build cache # https://restic.net/blog/2018-09-02/travis-build-cache cache: @@ -52,6 +53,7 @@ matrix: - ARCH=x86_64 - CGO_ENABLED=0 - GO111MODULE=on + - GOPROXY=https://proxy.golang.org go: 1.12.5 script: - go build --ldflags="$(go run buildscripts/gen-ldflags.go)" -o %GOPATH%\bin\minio.exe diff --git a/Dockerfile.simpleci b/Dockerfile.simpleci index 30bdad4be..2c8bba41a 100644 --- a/Dockerfile.simpleci +++ b/Dockerfile.simpleci @@ -8,6 +8,7 @@ WORKDIR /go/src/github.com/minio/minio RUN apt-get update && apt-get install -y jq ENV GO111MODULE=on +ENV GOPROXY=https://proxy.golang.org RUN git config --global http.cookiefile /gitcookie/.gitcookie diff --git a/Makefile b/Makefile index 1972c69ed..76f755f01 100644 --- a/Makefile +++ b/Makefile @@ -30,35 +30,35 @@ verifiers: getdeps vet fmt lint staticcheck spelling vet: @echo "Running $@" - @GO111MODULE=on go vet github.com/minio/minio/... + @GOPROXY=https://proxy.golang.org GO111MODULE=on go vet github.com/minio/minio/... fmt: @echo "Running $@" - @GO111MODULE=on gofmt -d cmd/ - @GO111MODULE=on gofmt -d pkg/ + @GOPROXY=https://proxy.golang.org GO111MODULE=on gofmt -d cmd/ + @GOPROXY=https://proxy.golang.org GO111MODULE=on gofmt -d pkg/ lint: @echo "Running $@" - @GO111MODULE=on ${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/cmd/... - @GO111MODULE=on ${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/pkg/... + @GOPROXY=https://proxy.golang.org GO111MODULE=on ${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/cmd/... + @GOPROXY=https://proxy.golang.org GO111MODULE=on ${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/pkg/... staticcheck: @echo "Running $@" - @GO111MODULE=on ${GOPATH}/bin/staticcheck github.com/minio/minio/cmd/... - @GO111MODULE=on ${GOPATH}/bin/staticcheck github.com/minio/minio/pkg/... + @GOPROXY=https://proxy.golang.org GO111MODULE=on ${GOPATH}/bin/staticcheck github.com/minio/minio/cmd/... + @GOPROXY=https://proxy.golang.org GO111MODULE=on ${GOPATH}/bin/staticcheck github.com/minio/minio/pkg/... spelling: - @GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find cmd/` - @GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find pkg/` - @GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find docs/` - @GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find buildscripts/` - @GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find dockerscripts/` + @GOPROXY=https://proxy.golang.org GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find cmd/` + @GOPROXY=https://proxy.golang.org GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find pkg/` + @GOPROXY=https://proxy.golang.org GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find docs/` + @GOPROXY=https://proxy.golang.org GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find buildscripts/` + @GOPROXY=https://proxy.golang.org GO111MODULE=on ${GOPATH}/bin/misspell -locale US -error `find dockerscripts/` # Builds minio, runs the verifiers then runs the tests. check: test test: verifiers build @echo "Running unit tests" - @GO111MODULE=on CGO_ENABLED=0 go test -tags kqueue ./... 1>/dev/null + @GOPROXY=https://proxy.golang.org GO111MODULE=on CGO_ENABLED=0 go test -tags kqueue ./... 1>/dev/null verify: build @echo "Verifying build" @@ -71,8 +71,8 @@ coverage: build # Builds minio locally. build: checks @echo "Building minio binary to './minio'" - @GO111MODULE=on GOFLAGS="" CGO_ENABLED=0 go build -tags kqueue --ldflags $(BUILD_LDFLAGS) -o $(PWD)/minio 1>/dev/null - @GO111MODULE=on GOFLAGS="" CGO_ENABLED=0 go build -tags kqueue --ldflags $(BUILD_LDFLAGS) -o $(PWD)/dockerscripts/healthcheck $(PWD)/dockerscripts/healthcheck.go 1>/dev/null + @GOPROXY=https://proxy.golang.org GO111MODULE=on GOFLAGS="" CGO_ENABLED=0 go build -tags kqueue --ldflags $(BUILD_LDFLAGS) -o $(PWD)/minio 1>/dev/null + @GOPROXY=https://proxy.golang.org GO111MODULE=on GOFLAGS="" CGO_ENABLED=0 go build -tags kqueue --ldflags $(BUILD_LDFLAGS) -o $(PWD)/dockerscripts/healthcheck $(PWD)/dockerscripts/healthcheck.go 1>/dev/null docker: build @docker build -t $(TAG) . -f Dockerfile.dev diff --git a/README.md b/README.md index 03a61bf7a..482eff503 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ service minio start Source installation is only intended for developers and advanced users. If you do not have a working Golang environment, please follow [How to install Golang](https://golang.org/doc/install). Minimum version required is [go1.12](https://golang.org/dl/#stable) ```sh -GO111MODULE=on go get github.com/minio/minio +GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/minio/minio ``` ## Allow port access for Firewalls diff --git a/buildscripts/cross-compile.sh b/buildscripts/cross-compile.sh index edf1786b9..a094a6511 100755 --- a/buildscripts/cross-compile.sh +++ b/buildscripts/cross-compile.sh @@ -23,6 +23,7 @@ function _build() { export GOOS=$os export GOARCH=$arch export GO111MODULE=on + export GOPROXY=https://proxy.golang.org go build -tags kqueue -o /dev/null } diff --git a/buildscripts/go-coverage.sh b/buildscripts/go-coverage.sh index 5efcfbb03..67599fd02 100755 --- a/buildscripts/go-coverage.sh +++ b/buildscripts/go-coverage.sh @@ -2,4 +2,4 @@ set -e -GO111MODULE=on CGO_ENABLED=0 go test -v -coverprofile=coverage.txt -covermode=atomic ./... +GOPROXY=https://proxy.golang.org GO111MODULE=on CGO_ENABLED=0 go test -v -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/buildscripts/verify-build.sh b/buildscripts/verify-build.sh index fd06a7e61..fc147a917 100755 --- a/buildscripts/verify-build.sh +++ b/buildscripts/verify-build.sh @@ -33,6 +33,7 @@ export ACCESS_KEY="minio" export SECRET_KEY="minio123" export ENABLE_HTTPS=0 export GO111MODULE=on +export GOPROXY=https://proxy.golang.org MINIO_CONFIG_DIR="$WORK_DIR/.minio" MINIO=( "$PWD/minio" --config-dir "$MINIO_CONFIG_DIR" ) diff --git a/mint/build/aws-sdk-go/install.sh b/mint/build/aws-sdk-go/install.sh index d73162840..0c5529078 100755 --- a/mint/build/aws-sdk-go/install.sh +++ b/mint/build/aws-sdk-go/install.sh @@ -16,4 +16,4 @@ # test_run_dir="$MINT_RUN_CORE_DIR/aws-sdk-go" -GO111MODULE=on go build -o "$test_run_dir/aws-sdk-go" "$test_run_dir/quick-tests.go" +GOPROXY=https://proxy.golang.org GO111MODULE=on go build -o "$test_run_dir/aws-sdk-go" "$test_run_dir/quick-tests.go" diff --git a/mint/build/healthcheck/install.sh b/mint/build/healthcheck/install.sh index 71ffe4823..906a62e67 100755 --- a/mint/build/healthcheck/install.sh +++ b/mint/build/healthcheck/install.sh @@ -16,4 +16,4 @@ # test_run_dir="$MINT_RUN_CORE_DIR/healthcheck" -GO111MODULE=on go build -o "$test_run_dir/healthcheck" "$test_run_dir/healthcheck.go" +GOPROXY=https://proxy.golang.org GO111MODULE=on go build -o "$test_run_dir/healthcheck" "$test_run_dir/healthcheck.go" diff --git a/mint/build/minio-go/install.sh b/mint/build/minio-go/install.sh index 5e3005199..1debb922b 100755 --- a/mint/build/minio-go/install.sh +++ b/mint/build/minio-go/install.sh @@ -23,5 +23,5 @@ fi test_run_dir="$MINT_RUN_CORE_DIR/minio-go" (git clone https://github.com/minio/minio-go && cd minio-go && git checkout --quiet "tags/$MINIO_GO_VERSION") -GO111MODULE=on CGO_ENABLED=0 go build -o "$test_run_dir/minio-go" "minio-go/functional_tests.go" +GOPROXY=https://proxy.golang.org GO111MODULE=on CGO_ENABLED=0 go build -o "$test_run_dir/minio-go" "minio-go/functional_tests.go" rm -rf minio-go diff --git a/mint/build/security/install.sh b/mint/build/security/install.sh index a517bfb18..e45c6789a 100755 --- a/mint/build/security/install.sh +++ b/mint/build/security/install.sh @@ -16,4 +16,4 @@ # test_run_dir="$MINT_RUN_CORE_DIR/security" -GO111MODULE=on go build -o "$test_run_dir/tls-tests" "$test_run_dir/tls-tests.go" +GOPROXY=https://proxy.golang.org GO111MODULE=on go build -o "$test_run_dir/tls-tests" "$test_run_dir/tls-tests.go" diff --git a/mint/build/worm/install.sh b/mint/build/worm/install.sh index 7cdf1fd0f..49f3191bf 100755 --- a/mint/build/worm/install.sh +++ b/mint/build/worm/install.sh @@ -16,4 +16,4 @@ # test_run_dir="$MINT_RUN_CORE_DIR/worm" -GO111MODULE=on CGO_ENABLED=0 go build -o "$test_run_dir/worm" "$test_run_dir/quick-worm-tests.go" +GOPROXY=https://proxy.golang.org GO111MODULE=on CGO_ENABLED=0 go build -o "$test_run_dir/worm" "$test_run_dir/quick-worm-tests.go" diff --git a/mint/mint.sh b/mint/mint.sh index 953c3f096..5d9e9972c 100755 --- a/mint/mint.sh +++ b/mint/mint.sh @@ -22,6 +22,7 @@ SERVER_REGION=${SERVER_REGION:-us-east-1} ENABLE_HTTPS=${ENABLE_HTTPS:-0} ENABLE_VIRTUAL_STYLE=${ENABLE_VIRTUAL_STYLE:-0} GO111MODULE=on +GOPROXY=https://proxy.golang.org if [ -z "$SERVER_ENDPOINT" ]; then SERVER_ENDPOINT="play.minio.io:9000" @@ -137,6 +138,7 @@ function main() export SERVER_REGION export ENABLE_VIRTUAL_STYLE export GO111MODULE + export GOPROXY echo "Running with" echo "SERVER_ENDPOINT: $SERVER_ENDPOINT"