-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathGNUmakefile
148 lines (123 loc) · 4.11 KB
/
GNUmakefile
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
SHELL := /usr/bin/env bash
VENV_DIR ?= $(CURDIR)/venv
PIP ?= pip3 --disable-pip-version-check --no-input --require-virtualenv
PYTHON ?= python3
PYTHON_VERSION ?= 3.10
DOCKER_COMPOSE ?= docker compose
KARAPACE-CLI ?= $(DOCKER_COMPOSE) -f container/compose.yml run --rm karapace-cli
define PIN_VERSIONS_COMMAND
pip install pip-tools && \
python -m piptools compile --upgrade -o /karapace/requirements/requirements.txt /karapace/pyproject.toml && \
python -m piptools compile --upgrade --extra dev -o /karapace/requirements/requirements-dev.txt /karapace/pyproject.toml && \
python -m piptools compile --upgrade --extra typing -o /karapace/requirements/requirements-typing.txt /karapace/pyproject.toml
endef
export PATH := $(VENV_DIR)/bin:$(PATH)
export PS4 := \e[0m\e[32m==> \e[0m
export LC_ALL := C
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
SHELL := bash
.SHELLFLAGS := -euxo pipefail -O globstar -c
.SILENT:
.SUFFIXES:
.PHONY: all
all: version
.PHONY: venv
venv: venv/.make
venv/.make:
rm -fr '$(VENV_DIR)'
$(PYTHON) -m venv '$(VENV_DIR)'
$(PIP) install --upgrade pip
touch '$(@)'
.PHONY: install
install: venv/.deps
venv/.deps: venv/.make
set +x
source ./bin/get-java
source ./bin/get-protoc
source ./bin/get-snappy
set -x
$(PIP) install --use-pep517 .
$(PIP) check
touch '$(@)'
.PHONY: install-dev
install-dev: venv/.deps-dev
venv/.deps-dev: venv/.make
set +x
source ./bin/get-java
source ./bin/get-protoc
source ./bin/get-snappy
set -x
$(PIP) install -e .[dev]
$(PIP) check
touch '$(@)'
.PHONY: test
tests: unit-tests integration-tests
.PHONY: unit-tests
unit-tests: export PYTEST_ARGS ?=
unit-tests: venv/.deps-dev
rm -fr runtime/*
$(PYTHON) -m pytest -s -vvv $(PYTEST_ARGS) tests/unit/
rm -fr runtime/*
.PHONY: integration-tests
integration-tests: export PYTEST_ARGS ?=
integration-tests: venv/.deps-dev
rm -fr runtime/*
$(PYTHON) -m pytest -s -vvv $(PYTEST_ARGS) tests/integration/
rm -fr runtime/*
.PHONY: clean
clean:
rm -fr ./kafka_* ./*.egg-info/ ./dist/ ./karapace/version.py
.PHONY: cleaner
cleaner: clean
rm -fr ./.*cache*/
.PHONY: cleanest
cleanest: cleaner
rm -fr '$(VENV_DIR)'
.PHONY: requirements
requirements:
requirements:
$(PIP) install --upgrade pip setuptools pip-tools
$(PIP) install .[dev,typing]
.PHONY: schema
schema: against := origin/main
schema:
$(PYTHON) -m karapace.backup.backends.v3.schema_tool --against=$(against)
.PHONY: pin-requirements
pin-requirements:
docker run -e CUSTOM_COMPILE_COMMAND='make pin-requirements' -it -v .:/karapace --security-opt label=disable python:$(PYTHON_VERSION)-bullseye /bin/bash -c "$(PIN_VERSIONS_COMMAND)"
.PHONY: stop-karapace-docker-resources
stop-karapace-docker-resources:
$(DOCKER_COMPOSE) -f container/compose.yml down -v --remove-orphans
.PHONY: start-karapace-docker-resources
start-karapace-docker-resources: export KARAPACE_VERSION ?= 4.1.1.dev44+gac20eeed.d20241205
start-karapace-docker-resources:
sudo touch .coverage.3.10 .coverage.3.11 .coverage.3.12
sudo chown ${RUNNER_UID}:${RUNNER_GID} .coverage.3.10 .coverage.3.11 .coverage.3.12
$(DOCKER_COMPOSE) -f container/compose.yml up -d --build --wait --detach
.PHONY: unit-tests-in-docker
unit-tests-in-docker: export PYTEST_ARGS ?=
unit-tests-in-docker: start-karapace-docker-resources
rm -fr runtime/*
$(KARAPACE-CLI) $(PYTHON) -m pytest -s -vvv $(PYTEST_ARGS) tests/unit/
rm -fr runtime/*
.PHONY: e2e-tests-in-docker
e2e-tests-in-docker: export PYTEST_ARGS ?=
e2e-tests-in-docker: stop-karapace-docker-resources start-karapace-docker-resources
rm -fr runtime/*
sleep 10
$(KARAPACE-CLI) $(PYTHON) -m pytest -s -vvv $(PYTEST_ARGS) tests/e2e/
rm -fr runtime/*
.PHONY: integration-tests-in-docker
integration-tests-in-docker: export PYTEST_ARGS ?=
integration-tests-in-docker: start-karapace-docker-resources
rm -fr runtime/*
sleep 10
$(KARAPACE-CLI) $(PYTHON) -m pytest -s -vvv $(PYTEST_ARGS) tests/integration/
rm -fr runtime/*
.PHONY: type-check-mypy-in-docker
type-check-mypy-in-docker: start-karapace-docker-resources
$(KARAPACE-CLI) $(PYTHON) -m mypy src/karapace
.PHONY: cli
cli: start-karapace-docker-resources
$(KARAPACE-CLI) bash