-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
198 lines (145 loc) · 4.79 KB
/
Makefile
File metadata and controls
198 lines (145 loc) · 4.79 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
SHELL:=/bin/bash -O globstar
.SHELLFLAGS = -ec
.PHONY: build dist
.DEFAULT_GOAL := list
# this is just to try and supress errors caused by poetry run
export PYTHONWARNINGS=ignore:::setuptools.command.install
list:
@grep '^[^#[:space:]].*:' Makefile
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
########################################################################################################################
##
## Makefile for this project things
##
########################################################################################################################
pwd := ${PWD}
dirname := $(notdir $(patsubst %/,%,$(CURDIR)))
DOCKER_BUILDKIT ?= 1
ifneq (,$(wildcard ./.env))
include .env
export
endif
install:
poetry install
poetry sync
install-ci:
poetry install --without local
poetry sync
update:
poetry update
local-terraform:
make -C stacks/localstack
docker-build:
docker compose build --pull
up-ci: requirements certs
docker compose up -d --remove-orphans
scripts/wait-for-container.sh localstack
make local-terraform
up: up-ci
stop-lambdas:
docker stop $$(docker ps --filter name=lambda -q) || true
down: stop-lambdas
poetry run docker compose down --remove-orphans || true
make -C stacks/localstack clean
build:
poetry run python -m build
pytest: certs
poetry run pytest
test: pytest
tox:
poetry run tox
tflint:
@docker run -v "$(pwd)/module:/data" -v "$(pwd)/tflint.hcl:/tflint.hcl" --entrypoint=/bin/sh \
ghcr.io/terraform-linters/tflint \
-c "tflint --init --config '/tflint.hcl'; tflint --config '/tflint.hcl' --enable-plugin=aws"
tf-format-check:
terraform fmt -check -recursive module
tf-format:
terraform fmt --recursive
tfsec:
tfsec module --config-file tfsec.yml
mypy:
poetry run mypy .
shellcheck:
@# Only swallow checking errors (rc=1), not fatal problems (rc=2)
docker run --rm -i -v ${PWD}:/mnt:ro koalaman/shellcheck -f gcc -e SC1090,SC1091 `find . \( -path "*/.venv/*" -prune -o -path "*/build/*" -prune -o -path "*/.tox/*" -prune -o -path "*/java_client/*" -prune \) -o -type f -name '*.sh' -print` || test $$? -eq 1
ruff: black
poetry run ruff check . --fix --show-fixes
ruff-check:
poetry run ruff check .
ruff-ci:
poetry run ruff check . --output-format=github
lint: ruff mypy shellcheck tflint
black-check:
poetry run black . --check
black:
poetry run black .
coverage-cleanup:
rm -f .coverage* || true
coverage-ci-test: certs
poetry run coverage run -m pytest tests/integration --color=yes -v --junit-xml=./reports/junit/tests-integration.xml
poetry run coverage run -a -m pytest tests/mocked --color=yes -v --junit-xml=./reports/junit/tests-mocked.xml
coverage-report:
@poetry run coverage report; \
poetry run coverage xml;
coverage: coverage-cleanup coverage-test coverage-report
coverage-test:
poetry run coverage run -m pytest tests/integration
poetry run coverage run -a -m pytest tests/mocked
coverage-ci: coverage-cleanup coverage-ci-test coverage-report
requirements:
@lock_hash=$$(md5sum poetry.lock | cut -d' ' -f1); \
for f in $$(find . -type f -name 'poetry-cmd.sh' | sort); do \
reqs_dir="$$(dirname $$f)"; \
echo "$${reqs_dir}"; \
cmd_hash=$$(md5sum $$f | cut -d' ' -f1) ; \
cur_hash=$$(cat "$${reqs_dir}/.lock-hash" 2>/dev/null || echo -n ''); \
update="no"; \
if test ! -f "$${reqs_dir}/requirements.txt"; then \
echo "$${reqs_dir}/requirements.txt does not exist"; \
update="yes"; \
fi; \
if [[ "$${lock_hash}+$${cmd_hash}" != "$${cur_hash}" ]]; then \
echo "$${lock_hash}+$${cmd_hash} != $${cur_hash}"; \
update="yes"; \
fi; \
if [[ "$${update}" == "yes" ]]; then \
echo "running: $${f}"; \
/bin/bash $$f; \
echo -n "$${lock_hash}+$${cmd_hash}" > "$${reqs_dir}/.lock-hash"; \
else \
echo "$${lock_hash}+$${cmd_hash} == $${cur_hash}"; \
fi \
done
check-secrets:
scripts/check-secrets.sh
check-secrets-all:
scripts/check-secrets.sh unstaged
delete-hooks:
rm .git/hooks/pre-commit 2>/dev/null || true
rm .git/hooks/commit-msg 2>/dev/null || true
.git/hooks/pre-commit:
cp scripts/hooks/pre-commit.sh .git/hooks/pre-commit
.git/hooks/commit-msg:
cp scripts/hooks/commit-msg.sh .git/hooks/commit-msg
refresh-hooks: delete-hooks .git/hooks/pre-commit .git/hooks/commit-msg
certs:
scripts/self-signed-ca/create-all.sh localhost
certs-new:
rm -r resources/mesh_certs/local || true
rm -f .docker.env || true
scripts/self-signed-ca/create-all.sh localhost mesh_api --overwrite
scripts/self-signed-ca/.certs.env:
make certs
pack-deps:
module/pack-deps.sh ./module
pack-app: guard-env
module/pack-app.sh ./module $(env)
list-functions:
AWS_ENDPOINT_URL=http://localhost:4569 aws lambda list-functions | jq -r .Functions[].FunctionName
s3-ls:
AWS_ENDPOINT_URL=http://localhost:4569 aws s3 ls --recursive s3://local-mesh/