Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (62 loc) · 2.17 KB
/
Copy pathMakefile
File metadata and controls
74 lines (62 loc) · 2.17 KB
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
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
APP_IMAGE ?= hub.adsw.io/adcm/adcm
APP_TAG ?= $(subst /,_,$(BRANCH_NAME))
SELENOID_HOST ?= 10.92.2.65
SELENOID_PORT ?= 4444
ADCM_VERSION = "3.1.0-dev"
PY_FILES = python dev/linters conf/adcm/python_scripts
.PHONY: build unittests test-integrations pretty lint version
define uv_sync
uv sync --inexact --group $(1)
endef
define pg_start
docker run -d --rm -e POSTGRES_PASSWORD="postgres" --name postgres -p 5500:5432 postgres:14
i=0; until docker exec postgres pg_isready -U postgres > /dev/null 2>&1; do \
i=$$((i+1)); \
if [ $$i -ge 30 ]; then \
echo "Postgres did not become ready within 30s" >&2; \
docker stop postgres; \
exit 1; \
fi; \
sleep 1; \
done
endef
define pg_stop
docker stop postgres
endef
TEST_ENV = DJANGO_SETTINGS_MODULE=adcm.settings_setups.test \
DB_HOST="localhost" DB_USER="postgres" DB_PORT="5500" DB_NAME="postgres" DB_PASS="postgres"
# $(1): arguments of `manage.py test` (labels and options)
define run_tests
$(call uv_sync,unittests)
$(pg_start)
$(TEST_ENV) uv run python/manage.py test -v 2 --keepdb $(1); \
TEST_EXIT=$$?; \
$(pg_stop); \
exit $$TEST_EXIT
endef
build:
@docker build --platform=linux/amd64 . -t $(APP_IMAGE):$(APP_TAG) --build-arg ADCM_VERSION=$(ADCM_VERSION)
unittests:
# celery_worker exclude is ignored, but it's a failsafe in case discovery is changed,
# since these tests may flak/fail in parallel run
$(call run_tests,python --parallel --exclude-tag celery_worker)
test-integrations:
# `tests.integrations` has no `__init__.py`, so its test packages have to be pointed at directly
$(call run_tests,tests.integrations.celery)
pretty:
$(call uv_sync,lint)
uv run ruff format $(PY_FILES)
uv run ruff check --fix $(PY_FILES)
uv run ruff format $(PY_FILES)
uv run python dev/linters/license_checker.py --fix --folders $(PY_FILES) go
lint:
$(call uv_sync,lint)
uv run ruff check $(PY_FILES)
uv run ruff format --check $(PY_FILES)
uv run pyright --project pyproject.toml
env PYTHONPATH=python uv run lint-imports --verbose
uv run python dev/linters/license_checker.py --folders $(PY_FILES) go
uv run python dev/linters/migrations_checker.py python
version:
@echo $(ADCM_VERSION)