Skip to content

Commit

Permalink
Pin and install go from go.mod version (#352)
Browse files Browse the repository at this point in the history
This include a super low tech mechanism not docker multistage either
dockerized golang, it just download a golang tarball and install it under
repo.

Signed-off-by: Quique Llorente <[email protected]>
  • Loading branch information
qinqon authored and kubevirt-bot committed Jan 28, 2020
1 parent 2cf2d31 commit f6b75ca
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 31 deletions.
45 changes: 28 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export KUBEVIRT_PROVIDER ?= k8s-1.15.1
export KUBEVIRT_NUM_NODES ?= 1
export KUBEVIRT_NUM_SECONDARY_NICS ?= 2

export GOFLAGS=-mod=vendor
export GO111MODULE=on

e2e_test_args = -singleNamespace=true -test.v -test.timeout=40m -ginkgo.v -ginkgo.slowSpecThreshold=60 $(E2E_TEST_ARGS)
ifeq ($(findstring k8s,$(KUBEVIRT_PROVIDER)),k8s)
Expand All @@ -26,10 +24,20 @@ else
e2e_test_args += -primaryNic ens3 -firstSecondaryNic ens8 -secondSecondaryNic ens9
endif

BIN_DIR = build/_output/bin/
GINKGO ?= $(BIN_DIR)/ginkgo
OPERATOR_SDK ?= $(BIN_DIR)/operator-sdk
GITHUB_RELEASE ?= $(BIN_DIR)/github-release
BIN_DIR = $(CURDIR)/build/_output/bin/

export GOFLAGS=-mod=vendor
export GO111MODULE=on
export GOROOT=$(BIN_DIR)/go/
export GOBIN=$(GOROOT)/bin/
export PATH := $(GOROOT)/bin:$(PATH)

GINKGO ?= $(GOBIN)/ginkgo
OPERATOR_SDK ?= $(GOBIN)/operator-sdk
GITHUB_RELEASE ?= $(GOBIN)/github-release
GOFMT := $(GOBIN)/gofmt
GO := $(GOBIN)/go

LOCAL_REGISTRY ?= registry:5000

CLUSTER_DIR ?= kubevirtci/cluster-up/
Expand All @@ -50,26 +58,29 @@ all: check handler

check: format vet whitespace-check

format: whitespace-format
gofmt -d cmd/ pkg/
format: whitespace-format $(GO)
$(GOFMT) -d cmd/ pkg/

vet:
go vet ./cmd/... ./pkg/...
vet: $(GO)
$(GO) vet ./cmd/... ./pkg/...

whitespace-format:
hack/whitespace.sh format

whitespace-check:
hack/whitespace.sh check

$(GINKGO): go.mod
GOBIN=$$(pwd)/$(BIN_DIR) go install ./vendor/github.com/onsi/ginkgo/ginkgo
$(GO):
hack/install-go.sh $(BIN_DIR)

$(GINKGO): go.mod $(GO)
$(GO) install ./vendor/github.com/onsi/ginkgo/ginkgo

$(OPERATOR_SDK): go.mod
GOBIN=$$(pwd)/$(BIN_DIR) go install ./vendor/github.com/operator-framework/operator-sdk/cmd/operator-sdk
$(OPERATOR_SDK): go.mod $(GO)
$(GO) install ./vendor/github.com/operator-framework/operator-sdk/cmd/operator-sdk

$(GITHUB_RELEASE): go.mod
GOBIN=$$(pwd)/$(BIN_DIR) go install ./vendor/github.com/aktau/github-release
$(GITHUB_RELEASE): go.mod $(GO)
$(GO) install ./vendor/github.com/aktau/github-release


gen-k8s: $(OPERATOR_SDK)
Expand Down Expand Up @@ -171,7 +182,7 @@ release: $(versioned_operator_manifest) push-handler $(description) $(GITHUB_REL
$(shell find deploy/crds/ deploy/openshift -type f)

tools-vendoring:
./hack/vendor-tools.sh $$(pwd)/$(BIN_DIR) $$(pwd)/tools.go
./hack/vendor-tools.sh $(BIN_DIR) $$(pwd)/tools.go

.PHONY: \
all \
Expand Down
15 changes: 2 additions & 13 deletions automation/check-patch.setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,11 @@
tmp_dir=/tmp/knmstate/

rm -rf $tmp_dir

echo 'Setup Go paths'
export GOROOT=$tmp_dir/go/root
mkdir -p $GOROOT
export PATH=${GOROOT}/bin:${PATH}

export GIMME_GO_VERSION=$(grep "^go " go.mod |awk '{print $2}')
echo "Install Go $GIMME_GO_VERSION"
gimme_dir=$tmp_dir/go/gimme
mkdir -p $gimme_dir
curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | HOME=${gimme_dir} bash >> ${gimme_dir}/gimme.sh
source $gimme_dir/gimme.sh

mkdir -p $tmp_dir

export TMP_PROJECT_PATH=$tmp_dir/kubernetes-nmstate
export ARTIFACTS=${ARTIFACTS-$tmp_dir/artifacts}
mkdir -p $ARTIFACTS

rsync -rt --links --filter=':- .gitignore' $(pwd)/ $TMP_PROJECT_PATH

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nmstate/kubernetes-nmstate

go 1.12
go 1.12.15

require (
github.com/aktau/github-release v0.7.2
Expand Down
10 changes: 10 additions & 0 deletions hack/install-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -xe

destination=$1
version=$(grep "^go " go.mod |awk '{print $2}')
tarball=go$version.linux-amd64.tar.gz
url=https://dl.google.com/go/

mkdir -p $destination
curl -L $url/$tarball -o $destination/$tarball
tar -xvf $destination/$tarball -C $destination

0 comments on commit f6b75ca

Please sign in to comment.