Skip to content

Commit d88775a

Browse files
committed
Merge pull request sorintlab#553 from sgotti/simplify_build
*: update go version to go1.11 and simplify build
2 parents 849e28b + 6f45fb8 commit d88775a

File tree

6 files changed

+18
-47
lines changed

6 files changed

+18
-47
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ Session.vim
1212

1313
#
1414
bin/
15-
/gopath/
1615
/release/

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
language: go
22

33
go:
4-
- 1.9.x
54
- 1.10.x
5+
- 1.11.x
6+
7+
go_import_path: github.com/sorintlab/stolon
68

79
env:
810
- TARGET=amd64

build

+5-36
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,8 @@ fi
3333
ORG_PATH="github.com/sorintlab"
3434
REPO_PATH="${ORG_PATH}/stolon"
3535

36-
# Hack to be sure that:
37-
# * all the dependencies are vendored
38-
# * if cloned as another repo name it will compile anyway
39-
export GOPATH=${PWD}/gopath
40-
41-
rm -f $GOPATH/src/${REPO_PATH}
42-
mkdir -p $GOPATH/src/${ORG_PATH}
43-
ln -s ${PWD} $GOPATH/src/${REPO_PATH}
44-
4536
mkdir -p ${BINDIR}
4637

47-
export GO15VENDOREXPERIMENT=1
48-
4938
VERSION=${STOLON_VERSION:-$(${BASEDIR}/scripts/git-version.sh)}
5039
LD_FLAGS="-s -X ${REPO_PATH}/cmd.Version=$VERSION"
5140

@@ -72,32 +61,12 @@ if [ -w ${go_root_dir}/pkg ]; then
7261
use_go_install=1
7362
fi
7463

75-
if [ -z $use_go_install ]; then
76-
echo "Cannot find/create a go stdlib created with cgo disabled for the go release installed at ${go_root_dir} since ${go_root_dir}/pkg is not writable by `whoami`"
77-
echo "The build will use \"go build\" instead of \"go install\". This is slower since every run will need to rebuild all the needed packages."
78-
echo "To speed up the build you should make ${go_root_dir}/pkg writable for `whoami` for at least the first build"
79-
echo "or manually rebuild stdlib executing the command 'CGO_ENABLED=0 go install -a -installsuffix cgo std' from a user with write access to ${go_root_dir}/pkg"
80-
81-
for cmd in sentinel proxy; do
82-
CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "$LD_FLAGS" -o ${BINDIR}/stolon-${cmd} ${REPO_PATH}/cmd/${cmd}
83-
done
84-
CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "$LD_FLAGS" -o ${BINDIR}/stolonctl ${REPO_PATH}/cmd/stolonctl
85-
else
86-
for cmd in sentinel proxy; do
87-
CGO_ENABLED=0 go install -installsuffix cgo -ldflags "$LD_FLAGS" ${REPO_PATH}/cmd/${cmd}
88-
rm -f ${BINDIR}/stolon-${cmd}
89-
cp ${GOPATH}/bin/${cmd} ${BINDIR}/stolon-${cmd}
90-
done
91-
CGO_ENABLED=0 go install -installsuffix cgo -ldflags "$LD_FLAGS" ${REPO_PATH}/cmd/stolonctl
92-
rm -f ${BINDIR}/stolonctl
93-
cp ${GOPATH}/bin/stolonctl ${BINDIR}/
94-
fi
64+
for cmd in sentinel proxy; do
65+
CGO_ENABLED=0 go build -installsuffix cgo -ldflags "$LD_FLAGS" -o ${BINDIR}/stolon-${cmd} ${REPO_PATH}/cmd/${cmd}
66+
done
67+
CGO_ENABLED=0 go build -installsuffix cgo -ldflags "$LD_FLAGS" -o ${BINDIR}/stolonctl ${REPO_PATH}/cmd/stolonctl
9568

96-
# stolon-keeper cannot be statically built since it needs to get its current
97-
# running user and this is not available with cgo disabled
98-
go install -ldflags "$LD_FLAGS" ${REPO_PATH}/cmd/keeper
99-
rm -f ${BINDIR}/stolon-keeper
100-
cp ${GOPATH}/bin/keeper ${BINDIR}/stolon-keeper
69+
go build -ldflags "$LD_FLAGS" -o ${BINDIR}/stolon-keeper ${REPO_PATH}/cmd/keeper
10170

10271
# Copy binaries to Dockerfile image directories
10372
declare -a DOCKERFILE_PATHS

scripts/semaphore-k8s.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ touch $HOME/.kube/config
2727
export KUBECONFIG=$HOME/.kube/config
2828
sudo -E minikube start --vm-driver=none
2929

30-
# Precompile stdlib with cgo disable to speedup builds
31-
sudo -E CGO_ENABLED=0 go install -a -installsuffix cgo std
30+
# Fix build to work with the right import path also when building github forked repositories
31+
if [[ ! -e ~/workspace/src/github.com/sorintlab/stolon ]]; then
32+
mkdir -p ~/workspace/src/github.com/sorintlab
33+
ln -s /home/runner/stolon ~/workspace/src/github.com/sorintlab/stolon
34+
fi
3235

3336
./build
3437

scripts/semaphore.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-
3131
sudo apt-get update
3232
sudo apt-get -y install postgresql-9.5 postgresql-9.6 postgresql-10 postgresql-11
3333

34-
# Precompile stdlib with cgo disable to speedup builds
35-
sudo -E CGO_ENABLED=0 go install -a -installsuffix cgo std
34+
# Fix build to work with the right import path also when building github forked repositories
35+
if [[ ! -e ~/workspace/src/github.com/sorintlab/stolon ]]; then
36+
mkdir -p ~/workspace/src/github.com/sorintlab
37+
ln -s /home/runner/stolon ~/workspace/src/github.com/sorintlab/stolon
38+
fi
3639

3740
# Run tests
3841
export ETCD_BIN="${PWD}/etcd/etcd-v3.2.11-linux-amd64/etcd"

test

-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ REPO_PATH="${ORG_PATH}/stolon"
2323

2424
./build
2525

26-
# Hack to be sure that:
27-
# * all the dependencies are vendored
28-
# * if cloned as another repo name it will compile anyway
29-
export GOPATH=${PWD}/gopath
30-
3126
# test all packages excluding integration tests
3227
IGNORE_PKGS="(vendor/|tests/integration)"
3328
PACKAGES=$(find . -name \*_test.go | while read -r a; do dirname "$a"; done | sort | uniq | grep -vE "$IGNORE_PKGS" | sed "s|\./||g")

0 commit comments

Comments
 (0)