Use glide for dependencies

Use the new tools/test-setup.sh for bootstrapping our
dev/test environment

Change-Id: Ic5c9d89d4a6d89f8a4b138fc9c814452fc6ff104
This commit is contained in:
Dean Troyer 2016-12-22 09:58:30 -06:00
parent 9b52de086d
commit 34a783684a
5 changed files with 117 additions and 18 deletions

View File

@ -13,30 +13,23 @@ GOPATH_DEFAULT := $(PWD)/.go
export GOPATH ?= $(GOPATH_DEFAULT)
DEST := $(GOPATH)/src/$(GIT_HOST)/openstack/$(BASE_DIR).git
env:
@echo "PWD: $(PWD)"
@echo "BASE_DIR: $(BASE_DIR)"
@echo "GOPATH: $(GOPATH)"
@echo "DEST: $(DEST)"
# CTI targets
work: $(GOPATH) $(DEST)
depend: work
cd $(DEST) && glide install
$(GOPATH):
mkdir -p $(GOPATH)
test: depend
cd $(DEST) && go test -tags=unit ./...
$(DEST): $(GOPATH)
mkdir -p $(shell dirname $(DEST))
ln -s $(PWD) $(DEST)
get: work
cd $(DEST); go get -tags=unit -t ./...
test: get
cd $(DEST); go test -tags=unit ./...
functional:
@echo "$@ not yet implemented"
fmt: work
cd $(DEST) && go fmt ./...
lint:
@echo "$@ not yet implemented"
cover:
@echo "$@ not yet implemented"
@ -49,6 +42,28 @@ relnotes:
translation:
@echo "$@ not yet implemented"
# Do the work here
# Set up the development environment
env:
@echo "PWD: $(PWD)"
@echo "BASE_DIR: $(BASE_DIR)"
@echo "GOPATH: $(GOPATH)"
@echo "DEST: $(DEST)"
# Get our dev/test dependencies in place
bootstrap:
tools/test-setup.sh
work: $(GOPATH) $(DEST)
$(GOPATH):
mkdir -p $(GOPATH)
$(DEST): $(GOPATH)
mkdir -p $(shell dirname $(DEST))
ln -s $(PWD) $(DEST)
.bindep:
virtualenv .bindep
.bindep/bin/pip install bindep
@ -61,8 +76,15 @@ install-distro-packages:
clean:
rm -rf .bindep
realclean: clean
rm -rf vendor
if [ "$(GOPATH)" = "$(GOPATH_DEFAULT)" ]; then \
rm -rf $(GOPATH); \
fi
.PHONY: bindep clean
shell: work
cd $(DEST) && $(SHELL) -i
.PHONY: bindep clean cover depend docs fmt functional lint realclean \
relnotes test translation

6
glide.lock generated Normal file
View File

@ -0,0 +1,6 @@
hash: 29383d95fa712061eaaec8c9f3af33f4a29700e0d385f4f9f454f1ce27b05fec
updated: 2016-12-21T14:53:45.41134367-06:00
imports:
- name: github.com/fullsailor/pkcs7
version: cedaa6c8ea14493515fcf950eabba5eb1530c349
devImports: []

3
glide.yaml Normal file
View File

@ -0,0 +1,3 @@
package: git.openstack.org/openstack/golang-client.git
import:
- package: github.com/fullsailor/pkcs7

View File

@ -7,6 +7,22 @@ function is_fedora {
[ -f /usr/bin/yum ] && cat /etc/*release | grep -q -e "Fedora"
}
PACKAGES=""
if ! which virtualenv; then
PACKAGES="$PACKAGES virtualenv"
fi
if ! which make; then
PACKAGES="$PACKAGES make"
fi
if [[ -n $PACKAGES ]]; then
sudo apt-get -q --assume-yes install virtualenv
fi
# Check for bindep
if ! which bindep; then
make bindep
fi
PACKAGES=$(make bindep || true)
# inspired from project-config install-distro-packages.sh

52
tools/test-setup.sh Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash -xe
# test-setup.sh - Install required stuffs
# Used in both CI jobs and locally
#
# Install the following tools:
# * glide
# Get OS
case $(uname -s) in
Darwin)
OS=darwin
;;
Linux)
if LSB_RELEASE=$(which lsb_release); then
OS=$($LSB_RELEASE -s -c)
else
# No lsb-release, trya hack or two
if which dpkg 1>/dev/null; then
OS=debian
elif which yum 1>/dev/null || which dnf 1>/dev/null; then
OS=redhat
else
echo "Linux distro not yet supported"
exit 1
fi
fi
;;
*)
echo "Unsupported OS"
exit 1
;;
esac
case $OS in
darwin)
if which brew 1>/dev/null; then
brew install glide
else
echo "Homebrew not found, install Glide from source?"
fi
;;
xenial)
APT_GET="DEBIAN_FRONTEND=noninteractive \
apt-get -q --option "Dpkg::Options::=--force-confold" \
--assume-yes"
if ! which add-apt-repository 1>/dev/null; then
sudo $APT_GET install software-properties-common
fi
sudo add-apt-repository --yes ppa:masterminds/glide && sudo apt-get update
sudo $APT_GET install glide
;;
esac