-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (52 loc) · 2.29 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
.PHONY: test docker push
IMAGE_PREFIX ?= ghcr.io/dlmiddlecote/openapi
GITDIFFHASH = $(shell git diff | md5sum | cut -c 1-4)
VERSION ?= $(shell git describe --tags --always --dirty=-dirty-$(GITDIFFHASH))
TAG ?= $(VERSION)
CLUSTER_NAME ?= kind
default: docker
.PHONY: test
test: poetry lint test.unit test.e2e
.PHONY: poetry
poetry:
poetry install
.PHONY: lint
lint:
poetry run flake8
poetry run black --check openapi_collector --check openapi_proxy
.PHONY: test.unit
test.unit:
poetry run coverage run --source openapi_collector -m py.test tests/collector
poetry run coverage run -a --source openapi_proxy -m py.test tests/proxy
poetry run coverage report
.PHONY: test.e2e
test.e2e: docker
env IMAGE_PREFIX=$(IMAGE_PREFIX) TAG=$(TAG) \
poetry run pytest -v -r=a \
--log-cli-level info \
--log-cli-format '%(asctime)s %(levelname)s %(message)s' \
--cluster-name $(CLUSTER_NAME) \
tests/e2e
docker:
docker build --build-arg "VERSION=$(VERSION)" -t "$(IMAGE_PREFIX)-router:$(TAG)" -f ./docker/router/Dockerfile .
docker build --build-arg "VERSION=$(VERSION)" -t "$(IMAGE_PREFIX)-collector:$(TAG)" -f ./docker/collector/Dockerfile .
docker build --build-arg "VERSION=$(VERSION)" -t "$(IMAGE_PREFIX)-proxy:$(TAG)" -f ./docker/proxy/Dockerfile .
@echo 'Docker images $(IMAGE_PREFIX)-router:$(TAG), $(IMAGE_PREFIX)-collector:$(TAG), $(IMAGE_PREFIX)-proxy:$(TAG) can now be used.'
push: docker
docker push "$(IMAGE_PREFIX)-router:$(TAG)"
docker push "$(IMAGE_PREFIX)-collector:$(TAG)"
docker push "$(IMAGE_PREFIX)-proxy:$(TAG)"
docker tag "$(IMAGE_PREFIX)-router:latest"
docker tag "$(IMAGE_PREFIX)-collector:latest"
docker tag "$(IMAGE_PREFIX)-proxy:latest"
docker push "$(IMAGE_PREFIX)-router:latest"
docker push "$(IMAGE_PREFIX)-collector:latest"
docker push "$(IMAGE_PREFIX)-proxy:latest"
update-deploy-files:
perl -i -pe"s/image: $(subst /,\/,$(IMAGE_PREFIX))-(.*):.*/image: $(subst /,\/,$(IMAGE_PREFIX))-\1:$(subst /,\/,$(TAG))/g" ./deploy/deployment.yaml
kind-load:
kind load docker-image $(IMAGE_PREFIX)-router:$(TAG) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_PREFIX)-collector:$(TAG) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_PREFIX)-proxy:$(TAG) --name $(CLUSTER_NAME)
format:
poetry run black openapi_collector openapi_proxy tests