Skip to content

Commit

Permalink
Merge pull request containernetworking#144 from squeed/build-fixes
Browse files Browse the repository at this point in the history
build: some small improvements; bump to go1.10
  • Loading branch information
dcbw authored Apr 25, 2018
2 parents adba9ec + aade7b9 commit 1df359a
Show file tree
Hide file tree
Showing 27 changed files with 35 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ _testmain.go
bin/
gopath/
.vagrant

/release-*
12 changes: 3 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
set -e
cd $(dirname "$0")

if [ "$(uname)" == "Darwin" ]; then
export GOOS=linux
export GOOS="${GOOS:-linux}"
fi

ORG_PATH="github.com/containernetworking"
Expand All @@ -13,7 +14,6 @@ if [ ! -h gopath/src/${REPO_PATH} ]; then
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
fi

export GO15VENDOREXPERIMENT=1
export GOPATH=${PWD}/gopath
export GO="${GO:-go}"

Expand All @@ -25,12 +25,6 @@ for d in $PLUGINS; do
if [ -d "$d" ]; then
plugin="$(basename "$d")"
echo " $plugin"
# use go install so we don't duplicate work
if [ -n "$FASTBUILD" ]
then
GOBIN=${PWD}/bin $GO install -pkgdir $GOPATH/pkg "$@" $REPO_PATH/$d
else
$GO build -o "${PWD}/bin/$plugin" -pkgdir "$GOPATH/pkg" "$@" "$REPO_PATH/$d"
fi
$GO build -o "${PWD}/bin/$plugin" "$@" "$REPO_PATH"/$d
fi
done
2 changes: 1 addition & 1 deletion integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

func TestIntegration(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Integration Suite")
RunSpecs(t, "integration")
}

var echoServerBinaryPath string
Expand Down
2 changes: 1 addition & 1 deletion pkg/ip/ip_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestIp(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Ip Suite")
RunSpecs(t, "pkg/ip")
}
2 changes: 1 addition & 1 deletion pkg/ipam/ipam_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestIpam(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Ipam Suite")
RunSpecs(t, "pkg/ipam")
}
2 changes: 1 addition & 1 deletion pkg/ns/ns_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ func TestNs(t *testing.T) {
runtime.LockOSThread()

RegisterFailHandler(Fail)
RunSpecs(t, "pkg/ns Suite")
RunSpecs(t, "pkg/ns")
}
2 changes: 1 addition & 1 deletion pkg/testutils/echosvr/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import (

func TestEchosvr(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Testutils Echosvr Suite")
RunSpecs(t, "pkg/testutils/echosvr")
}
2 changes: 1 addition & 1 deletion pkg/utils/hwaddr/hwaddr_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestHwaddr(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Hwaddr Suite")
RunSpecs(t, "pkg/utils/hwaddr")
}
2 changes: 1 addition & 1 deletion pkg/utils/utils_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestUtils(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Utils Suite")
RunSpecs(t, "pkg/utils")
}
2 changes: 1 addition & 1 deletion plugins/ipam/dhcp/dhcp_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestDHCP(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "DHCP Suite")
RunSpecs(t, "plugins/ipam/dhcp")
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestAllocator(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Allocator Suite")
RunSpecs(t, "plugins/ipam/host-local/backend/allocator")
}
2 changes: 1 addition & 1 deletion plugins/ipam/host-local/backend/disk/disk_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestLock(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Disk Suite")
RunSpecs(t, "plugins/ipam/host-local/backend/disk")
}
2 changes: 1 addition & 1 deletion plugins/ipam/host-local/host_local_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestHostLocal(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "HostLocal Suite")
RunSpecs(t, "plugins/ipam/host-local")
}
2 changes: 1 addition & 1 deletion plugins/main/bridge/bridge_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestBridge(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "bridge Suite")
RunSpecs(t, "plugins/main/bridge")
}
2 changes: 1 addition & 1 deletion plugins/main/host-device/host-device_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestVlan(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "host-device Suite")
RunSpecs(t, "plugins/main/host-device")
}
2 changes: 1 addition & 1 deletion plugins/main/ipvlan/ipvlan_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestIpvlan(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "ipvlan Suite")
RunSpecs(t, "plugins/main/ipvlan")
}
2 changes: 1 addition & 1 deletion plugins/main/loopback/loopback_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var pathToLoPlugin string

func TestLoopback(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Loopback Suite")
RunSpecs(t, "plugins/main/loopback")
}

var _ = BeforeSuite(func() {
Expand Down
2 changes: 1 addition & 1 deletion plugins/main/macvlan/macvlan_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestMacvlan(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "macvlan Suite")
RunSpecs(t, "plugins/main/macvlan")
}
2 changes: 1 addition & 1 deletion plugins/main/ptp/ptp_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestPtp(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "ptp Suite")
RunSpecs(t, "plugins/main/ptp")
}
2 changes: 1 addition & 1 deletion plugins/main/vlan/vlan_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestVlan(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "vlan Suite")
RunSpecs(t, "plugins/main/vlan")
}
2 changes: 1 addition & 1 deletion plugins/meta/bandwidth/bandwidth_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

func TestTBF(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "bandwidth suite")
RunSpecs(t, "plugins/meta/bandwidth")
}

var echoServerBinaryPath string
Expand Down
2 changes: 1 addition & 1 deletion plugins/meta/flannel/flannel_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ import (

func TestFlannel(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Flannel Suite")
RunSpecs(t, "plugins/meta/flannel")
}
2 changes: 1 addition & 1 deletion plugins/meta/portmap/portmap_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestPortmap(t *testing.T) {
rand.Seed(config.GinkgoConfig.RandomSeed)

RegisterFailHandler(Fail)
RunSpecs(t, "portmap Suite")
RunSpecs(t, "plugins/meta/portmap")
}

var echoServerBinaryPath string
Expand Down
2 changes: 1 addition & 1 deletion plugins/meta/tuning/tuning_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import (

func TestTuning(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "tuning Suite")
RunSpecs(t, "plugins/meta/tuning")
}
2 changes: 1 addition & 1 deletion plugins/sample/sample_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ import (

func TestSample(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "sample suite")
RunSpecs(t, "plugins/sample")
}
10 changes: 4 additions & 6 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@
set -xe

SRC_DIR="${SRC_DIR:-$PWD}"
BUILDFLAGS="-a --ldflags '-extldflags \"-static\"'"

TAG=$(git describe --tags --dirty)
RELEASE_DIR=release-${TAG}

BUILDFLAGS="-ldflags '-extldflags -static -X main._buildVersion=${TAG}'"

OUTPUT_DIR=bin

# Always clean first
rm -Rf ${SRC_DIR}/${RELEASE_DIR}
mkdir -p ${SRC_DIR}/${RELEASE_DIR}
mkdir -p ${OUTPUT_DIR}

docker run -i -v ${SRC_DIR}:/opt/src --rm golang:1.9-alpine \
docker run -ti -v ${SRC_DIR}:/go/src/github.com/containernetworking/plugins --rm golang:1.10-alpine \
/bin/sh -xe -c "\
apk --no-cache add bash tar;
cd /opt/src; umask 0022;
cd /go/src/github.com/containernetworking/plugins; umask 0022;
for arch in amd64 arm arm64 ppc64le s390x; do \
rm -f ${OUTPUT_DIR}/*; \
CGO_ENABLED=0 GOARCH=\$arch ./build.sh ${BUILDFLAGS}; \
for format in tgz; do \
FILENAME=cni-plugins-\$arch-${TAG}.\$format; \
FILEPATH=${RELEASE_DIR}/\$FILENAME; \
tar -C ${OUTPUT_DIR} --owner=0 --group=0 -caf \$FILEPATH .; \
if [ \"\$arch\" == \"amd64\" ]; then \
cp \$FILEPATH ${RELEASE_DIR}/cni-${TAG}.\$format; \
fi; \
done; \
done;
cd ${RELEASE_DIR};
Expand Down
11 changes: 3 additions & 8 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,22 @@ source ./build.sh

echo "Running tests"

# test everything that's not in vendor
pushd "$GOPATH/src/$REPO_PATH" >/dev/null
ALL_PKGS="$(go list ./... | grep -v vendor | xargs echo)"
popd >/dev/null

GINKGO_FLAGS="-p --randomizeAllSpecs --randomizeSuites --failOnPending --progress"

# user has not provided PKG override
if [ -z "$PKG" ]; then
GINKGO_FLAGS="$GINKGO_FLAGS -r ."
LINT_TARGETS="$ALL_PKGS"
LINT_TARGETS="./..."

# user has provided PKG override
else
GINKGO_FLAGS="$GINKGO_FLAGS $PKG"
LINT_TARGETS="$PKG"
fi

cd "$GOPATH/src/$REPO_PATH"
sudo -E bash -c "umask 0; PATH=${GOROOT}/bin:$(pwd)/bin:${PATH} ginkgo ${GINKGO_FLAGS}"
sudo -E bash -c "umask 0; cd ${GOPATH}/src/${REPO_PATH}; PATH=${GOROOT}/bin:$(pwd)/bin:${PATH} ginkgo ${GINKGO_FLAGS}"

cd ${GOPATH}/src/${REPO_PATH};
echo "Checking gofmt..."
fmtRes=$(go fmt $LINT_TARGETS)
if [ -n "${fmtRes}" ]; then
Expand Down

0 comments on commit 1df359a

Please sign in to comment.