forked from data-dot-all/dataall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (100 loc) · 4.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
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
help:
@echo "install - install a virtualenv for development"
@echo "lint - check source code with flake8"
@echo "test - run unit tests"
@echo "coverage - check code coverage"
@echo "build env={env} - package new code and update the function in the cloud"
@echo "describe env={env} - describe cloud stack"
@echo "check env={env} - check the state of one function"
@echo "clean - remove build, test, coverage and Python artifacts locally"
@echo "tear-down env={env} - completely destroy stack in the cloud -- be cautious"
.PHONY: venv
venv:
@test -d "venv" || mkdir -p "venv"
@rm -Rf "venv"
@python3 -m venv "venv"
@/bin/bash -c "source venv/bin/activate"
install: upgrade-pip install-deploy install-backend install-cdkproxy install-tests
upgrade-pip:
pip install --upgrade pip setuptools
install-deploy:
pip install -r deploy/requirements.txt
install-backend:
pip install -r backend/requirements.txt
install-cdkproxy:
pip install -r backend/dataall/base/cdkproxy/requirements.txt
install-tests:
pip install -r tests/requirements.txt
install-integration-tests:
pip install -r tests_new/integration_tests/requirements.txt
lint:
pip install ruff
ruff check --fix
ruff format
bandit:
pip install bandit
python -m bandit -r backend/ | tee bandit.log || true
check-security: upgrade-pip install-backend install-cdkproxy
pip install bandit
pip install safety
bandit -lll -r backend
safety check --ignore=51668,70612,70624
checkov-synth: upgrade-pip install-backend install-cdkproxy install-tests
export PYTHONPATH=./backend:/./tests && \
python -m pytest -v -ra -k test_checkov tests
test:
export PYTHONPATH=./backend:/./tests && \
python -m pytest -v -ra tests/
integration-tests: upgrade-pip install-integration-tests
export PYTHONPATH=./backend:/./tests_new && \
python -m pytest -v -ra tests_new/integration_tests/ \
--junitxml=reports/integration_tests.xml
coverage: upgrade-pip install-backend install-cdkproxy install-tests
export PYTHONPATH=./backend:/./tests && \
python -m pytest -x -v -ra tests/ \
--junitxml=reports/test-unit.xml \
--cov-report xml:cobertura.xml \
--cov-report term-missing \
--cov-report html \
--cov=backend/dataall \
--cov-config=.coveragerc \
--color=yes
deploy-image:
docker build -f backend/docker/prod/${type}/Dockerfile -t ${image-tag}:${image-tag} . && \
aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${account}.dkr.ecr.${region}.amazonaws.com && \
docker tag ${image-tag}:${image-tag} ${account}.dkr.ecr.${region}.amazonaws.com/${repo}:${image-tag} && \
docker push ${account}.dkr.ecr.${region}.amazonaws.com/${repo}:${image-tag}
assume-role:
aws sts assume-role --role-arn "arn:aws:iam::${REMOTE_ACCOUNT_ID}:role/${REMOTE_ROLE}" --external-id ${EXTERNAL_ID} --role-session-name "session1" >.assume_role_json
echo "export AWS_ACCESS_KEY_ID=$$(cat .assume_role_json | jq '.Credentials.AccessKeyId' -r)" >.env.assumed_role
echo "export AWS_SECRET_ACCESS_KEY=$$(cat .assume_role_json | jq '.Credentials.SecretAccessKey' -r)" >>.env.assumed_role
echo "export AWS_SESSION_TOKEN=$$(cat .assume_role_json | jq '.Credentials.SessionToken' -r)" >>.env.assumed_role
rm .assume_role_json
drop-tables: upgrade-pip install-backend
pip install 'alembic'
export PYTHONPATH=./backend && \
python backend/migrations/drop_tables.py
upgrade-db: upgrade-pip install-backend
pip install 'alembic'
export PYTHONPATH=./backend && \
alembic -c backend/alembic.ini upgrade head
generate-migrations: upgrade-pip install-backend
pip install 'alembic'
export PYTHONPATH=./backend && \
alembic -c backend/alembic.ini upgrade head
alembic -c backend/alembic.ini revision -m "describe_changes_shortly" --autogenerate
clean:
@rm -fr cdk_out/
@rm -fr dist/
@rm -fr htmlcov/
@rm -fr site/
@rm -fr .eggs/
@rm -fr cdk_out/
@rm -fr .tox/
@find . -name '*.egg-info' -exec rm -fr {} +
@find . -name "*.py[co]" -o -name .pytest_cache -exec rm -rf {} +
@find . -name '*.egg' -exec rm -f {} +
@find . -name '*.pyc' -exec rm -f {} +
@find . -name '*.pyo' -exec rm -f {} +
@find . -name '*~' -exec rm -f {} +
@find . -name '__pycache__' -exec rm -fr {} +