Skip to content

Commit 3f78f44

Browse files
authored
Bring in build_tools 2.0 (ddev#1371)
* Updated build-tools to 2.0.0 https://github.com/drud/build-tools/releases/tag/2.0.0
1 parent 1e35bac commit 3f78f44

File tree

389 files changed

+31915
-10682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

389 files changed

+31915
-10682
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jobs:
144144
name: Build the ddev executables
145145

146146
- run:
147-
command: bin/linux/ddev version
147+
command: .gotmp/bin/ddev version
148148
name: ddev version information
149149

150150
# We only build the xz version of the docker images on tag build.

.circleci/generate_artifacts.sh

+12-10
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
# Optional second arg is whether to build xz version of ddev_docker_images.tar
55

66
set -o errexit
7+
set -o pipefail
8+
set -o nounset
79

8-
ARTIFACTS=$1
10+
ARTIFACTS=${1:-/artifacts}
911
# We only build the xz artifacts if $2 ($BUILD_XZ) is not empty.
10-
BUILD_XZ=$2
12+
BUILD_XZ=${2:-}
1113
BASE_DIR=$PWD
1214

13-
sudo mkdir $ARTIFACTS && sudo chmod 777 $ARTIFACTS
15+
sudo mkdir -p $ARTIFACTS && sudo chmod 777 $ARTIFACTS
1416
export VERSION=$(git describe --tags --always --dirty)
1517

1618
# Make sure we have all our docker images, and save them in a tarball
17-
$BASE_DIR/bin/linux/ddev version | awk '/drud\// {print $2;}' >/tmp/images.txt
19+
.gotmp/bin/ddev version | awk '/drud\// {print $2;}' >/tmp/images.txt
1820
for item in $(cat /tmp/images.txt); do
1921
docker pull $item
2022
done
@@ -25,23 +27,23 @@ if [ ! -z "$BUILD_XZ" ] ; then
2527
fi
2628

2729
# Generate and place extra items like autocomplete
28-
bin/linux/ddev_gen_autocomplete
29-
for dir in bin/darwin/darwin_amd64 bin/linux bin/windows/windows_amd64; do
30-
cp bin/ddev_bash_completion.sh $dir
30+
.gotmp/bin/ddev_gen_autocomplete
31+
for dir in .gotmp/bin/darwin_amd64 .gotmp/bin/windows_amd64; do
32+
cp .gotmp/bin/ddev_bash_completion.sh $dir
3133
done
3234

3335
# Generate macOS tarball/zipball
34-
cd $BASE_DIR/bin/darwin/darwin_amd64
36+
cd $BASE_DIR/.gotmp/bin/darwin_amd64
3537
tar -czf $ARTIFACTS/ddev_macos.$VERSION.tar.gz ddev ddev_bash_completion.sh
3638
zip $ARTIFACTS/ddev_macos.$VERSION.zip ddev ddev_bash_completion.sh
3739

3840
# Generate linux tarball/zipball
39-
cd $BASE_DIR/bin/linux
41+
cd $BASE_DIR/.gotmp/bin
4042
tar -czf $ARTIFACTS/ddev_linux.$VERSION.tar.gz ddev ddev_bash_completion.sh
4143
zip $ARTIFACTS/ddev_linux.$VERSION.zip ddev ddev_bash_completion.sh
4244

4345
# generate windows tarball/zipball
44-
cd $BASE_DIR/bin/windows/windows_amd64
46+
cd $BASE_DIR/.gotmp/bin/windows_amd64
4547
tar -czf $ARTIFACTS/ddev_windows.$VERSION.tar.gz ddev.exe ddev_bash_completion.sh
4648
zip $ARTIFACTS/ddev_windows.$VERSION.zip ddev.exe ddev_bash_completion.sh
4749
cp ddev_windows_installer*.exe $ARTIFACTS

.golangci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
run:
2+
modules-download-mode: vendor
3+

Makefile

+9-9
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,25 @@ TESTOS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
6565
TEST_TIMEOUT=120m
6666
BUILD_ARCH = $(shell go env GOARCH)
6767
ifeq ($(BUILD_OS),linux)
68-
DDEV_BINARY_FULLPATH=$(PWD)/bin/$(BUILD_OS)/ddev
68+
DDEV_BINARY_FULLPATH=$(PWD)/$(GOTMP)/bin/ddev
6969
endif
7070

7171
ifeq ($(BUILD_OS),windows)
72-
DDEV_BINARY_FULLPATH=$(PWD)/bin/$(BUILD_OS)/$(BUILD_OS)_$(BUILD_ARCH)/ddev.exe
72+
DDEV_BINARY_FULLPATH=$(PWD)/$(GOTMP)/bin/$(BUILD_OS)_$(BUILD_ARCH)/ddev.exe
7373
endif
7474

7575
ifeq ($(BUILD_OS),darwin)
76-
DDEV_BINARY_FULLPATH=$(PWD)/bin/$(BUILD_OS)/$(BUILD_OS)_$(BUILD_ARCH)/ddev
76+
DDEV_BINARY_FULLPATH=$(PWD)/$(GOTMP)/bin/$(BUILD_OS)_$(BUILD_ARCH)/ddev
7777
endif
7878

7979
# Override test section with tests specific to ddev
8080
test: testpkg testcmd
8181

8282
testcmd: $(BUILD_OS) setup
83-
DDEV_NO_SENTRY=true CGO_ENABLED=0 DDEV_BINARY_FULLPATH=$(DDEV_BINARY_FULLPATH) go test -p 1 -timeout $(TEST_TIMEOUT) -v -installsuffix static -ldflags '$(LDFLAGS)' ./cmd/... $(TESTARGS)
83+
DDEV_NO_SENTRY=true CGO_ENABLED=0 DDEV_BINARY_FULLPATH=$(DDEV_BINARY_FULLPATH) go test $(USEMODVENDOR) -p 1 -timeout $(TEST_TIMEOUT) -v -installsuffix static -ldflags '$(LDFLAGS)' ./cmd/... $(TESTARGS)
8484

8585
testpkg: setup
86-
DDEV_NO_SENTRY=true CGO_ENABLED=0 go test -p 1 -timeout $(TEST_TIMEOUT) -v -installsuffix static -ldflags '$(LDFLAGS)' ./pkg/... $(TESTARGS)
86+
DDEV_NO_SENTRY=true CGO_ENABLED=0 go test $(USEMODVENDOR) -p 1 -timeout $(TEST_TIMEOUT) -v -installsuffix static -ldflags '$(LDFLAGS)' ./pkg/... $(TESTARGS)
8787

8888
setup:
8989
@(mv -f ~/.ddev/global_config.yaml ~/.ddev/global_config.yaml.bak 2>/dev/null && echo "Warning: Removed your global ddev config file") || true
@@ -94,10 +94,10 @@ setup:
9494
# Required static analysis targets used in circleci - these cause fail if they don't work
9595
staticrequired: golangci-lint
9696

97-
windows_install: windows bin/windows/windows_amd64/sudo.exe bin/windows/windows_amd64/sudo_license.txt
97+
windows_install: windows $(GOTMP)/bin/windows_amd64/sudo.exe $(GOTMP)/bin/windows_amd64/sudo_license.txt
9898
makensis -DVERSION=$(VERSION) winpkg/ddev.nsi # brew install makensis, apt-get install nsis, or install on Windows
9999

100-
bin/windows/windows_amd64/sudo.exe bin/windows/windows_amd64/sudo_license.txt:
100+
$(GOTMP)/bin/windows_amd64/sudo.exe $(GOTMP)/bin/windows_amd64/sudo_license.txt:
101101
curl -sSL -o /tmp/sudo.zip -O https://github.com/mattn/sudo/releases/download/$(WINDOWS_SUDO_VERSION)/sudo-x86_64.zip
102-
unzip -o -d $(PWD)/bin/windows/windows_amd64 /tmp/sudo.zip
103-
curl -sSL -o $(PWD)/bin/windows/windows_amd64/sudo_license.txt https://raw.githubusercontent.com/mattn/sudo/master/LICENSE
102+
unzip -o -d $(GOTMP)/bin/windows_amd64 /tmp/sudo.zip
103+
curl -sSL -o $(GOTMP)/bin/windows_amd64/sudo_license.txt https://raw.githubusercontent.com/mattn/sudo/master/LICENSE

build-tools/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ make linux
4040
make darwin
4141
make gofmt
4242
make govet
43-
make govendor
4443
make golint
4544
make codecoroner
46-
make static (gofmt, govet, golint, govendor)
45+
make static (gofmt, govet, golint)
4746
make test
4847
make container
4948
make push

build-tools/makefile_components/base_build_go.mak

+37-92
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@
44
##### contents into ../Makefile and commenting out the include and adding a
55
##### comment about what you did and why.
66

7-
8-
.PHONY: all build test push clean container-clean bin-clean version static govendor gofmt govet golint golangci-lint container
7+
DOCKERBUILDCMD=docker run -t --rm -u $(shell id -u):$(shell id -g) \
8+
-v "$(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG)" \
9+
-v "$(S)$$PWD:/workdir$(DOCKERMOUNTFLAG)" \
10+
-e CGO_ENABLED=0 \
11+
-e GOOS=$@ \
12+
-w $(S)/workdir \
13+
$(BUILD_IMAGE)
14+
15+
DOCKERTESTCMD=docker run -t --rm -u $(shell id -u):$(shell id -g) \
16+
-v "$(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG)" \
17+
-v "$(S)$$PWD:/workdir$(DOCKERMOUNTFLAG)" \
18+
-w $(S)/workdir \
19+
$(BUILD_IMAGE)
20+
21+
.PHONY: all build test push clean container-clean bin-clean version static gofmt govet golint golangci-lint container
922
GOTMP=.gotmp
1023

1124
SHELL = /bin/bash
@@ -14,7 +27,7 @@ GOFILES = $(shell find $(SRC_DIRS) -name "*.go")
1427

1528
BUILD_OS = $(shell go env GOHOSTOS)
1629

17-
BUILD_IMAGE ?= drud/golang-build-container:v1.11
30+
BUILD_IMAGE ?= drud/golang-build-container:v1.11.4.2
1831

1932
BUILD_BASE_DIR ?= $$PWD
2033

@@ -35,6 +48,11 @@ VERSION_LDFLAGS := $(foreach v,$(VERSION_VARIABLES),-X "$(PKG)/pkg/version.$(v)=
3548
LDFLAGS := -extldflags -static $(VERSION_LDFLAGS)
3649
DOCKERMOUNTFLAG := :delegated
3750

51+
# In go 1.11 -mod=vendor is not autodetected; it probably will be in 1.12
52+
# See https://github.com/golang/go/issues/27227
53+
USEMODVENDOR := $(shell if [ -d vendor ]; then echo "-mod=vendor"; fi)
54+
55+
3856
PWD=$(shell pwd)
3957
S =
4058
ifeq ($(BUILD_OS),windows)
@@ -47,143 +65,70 @@ build: $(BUILD_OS)
4765

4866
linux darwin windows: $(GOFILES)
4967
@echo "building $@ from $(SRC_AND_UNDER)"
50-
@$(shell rm -f VERSION.txt)
51-
@$(shell mkdir -p bin/$@ $(GOTMP)/{std/$@,bin,src/$(PKG)})
52-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
53-
-v "$(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG)" \
54-
-v "$(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG)" \
55-
-v "$(S)$$PWD/bin/$@:/go/bin$(DOCKERMOUNTFLAG)" \
56-
-v "$(S)$$PWD/bin/$@:/go/bin/$@$(DOCKERMOUNTFLAG)" \
57-
-v "$(S)$$PWD/$(GOTMP)/std/$@:/usr/local/go/pkg/$@_amd64_static$(DOCKERMOUNTFLAG)" \
58-
-e CGO_ENABLED=0 \
59-
-e GOOS=$@ \
60-
-w $(S)/go/src/$(PKG) \
61-
$(BUILD_IMAGE) \
62-
go install -installsuffix static -ldflags ' $(LDFLAGS) ' $(SRC_AND_UNDER)
68+
@mkdir -p $(GOTMP)/{.cache,pkg,src,bin}
69+
@$(DOCKERBUILDCMD) \
70+
go install $(USEMODVENDOR) -installsuffix static -ldflags ' $(LDFLAGS) ' $(SRC_AND_UNDER)
6371
@$(shell touch $@)
72+
$( shell if [ -d $(GOTMP) ]; then chmod -R u+w $(GOTMP); fi )
6473
@echo $(VERSION) >VERSION.txt
6574

66-
govendor:
67-
@echo -n "Using govendor to check for missing dependencies and unused dependencies: "
68-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
69-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
70-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
71-
-w $(S)/go/src/$(PKG) \
72-
$(BUILD_IMAGE) \
73-
bash -c 'OUT=$$(govendor list +missing +unused); if [ -n "$$OUT" ]; then echo "$$OUT"; exit 1; fi'
74-
7575
gofmt:
7676
@echo "Checking gofmt: "
77-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
78-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
79-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
80-
-w $(S)/go/src/$(PKG) \
81-
$(BUILD_IMAGE) \
77+
@$(DOCKERTESTCMD) \
8278
bash -c 'export OUT=$$(gofmt -l $(SRC_DIRS)) && if [ -n "$$OUT" ]; then echo "These files need gofmt -w: $$OUT"; exit 1; fi'
8379

8480
govet:
8581
@echo "Checking go vet: "
86-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
87-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
88-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
89-
-w $S/go/src/$(PKG) \
90-
$(BUILD_IMAGE) \
82+
@$(DOCKERTESTCMD) \
9183
bash -c 'go vet $(SRC_AND_UNDER)'
9284

9385
golint:
9486
@echo "Checking golint: "
95-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
96-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
97-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
98-
-w $(S)/go/src/$(PKG) \
99-
$(BUILD_IMAGE) \
87+
@$(DOCKERTESTCMD) \
10088
bash -c 'export OUT=$$(golint $(SRC_AND_UNDER)) && if [ -n "$$OUT" ]; then echo "Golint problems discovered: $$OUT"; exit 1; fi'
10189

10290
errcheck:
10391
@echo "Checking errcheck: "
104-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
105-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
106-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
107-
-w $(S)/go/src/$(PKG) \
108-
$(BUILD_IMAGE) \
92+
@$(DOCKERTESTCMD) \
10993
errcheck $(SRC_AND_UNDER)
11094

11195
staticcheck:
11296
@echo "Checking staticcheck: "
113-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
114-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
115-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
116-
-w $(S)/go/src/$(PKG) \
117-
$(BUILD_IMAGE) \
97+
@$(DOCKERTESTCMD) \
11898
staticcheck $(SRC_AND_UNDER)
11999

120-
unused:
121-
@echo "Checking unused variables and functions: "
122-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
123-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
124-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
125-
-w $(S)/go/src/$(PKG) \
126-
$(BUILD_IMAGE) \
127-
unused $(SRC_AND_UNDER)
128-
129-
codecoroner:
130-
@echo "Checking codecoroner for unused functions: "
131-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
132-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
133-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
134-
-w $(S)/go/src/$(PKG) \
135-
$(BUILD_IMAGE) \
136-
bash -c 'OUT=$$(codecoroner -tests -ignore vendor funcs $(SRC_AND_UNDER)); if [ -n "$$OUT" ]; then echo "$$OUT"; exit 1; fi' \
137-
138-
139100
varcheck:
140101
@echo "Checking unused globals and struct members: "
141-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
142-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
143-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
144-
-w $(S)/go/src/$(PKG) \
145-
$(BUILD_IMAGE) \
146-
varcheck $(SRC_AND_UNDER) && structcheck $(SRC_AND_UNDER)
102+
@$(DOCKERTESTCMD) \
103+
bash -c "varcheck $(SRC_AND_UNDER) && structcheck $(SRC_AND_UNDER)"
147104

148105
misspell:
149106
@echo "Checking for misspellings: "
150-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
151-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
152-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
153-
-w $(S)/go/src/$(PKG) \
154-
$(BUILD_IMAGE) \
107+
@$(DOCKERTESTCMD) \
155108
misspell $(SRC_DIRS)
156109

157110
gometalinter:
158111
@echo "gometalinter: "
159-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
160-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
161-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
162-
-w $(S)/go/src/$(PKG) \
163-
$(BUILD_IMAGE) \
112+
@$(DOCKERTESTCMD) \
164113
time gometalinter $(GOMETALINTER_ARGS) $(SRC_AND_UNDER)
165114

166115
golangci-lint:
167116
@echo "golangci-lint: "
168-
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
169-
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
170-
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
171-
-w $(S)/go/src/$(PKG) \
172-
$(BUILD_IMAGE) \
117+
@$(DOCKERTESTCMD) \
173118
time bash -c "golangci-lint run $(GOLANGCI_LINT_ARGS) $(SRC_AND_UNDER)"
174119

175120
version:
176121
@echo VERSION:$(VERSION)
177122

178123
clean: container-clean bin-clean
179-
@go clean -cache || echo "You're not running latest golang locally" # Make sure the local go cache is clean for testing
180124

181125
container-clean:
182126
@if docker image inspect $(DOCKER_REPO):$(VERSION) >/dev/null 2>&1; then docker rmi -f $(DOCKER_REPO):$(VERSION); fi
183127
@rm -rf .container-* .dockerfile* .push-* linux darwin windows container VERSION.txt .docker_image
184128

185129
bin-clean:
186-
$(shell rm -rf $(GOTMP) bin .tmp)
130+
@rm -rf bin
131+
$(shell if [ -d $(GOTMP) ]; then chmod -R u+w $(GOTMP) && rm -rf $(GOTMP); fi )
187132

188133
# print-ANYVAR prints the expanded variable
189134
print-%: ; @echo $* = $($*)

build-tools/makefile_components/base_test_go.mak

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
TESTOS = $(BUILD_OS)
88

99
test: build
10-
@mkdir -p bin/linux
11-
@mkdir -p $(GOTMP)/{src/$(PKG),pkg,bin,std/linux}
1210
@echo "Testing $(SRC_AND_UNDER) with TESTARGS=$(TESTARGS)"
11+
@mkdir -p $(GOTMP)/{.cache,pkg,src,bin}
1312
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
1413
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
1514
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
@@ -18,7 +17,8 @@ test: build
1817
-e CGO_ENABLED=0 \
1918
-w /go/src/$(PKG) \
2019
$(BUILD_IMAGE) \
21-
go test -v -installsuffix static -ldflags '$(LDFLAGS)' $(SRC_AND_UNDER) $(TESTARGS)
20+
go test $(USEMODVENDOR) -v -installsuffix static -ldflags '$(LDFLAGS)' $(SRC_AND_UNDER) $(TESTARGS)
21+
@$(shell chmod -R u+w $(GOTMP))
2222

2323
# test_precompile allows a full compilation of _test.go files, without execution of the tests.
2424
# Setup and teardown in TestMain is still executed though, so this can cost some time.

cmd/ddev_gen_autocomplete/ddev_gen_autocomplete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/drud/ddev/pkg/util"
99
)
1010

11-
var targetDir = "bin"
11+
var targetDir = ".gotmp/bin"
1212

1313
func main() {
1414
if _, err := os.Stat(targetDir); os.IsNotExist(err) {

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ require (
3939
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a
4040
github.com/magiconair/properties v1.8.0 // indirect
4141
github.com/mattn/go-colorable v0.0.9 // indirect
42-
github.com/mattn/go-isatty v0.0.3 // indirect
42+
github.com/mattn/go-isatty v0.0.3
4343
github.com/mattn/go-runewidth v0.0.2 // indirect
4444
github.com/mattn/go-shellwords v1.0.3
4545
github.com/mitchellh/go-homedir v0.0.0-20180523094522-3864e76763d9

vendor/github.com/Azure/go-ansiterm/README.md

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)