This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
176 lines (150 loc) · 5.11 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Copyright 2019 Yelp Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PKG_NAME=clusterman
DOCKER_TAG ?= ${PKG_NAME}-dev-$(USER)
VIRTUALENV_RUN_TARGET = virtualenv_run-dev
VIRTUALENV_RUN_REQUIREMENTS = requirements.txt requirements-dev.txt
ifeq ($(findstring .yelpcorp.com,$(shell hostname -f)), .yelpcorp.com)
PAASTA_ENV ?= YELP
else
PAASTA_ENV ?= $(shell hostname --fqdn)
endif
ifeq ($(PAASTA_ENV),YELP)
export DOCKER_REGISTRY ?= docker-dev.yelpcorp.com
export BIONIC_IMAGE_NAME ?= bionic_pkgbuild
export JAMMY_IMAGE_NAME ?= jammy_pkgbuild
else
export PIP_INDEX_URL ?= https://pypi.python.org/simple
export NPM_CONFIG_REGISTRY ?= https://registry.npmjs.org
export DOCKER_REGISTRY ?= docker.io
export BIONIC_IMAGE_NAME ?= ubuntu:bionic
export JAMMY_IMAGE_NAME ?= ubuntu:jammy
endif
.PHONY: all
all: development
# https://www.gnu.org/software/make/manual/html_node/Target_002dspecific
.PHONY: production
production: virtualenv_run
production: export VIRTUALENV_RUN_REQUIREMENTS = requirements.txt
production: export VIRTUALENV_RUN_TARGET = virtualenv_run
.PHONY: development
development: virtualenv_run install-hooks
.PHONY: docs
docs:
-rm -rf docs/build
tox -e docs
.PHONY: test
test: clean-cache
tox -e yelp
.PHONY: test-external
test-external: clean-cache
tox -e external -- --tags=-yelp
.PHONY: itest
itest: cook-image
.PHONY: itest-external
itest-external: cook-image-external
.PHONY: cook-image
cook-image:
git rev-parse HEAD > version
docker build --build-arg DOCKER_REGISTRY=${DOCKER_REGISTRY} --build-arg IMAGE_NAME=${JAMMY_IMAGE_NAME} -t $(DOCKER_TAG) .
.PHONY: cook-image-external
cook-image-external:
git rev-parse HEAD > version
docker build --build-arg DOCKER_REGISTRY=${DOCKER_REGISTRY} --build-arg IMAGE_NAME=${JAMMY_IMAGE_NAME} -t $(DOCKER_TAG) -f Dockerfile.external .
.PHONY: completions
completions:
mkdir -p completions
tox -e completions
.PHONY: install-hooks
install-hooks: virtualenv_run
./virtualenv_run/bin/pre-commit install -f --install-hooks
.PHONY: run-hooks
run-pre-commit: virtualenv_run
./virtualenv_run/bin/pre-commit run -a
virtualenv_run: $(VIRTUALENV_RUN_REQUIREMENTS)
tox -e $(VIRTUALENV_RUN_TARGET)
.PHONY: version-bump
version-bump:
@set -e; \
if [ -z ${EDITOR} ]; then \
echo "EDITOR environment variable not set, please set and try again"; \
false; \
fi; \
OLD_PACKAGE_VERSION=$$(python setup.py --version); \
${EDITOR} ${PKG_NAME}/__init__.py; \
PACKAGE_VERSION=$$(python setup.py --version); \
if [ "$${OLD_PACKAGE_VERSION}" = "$${PACKAGE_VERSION}" ]; then \
echo "package version unchanged; aborting"; \
false; \
elif [ ! -f debian/changelog ]; then \
dch -v $${PACKAGE_VERSION} --create --package=$(PKG_NAME) -D "bionic jammy" -u low ${ARGS}; \
else \
dch -v $${PACKAGE_VERSION} -D "bionic jammy" -u low ${ARGS}; \
fi; \
git add debian/changelog ${PKG_NAME}/__init__.py; \
set +e; git commit -m "Bump to version $${PACKAGE_VERSION}"; \
if [ $$? -ne 0 ]; then \
git add debian/changelog ${PKG_NAME}/__init__.py; \
git commit -m "Bump to version $${PACKAGE_VERSION}"; \
fi; \
if [ $$? -eq 0 ]; then git tag "v$${PACKAGE_VERSION}"; fi
dist:
ln -sf package/dist ./dist
itest_%: dist completions
COMPOSE_PROJECT_NAME=clusterman_$* tox -e acceptance
make -C package $@
itest_%-external: dist
COMPOSE_PROJECT_NAME=clusterman_$* tox -e acceptance
make -C package $@
.PHONY:
package: itest_bionic itest_jammy
.PHONY:
package-external: itest_bionic-external itest_jammy-external
.PHONY:
example: export EXAMPLE=true
example: itest_jammy-external
.PHONY:
clean: clean-cache
-docker-compose -f acceptance/docker-compose.yaml down
-rm -rf docs/build
-rm -rf virtualenv_run/
-rm -rf .tox
-unlink dist
-rm -rf package/dist/*
.PHONY:
clean-cache:
find -name '*.pyc' -delete
find -name '__pycache__' -delete
rm -rf .mypy_cache
rm -rf .pytest_cache
.PHONY:
debug:
docker build . -t clusterman_debug_container
paasta_docker_wrapper run -it \
-v $(shell pwd)/clusterman:/code/clusterman:rw \
-v $(shell pwd)/clusterman.conf:/var/lib/clusterman/clusterman.conf:rw \
-v $(shell pwd)/.cman_debug_bashrc:/home/nobody/.bashrc:ro \
-v $(shell pwd)/etc-kubernetes:/etc/kubernetes:ro \
-v /nail/srv/configs:/nail/srv/configs:ro \
-v $(shell pwd)/clusterman.yaml:/nail/srv/configs/clusterman.yaml:ro \
-v $(shell pwd)/default.kubernetes:/nail/srv/configs/clusterman-clusters/kubestage/default.kubernetes:ro \
-v /nail/etc/services:/nail/etc/services:ro \
-v /etc/boto_cfg:/etc/boto_cfg:ro \
-e "CMAN_CLUSTER=kubestage" \
-e "CMAN_POOL=default" \
-e "CMAN_SCHEDULER=kubernetes" \
clusterman_debug_container /bin/bash
.PHONY:
upgrade-requirements:
upgrade-requirements --python python3.8