-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Makefile
97 lines (72 loc) · 2.8 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
.PHONY: dev lint mypy-lint complex coverage pre-commit sort deploy destroy deps unit infra-tests integration e2e coverage-tests docs lint-docs build format format-fix compare-openapi openapi pr watch update-deps
PYTHON := ".venv/bin/python3"
.ONESHELL: # run all commands in a single shell, ensuring it runs within a local virtual env
OPENAPI_DIR := ./docs/swagger
CURRENT_OPENAPI := $(OPENAPI_DIR)/openapi.json
LATEST_OPENAPI := openapi_latest.json
dev:
pip install --upgrade pip pre-commit poetry
pre-commit install
# ensures poetry creates a local virtualenv (.venv)
poetry config --local virtualenvs.in-project true
poetry install --no-root
npm ci
format:
poetry run ruff check . --fix
format-fix:
poetry run ruff format .
lint: format
@echo "Running mypy"
$(MAKE) mypy-lint
complex:
@echo "Running Radon"
poetry run radon cc -e 'tests/*,cdk.out/*,node_modules/*' .
@echo "Running xenon"
poetry run xenon --max-absolute B --max-modules A --max-average A -e 'tests/*,.venv/*,cdk.out/*,node_modules/*' .
pre-commit:
poetry run pre-commit run -a --show-diff-on-failure
mypy-lint:
poetry run mypy --pretty service cdk tests
deps:
poetry export --only=dev --format=requirements.txt > dev_requirements.txt
poetry export --without=dev --format=requirements.txt > lambda_requirements.txt
unit:
poetry run pytest tests/unit --cov-config=.coveragerc --cov=service --cov-report xml
build: deps
mkdir -p .build/lambdas ; cp -r service .build/lambdas
mkdir -p .build/common_layer ; poetry export --without=dev --format=requirements.txt > .build/common_layer/requirements.txt
infra-tests: build
poetry run pytest tests/infrastructure
integration:
poetry run pytest tests/integration --cov-config=.coveragerc --cov=service --cov-report xml
e2e:
poetry run pytest tests/e2e --cov-config=.coveragerc --cov=service --cov-report xml
pr: deps format pre-commit complex lint lint-docs unit deploy coverage-tests e2e openapi
coverage-tests:
poetry run pytest tests/unit tests/integration --cov-config=.coveragerc --cov=service --cov-report xml
deploy: build
npx cdk deploy --app="${PYTHON} ${PWD}/app.py" --require-approval=never
destroy:
npx cdk destroy --app="${PYTHON} ${PWD}/app.py" --force
docs:
poetry run mkdocs serve
lint-docs:
docker run -v ${PWD}:/markdown 06kellyjac/markdownlint-cli --fix "docs"
watch:
npx cdk watch
update-deps:
poetry update
pre-commit autoupdate
npm i --package-lock-only
openapi:
poetry run python generate_openapi.py
compare-openapi:
poetry run python generate_openapi.py --out-destination '.' --out-filename 'openapi_latest.json'
@if cmp --silent $(CURRENT_OPENAPI) $(LATEST_OPENAPI); then \
rm $(LATEST_OPENAPI); \
echo "Swagger file is up to date"; \
else \
echo "Swagger files are not equal, did you run 'make pr' or 'make openapi'?"; \
rm $(LATEST_OPENAPI); \
exit 1; \
fi