1
0
mirror of https://github.com/rancher/cli.git synced 2026-02-05 09:48:36 +01:00

Update build process

Problem:
The cli is using an old go version
It does not use all the validation tools rancher/rancher uses

Solution:
Update to go version 1.12.9
Include goimports for validation
This commit is contained in:
Dan Ramich
2019-08-26 14:55:48 -07:00
committed by Craig Jellick
parent 8c5d6c3630
commit a8000549ed
4 changed files with 18 additions and 27 deletions

View File

@@ -1,8 +1,13 @@
FROM golang:1.9.4
FROM golang:1.12.9
RUN apt-get update && \
apt-get install -y xz-utils zip rsync
RUN go get github.com/rancher/trash
RUN go get golang.org/x/lint/golint
RUN go get -u golang.org/x/lint/golint && \
go get -d golang.org/x/tools/cmd/goimports && \
# This needs to be kept up to date with rancher/types
git -C /go/src/golang.org/x/tools/cmd/goimports checkout -b release-branch.go1.12 origin/release-branch.go1.12 && \
go install golang.org/x/tools/cmd/goimports
RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \
chmod +x /usr/bin/docker
ENV PATH /go/bin:$PATH
@@ -10,7 +15,6 @@ ENV DAPPER_SOURCE /go/src/github.com/rancher/cli
ENV DAPPER_OUTPUT bin build/bin dist
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_ENV TAG REPO GOOS CROSS DRONE_TAG
ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache
WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]

View File

@@ -10,14 +10,6 @@ TARGETS := $(shell ls scripts)
$(TARGETS): .dapper
./.dapper $@
trash: .dapper
./.dapper -m bind trash
trash-keep: .dapper
./.dapper -m bind trash -k
deps: trash
.DEFAULT_GOAL := ci
.PHONY: $(TARGETS)

View File

@@ -5,6 +5,4 @@ cd $(dirname $0)/..
echo Running tests
PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')"
go test -race -cover -tags=test ${PACKAGES}
go test -race -cover -tags=test .././...

View File

@@ -3,17 +3,14 @@ set -e
cd $(dirname $0)/..
echo Running validation
echo Running: go vet
go vet ./...
echo Running: golint
# use go list until golint acts the same as go-1.9 and ignores vendor with ./...
if [ -n "$(golint $(go list ./...) | grep -v 'should have comment.*or be unexported' | tee /dev/stderr)" ]; then
failed=true
fi
test -z "$failed"
echo Running: go fmt
test -z "$(go fmt ./... | tee /dev/stderr)"
echo Running: go vet
test -z "$(go vet ./... 2>&1 | tee /dev/stderr)"
echo Running: golint
test -z "$(go list ./... | grep -v /vendor/ | xargs -L1 golint | grep -v 'or be unexported' | tee /dev/stderr)"
echo Running: goimports
test -z "$(goimports -d $(find . -type f -name '*.go' -not -path "./vendor/*") | tee /dev/stderr)"