-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
70 lines (57 loc) · 2.1 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
TF=terraform
PYTHON=python3
VENV=.kafka2sqs
BUILD_VENV=.build_venv
LAMBDA_ZIP=lambda.zip
TF_ZIP=module.zip
PY_SRC=kafka2sqs
PY_TESTS=tests
.PHONY: clean test
$(TF_ZIP): $(LAMBDA_ZIP) modules/**
cp $(LAMBDA_ZIP) modules/lambda/
cd modules && zip -r ../$(TF_ZIP) *
$(LAMBDA_ZIP): requirements.txt $(PY_SRC)/* $(BUILD_VENV)/bin/activate
@echo "Package dependencies"
cd $(BUILD_VENV)/lib/python*/site-packages; \
rm -rf pip* setup* pkg_* _distutils_hack; \
zip -r ../../../../$(LAMBDA_ZIP) .
@echo "Add the handler"
zip -r $(LAMBDA_ZIP) $(PY_SRC)
lint: venv
$(VENV)/bin/python -m black $(PY_SRC)/ $(PY_TESTS)/
$(TF) fmt -recursive modules
$(TF) fmt -recursive examples
check: venv test
cd modules; \
$(TF) init; \
$(TF) fmt -recursive -check; \
$(TF) validate
$(TF) fmt -recursive -check examples
$(VENV)/bin/python -m black --check $(PY_SRC)
test: venv
$(VENV)/bin/python -m pytest --cov=kafka2sqs tests --asyncio-mode=strict
$(BUILD_VENV)/bin/activate: requirements.txt
$(PYTHON) -m venv $(BUILD_VENV); \
$(BUILD_VENV)/bin/pip install -r requirements.txt
venv: $(VENV)/bin/activate
$(VENV)/bin/activate: requirements.txt requirements.dev.txt
$(PYTHON) -m venv $(VENV)
$(VENV)/bin/pip install -r requirements.dev.txt
$(VENV)/bin/pip install -r requirements.txt
docs: $(VENV)/bin/terraform-docs
$(VENV)/bin/terraform-docs -c modules/.terraform-docs.yml modules/lambda > modules/lambda/readme.md
$(VENV)/bin/terraform-docs -c modules/.terraform-docs.yml modules/sasl_secrets > modules/sasl_secrets/readme.md
$(VENV)/bin/terraform-docs -c modules/.terraform-docs.yml modules/mtls_secrets > modules/mtls_secrets/readme.md
$(VENV)/bin/terraform-docs: venv
cd /tmp/; \
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.16.0/terraform-docs-v0.16.0-$(shell uname -s)-amd64.tar.gz; \
tar xzf terraform-docs.tar.gz; \
chmod +x terraform-docs
mv /tmp/terraform-docs $(VENV)/bin/terraform-docs
clean: venv
@echo Remove all generated zip files
find . | grep .zip | xargs rm -rf
@echo Remove python cache files
$(VENV)/bin/python -m pyclean kafka2sqs tests
@echo Remove build venv
rm -rf $(BUILD_VENV)