-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
128 lines (106 loc) · 2.91 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
IMAGE_NAME ?= "opsani/servox:edge"
KUBETEST_CONTEXT ?= "kubetest"
ifneq (,$(wildcard ./.env))
include .env
export
ENV_FILE_PARAM = --env-file .env
endif
OPSANI_TOKEN_FILE ?= "/dev/null"
define vscode_settings
{
"python.pythonPath": "$(shell poetry env info -p)/bin/python",
"terminal.integrated.shellArgs.linux": ["poetry shell"],
"terminal.integrated.shellArgs.osx": ["poetry shell"],
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/*.pyc": true,
"**/__pycache__": true,
"**/.mypy_cache": true
},
"python.linting.enabled": true
}
endef
export vscode_settings
.PHONY: init
init:
mkdir -p .vscode
touch .vscode/settings.json
@echo "$$vscode_settings" > .vscode/settings.json
poetry install
poetry run servo init
.PHONY: vscode
vscode:
source "$(shell poetry env info -p)/bin/activate" --prompt "poetry env"
code .
.PHONY: build
build:
DOCKER_BUILDKIT=1 docker build -t ${IMAGE_NAME} --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from opsani/servox:edge .
.PHONY: generate
generate:
@$(MAKE) -e SERVO_ARGS="generate --force" run
.PHONY: config
config:
@$(MAKE) -e SERVO_ARGS="config" run
.PHONY: run
run: build
docker run -it \
-v $(CURDIR)/servo.yaml:/servo/servo.yaml \
-v ${HOME}/.kube:/root/.kube:ro \
-v ${HOME}/.aws:/root/.aws:ro \
-v ${OPSANI_TOKEN_FILE:-/dev/null}:/servo/opsani.token \
$(ENV_FILE_PARAM) \
$(IMAGE_NAME) \
${SERVO_ARGS:-run}
.PHONY: push
push: build
docker push ${IMAGE_NAME}
.PHONY: format
format:
poetry run isort .
poetry run autoflake --recursive \
--ignore-init-module-imports \
--remove-all-unused-imports \
--remove-unused-variables \
--in-place servo tests
.PHONY: typecheck
typecheck:
poetry run mypy servo || true
.PHONY: lint-docs
lint-docs:
poetry run flake8-markdown "**/*.md" || true
.PHONY: lint
lint: typecheck
poetry run flakehell lint --count
.PHONY: scan
scan:
poetry run bandit -r servo
.PHONY: test-kubeconfig
test-kubeconfig:
@kubectl config view \
--minify --flatten \
> $(CURDIR)/tests/kubeconfig
@kubectl config rename-context \
--kubeconfig=$(CURDIR)/tests/kubeconfig \
$(shell kubectl config current-context) \
$(KUBETEST_CONTEXT)
@echo "Saved current kubeconfig context '$(shell kubectl config current-context)' as '$(KUBETEST_CONTEXT)' in tests/kubeconfig"
.PHONY: pre-commit
pre-commit:
poetry run pre-commit run --hook-stage manual --all-files
.PHONY: autotest
autotest:
poetry run watchfiles autotest.main
.PHONY: test
test: test-unit test-integration test-system
.PHONY: test-coverage
poetry run pytest --cov=servo --cov-report=term-missing:skip-covered --cov-config=setup.cfg
.PHONY: test-unit
test-unit:
poetry run pytest -T unit -n 6
.PHONY: test-integration
test-integration:
poetry run pytest -T integration -n 6 --durations=0 --durations-min=5
.PHONY: test-system
test-system:
poetry run pytest -T system -n 6 --durations=0 --durations-min=5