mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-09-20 09:01:15 +00:00
Support GOPATH mode build/test for its transitional situation
This commit is contained in:
committed by
Tomofumi Hayashi
parent
ac21a96804
commit
d134ac8485
24
build
24
build
@@ -20,9 +20,29 @@ set -e
|
|||||||
DATE=$(date --iso-8601=seconds)
|
DATE=$(date --iso-8601=seconds)
|
||||||
COMMIT=$(git rev-parse --verify HEAD)
|
COMMIT=$(git rev-parse --verify HEAD)
|
||||||
LDFLAGS="-X main.version=${VERSION:-master} -X main.commit=${COMMIT} -X main.date=${DATE}"
|
LDFLAGS="-X main.version=${VERSION:-master} -X main.commit=${COMMIT} -X main.date=${DATE}"
|
||||||
|
|
||||||
export GO111MODULE=on
|
|
||||||
export CGO_ENABLED=0
|
export CGO_ENABLED=0
|
||||||
|
|
||||||
|
# this if... will be removed when gomodules goes default
|
||||||
|
if [ $GO111MODULE == "off" ]; then
|
||||||
|
echo "Building plugin without go module"
|
||||||
|
echo "Warning: this will be deprecated in near future so please use go modules!"
|
||||||
|
|
||||||
|
ORG_PATH="github.com/intel"
|
||||||
|
REPO_PATH="${ORG_PATH}/multus-cni"
|
||||||
|
|
||||||
|
if [ ! -h gopath/src/${REPO_PATH} ]; then
|
||||||
|
mkdir -p gopath/src/${ORG_PATH}
|
||||||
|
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
|
||||||
|
fi
|
||||||
|
|
||||||
|
export GO15VENDOREXPERIMENT=1
|
||||||
|
export GOBIN=${PWD}/bin
|
||||||
|
export GOPATH=${PWD}/gopath
|
||||||
|
go install -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/multus
|
||||||
|
else
|
||||||
|
# build with go modules
|
||||||
|
export GO111MODULE=on
|
||||||
|
|
||||||
echo "Building plugins"
|
echo "Building plugins"
|
||||||
go build -o ${DEST_DIR}/multus -tags no_openssl -ldflags "${LDFLAGS}" "$@" ./multus
|
go build -o ${DEST_DIR}/multus -tags no_openssl -ldflags "${LDFLAGS}" "$@" ./multus
|
||||||
|
fi
|
||||||
|
20
test.sh
20
test.sh
@@ -1,7 +1,23 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
export GO111MODULE=on
|
# this if... will be removed when gomodules goes default
|
||||||
|
if [ $GO111MODULE == "off" ]; then
|
||||||
|
echo "Warning: this will be deprecated in near future so please use go modules!"
|
||||||
|
|
||||||
|
ORG_PATH="github.com/intel"
|
||||||
|
REPO_PATH="${ORG_PATH}/multus-cni"
|
||||||
|
|
||||||
|
if [ ! -h gopath/src/${REPO_PATH} ]; then
|
||||||
|
mkdir -p gopath/src/${ORG_PATH}
|
||||||
|
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
|
||||||
|
fi
|
||||||
|
|
||||||
|
export GO15VENDOREXPERIMENT=1
|
||||||
|
export GOBIN=${PWD}/bin
|
||||||
|
export GOPATH=${PWD}/gopath
|
||||||
|
bash -c "umask 0; cd ${GOPATH}/src/${REPO_PATH}; PATH=${GOROOT}/bin:$(pwd)/bin:${PATH} go test -v -covermode=count -coverprofile=coverage.out ./..."
|
||||||
|
else
|
||||||
|
# test with go modules
|
||||||
bash -c "umask 0; go test -v -covermode=count -coverprofile=coverage.out ./..."
|
bash -c "umask 0; go test -v -covermode=count -coverprofile=coverage.out ./..."
|
||||||
|
fi
|
||||||
|
Reference in New Issue
Block a user