|
1 | | -# If DEIS_REGISTRY is not set, try to populate it from legacy DEV_REGISTRY |
2 | | -DEIS_REGISTRY ?= $(DEV_REGISTRY) |
3 | | -IMAGE_PREFIX ?= deis |
4 | | -COMPONENT ?= workflow |
5 | | -VERSION ?= git-$(shell git rev-parse --short HEAD) |
6 | | -IMAGE = $(DEIS_REGISTRY)$(IMAGE_PREFIX)/$(COMPONENT):$(VERSION) |
7 | | -SHELL_SCRIPTS = $(wildcard rootfs/bin/*) $(shell find "rootfs" -name '*.sh') $(wildcard _scripts/*.sh) |
8 | | - |
9 | | -# Get the component informtation to a tmp location and get replica count |
10 | | -$(shell kubectl get rc deis-$(COMPONENT) --namespace deis -o yaml > /tmp/deis-$(COMPONENT)) |
11 | | -DESIRED_REPLICAS=$(shell kubectl get -o template rc/deis-$(COMPONENT) --template={{.status.replicas}} --namespace deis) |
12 | | - |
13 | | -info: |
14 | | - @echo "Build tag: ${VERSION}" |
15 | | - @echo "Registry: ${DEIS_REGISTRY}" |
16 | | - @echo "Image: ${IMAGE}" |
17 | | - |
18 | | -check-docker: |
19 | | - @if [ -z $$(which docker) ]; then \ |
20 | | - echo "Missing \`docker\` client which is required for development"; \ |
21 | | - exit 2; \ |
22 | | - fi |
23 | | - |
24 | | -build: docker-build |
25 | | - |
26 | | -docker-build: check-docker |
27 | | - docker build --rm -t $(IMAGE) rootfs |
28 | | - |
29 | | -docker-push: update-manifests |
30 | | - docker push ${IMAGE} |
31 | | - |
32 | | -kube-delete: |
33 | | - -kubectl delete service deis-workflow |
34 | | - -kubectl delete rc deis-workflow |
35 | | - |
36 | | -kube-delete-database: |
37 | | - -kubectl delete service deis-database |
38 | | - -kubectl delete rc deis-database |
39 | | - |
40 | | -kube-delete-all: kube-delete kube-delete-database |
41 | | - |
42 | | -kube-create: update-manifests |
43 | | - kubectl create -f manifests/deis-workflow-service.yml |
44 | | - kubectl create -f manifests/deis-workflow-rc.tmp.yml |
45 | | - |
46 | | -kube-create-database: |
47 | | - kubectl create -f manifests/deis-database-rc.yml |
48 | | - kubectl create -f manifests/deis-database-service.yml |
49 | | - |
50 | | -kube-create-all: kube-create-database kube-create |
51 | | - |
52 | | -kube-update: update-manifests |
53 | | - kubectl delete -f manifests/deis-workflow-rc.tmp.yml |
54 | | - kubectl create -f manifests/deis-workflow-rc.tmp.yml |
55 | | - |
56 | | -update-manifests: |
57 | | - sed 's#\(image:\) .*#\1 $(IMAGE)#' manifests/deis-workflow-rc.yml \ |
58 | | - > manifests/deis-workflow-rc.tmp.yml |
59 | | - |
60 | | -deploy: docker-build docker-push |
61 | | - sed 's#\(image:\) .*#\1 $(IMAGE)#' /tmp/deis-$(COMPONENT) | kubectl apply --validate=true -f - |
62 | | - kubectl scale rc deis-workflow --replicas 0 --namespace deis |
63 | | - kubectl scale rc deis-workflow --replicas $(DESIRED_REPLICAS) --namespace deis |
64 | | - |
65 | | -clean: check-docker |
66 | | - docker rmi $(IMAGE) |
67 | | - |
68 | | -commit-hook: |
69 | | - cp contrib/util/commit-msg .git/hooks/commit-msg |
70 | | - |
71 | | -full-clean: check-docker |
72 | | - docker images -q $(IMAGE_PREFIX)$(COMPONENT) | xargs docker rmi -f |
73 | | - |
74 | | -postgres: |
75 | | - docker start postgres || docker run --restart="always" -d -p 5432:5432 --name postgres postgres:9.3 |
76 | | - docker exec postgres createdb -U postgres deis 2>/dev/null || true |
77 | | - @echo "To use postgres for local development:" |
78 | | - @echo " export PGHOST=`docker-machine ip $$(docker-machine active) 2>/dev/null || echo 127.0.0.1`" |
79 | | - @echo " export PGPORT=5432" |
80 | | - @echo " export PGUSER=postgres" |
81 | | - |
82 | | -setup-venv: |
83 | | - @if [ ! -d venv ]; then virtualenv venv; fi |
84 | | - venv/bin/pip install --disable-pip-version-check -q -r rootfs/requirements.txt -r rootfs/dev_requirements.txt |
85 | | - |
86 | | -test: test-style test-check test-unit test-functional |
87 | | - |
88 | | -test-check: |
89 | | - cd rootfs && python manage.py check |
| 1 | +export GO15VENDOREXPERIMENT=1 |
| 2 | + |
| 3 | +# the filepath to this repository, relative to $GOPATH/src |
| 4 | +repo_path = github.com/deis/workflow/client |
| 5 | + |
| 6 | +HOST_OS := $(shell uname) |
| 7 | +ifeq ($(HOST_OS),Darwin) |
| 8 | + GOOS=darwin |
| 9 | +else |
| 10 | + GOOS=linux |
| 11 | +endif |
| 12 | + |
| 13 | +DEV_ENV_IMAGE := quay.io/deis/go-dev:0.9.0 |
| 14 | +DEV_ENV_WORK_DIR := /go/src/${repo_path} |
| 15 | +DEV_ENV_PREFIX := docker run --rm -e GO15VENDOREXPERIMENT=1 -e CGO_ENABLED=0 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} |
| 16 | +DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE} |
| 17 | +DIST_DIR := _dist |
| 18 | + |
| 19 | +GO_FILES = $(wildcard *.go) |
| 20 | +GO_LDFLAGS = -ldflags "-s -X ${repo_path}/version.BuildVersion=${VERSION}" |
| 21 | +GO_PACKAGES = cmd controller/api controller/client $(wildcard controller/models/*) parser $(wildcard pkg/*) |
| 22 | +GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES)) |
| 23 | +GOFMT = gofmt -e -l -s |
| 24 | +GOTEST = go test --cover --race -v |
| 25 | + |
| 26 | +VERSION ?= $(shell git rev-parse --short HEAD) |
| 27 | + |
| 28 | +define check-static-binary |
| 29 | + if file $(1) | egrep -q "(statically linked|Mach-O)"; then \ |
| 30 | + echo -n ""; \ |
| 31 | + else \ |
| 32 | + echo "The binary file $(1) is not statically linked. Build canceled"; \ |
| 33 | + exit 1; \ |
| 34 | + fi |
| 35 | +endef |
| 36 | + |
| 37 | +prep-bintray-json: |
| 38 | +# TRAVIS_TAG is set to the tag name if the build is a tag |
| 39 | +ifdef TRAVIS_TAG |
| 40 | + @jq '.version.name |= "$(VERSION)"' _scripts/ci/bintray-template.json | \ |
| 41 | + jq '.package.repo |= "deis"' > _scripts/ci/bintray-ci.json |
| 42 | +else |
| 43 | + @jq '.version.name |= "$(VERSION)"' _scripts/ci/bintray-template.json \ |
| 44 | + > _scripts/ci/bintray-ci.json |
| 45 | +endif |
| 46 | + |
| 47 | +bootstrap: |
| 48 | + ${DEV_ENV_CMD} glide install |
| 49 | + |
| 50 | +glideup: |
| 51 | + ${DEV_ENV_CMD} glide up |
| 52 | + |
| 53 | +build: binary-build |
| 54 | + @$(call check-static-binary,deis) |
| 55 | + |
| 56 | +build-all: |
| 57 | + ${DEV_ENV_CMD} gox -verbose \ |
| 58 | + ${GO_LDFLAGS} \ |
| 59 | + -os="linux darwin " \ |
| 60 | + -arch="amd64 386" \ |
| 61 | + -output="$(DIST_DIR)/deis-${VERSION}-{{.OS}}-{{.Arch}}" . |
| 62 | + |
| 63 | +binary-build: |
| 64 | + ${DEV_ENV_PREFIX} -e GOOS=${GOOS} ${DEV_ENV_IMAGE} go build -a -installsuffix cgo ${GO_LDFLAGS} -o deis . |
| 65 | + |
| 66 | +dist: build-all |
| 67 | + |
| 68 | +install: |
| 69 | + cp deis $$GOPATH/bin |
| 70 | + |
| 71 | +installer: build |
| 72 | + @if [ ! -d makeself ]; then git clone -b single-binary https://github.com/deis/makeself.git; fi |
| 73 | + PATH=./makeself:$$PATH BINARY=deis makeself.sh --bzip2 --current --nox11 . \ |
| 74 | + deis-cli-`cat deis-version`-`go env GOOS`-`go env GOARCH`.run \ |
| 75 | + "Deis CLI" "echo \ |
| 76 | + && echo 'deis is in the current directory. Please' \ |
| 77 | + && echo 'move deis to a directory in your search PATH.' \ |
| 78 | + && echo \ |
| 79 | + && echo 'See http://docs.deis.io/ for documentation.' \ |
| 80 | + && echo" |
| 81 | + |
| 82 | +setup-gotools: |
| 83 | + go get -u github.com/golang/lint/golint |
| 84 | + go get -u golang.org/x/tools/cmd/cover |
| 85 | + go get -u golang.org/x/tools/cmd/vet |
| 86 | + |
| 87 | +test: test-style test-unit |
90 | 88 |
|
91 | 89 | test-style: |
92 | | - cd rootfs && flake8 --show-pep8 --show-source |
93 | | - shellcheck $(SHELL_SCRIPTS) |
| 90 | + @if [ $(shell $(GOFMT) $(GO_FILES) $(GO_PACKAGES)) ]; then \ |
| 91 | + echo "gofmt check failed:"; $(GOFMT) $(GO_FILES) $(GO_PACKAGES); exit 1; \ |
| 92 | + fi |
| 93 | + @go vet $(repo_path) $(GO_PACKAGES_REPO_PATH) |
| 94 | + @for i in $(addsuffix /...,$(GO_PACKAGES)); do \ |
| 95 | + golint $$i; \ |
| 96 | + done |
94 | 97 |
|
95 | 98 | test-unit: |
96 | | - cd rootfs \ |
97 | | - && coverage run manage.py test --noinput registry api \ |
98 | | - && coverage report -m |
99 | | - |
100 | | -test-functional: |
101 | | - @echo "Implement functional tests in _tests directory" |
102 | | - |
103 | | -test-integration: |
104 | | - @echo "Check https://github.com/deis/workflow-e2e for the complete interation test suite" |
105 | | - |
106 | | -.PHONY: build clean commit-hook full-clean postgres setup-venv test test-style test-unit test-functional |
| 99 | + $(GOTEST) $(shell glide novendor) |
0 commit comments