forked from ethyca/fidesops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
190 lines (155 loc) · 6.28 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
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
.DEFAULT_GOAL := help
####################
# CONSTANTS
####################
REGISTRY := ethyca
IMAGE_TAG := $(shell git fetch --force --tags && git describe --tags --dirty --always)
IMAGE_NAME := fidesops
IMAGE := $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)
IMAGE_LATEST := $(REGISTRY)/$(IMAGE_NAME):latest
####################
# Defaults
####################
.PHONY: help
help:
@echo "Under Construction, please read the Makefile directly!"
####################
# Dev
####################
init-db: compose-build
@echo "Check for new migrations to run..."
@docker-compose run --rm $(IMAGE_NAME) \
python -c "\
from fidesops.db.database import init_db; \
from fidesops.core.config import config; \
init_db(config.database.SQLALCHEMY_DATABASE_URI);"
reset-db:
@echo "Resetting and re-initializing the application db..."
@make teardown
@docker volume rm fidesops_app-db-data || echo "No app DB found, continuing!"
@make init-db
server: compose-build
@docker-compose up
server-shell: compose-build
@docker-compose run $(IMAGE_NAME) /bin/bash
integration-shell: compose-build
# note- does not bring up external connectors such as redshift or snowflake
@echo "Bringing up main image and images for integration testing"
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml up -d
@echo "Waiting 15s for integration containers to be ready..."
@sleep 15
@echo "Running additional setup for mssql integration tests"
@docker exec -it fidesops python tests/integration_tests/mssql_setup.py
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml run $(IMAGE_NAME) /bin/bash
integration-env: compose-build
@echo "Bringing up main image and images for integration testing"
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml up -d
@echo "Waiting 15s for integration containers to be ready..."
@sleep 15
@echo "Running additional setup for mssql integration tests"
@docker exec -it fidesops python tests/integration_tests/mssql_setup.py
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml logs -f -t
quickstart: compose-build
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml up -d
@docker exec -it fidesops python quickstart.py
####################
# Docker
####################
docker-build:
docker build --tag $(IMAGE) .
docker-push:
docker tag $(IMAGE) $(IMAGE_LATEST)
docker push $(IMAGE)
docker push $(IMAGE_LATEST)
####################
# CI
####################
check-all: black-ci pylint mypy check-migrations pytest pytest-integration-access pytest-integration-erasure
black-ci: compose-build
@echo "Running black checks..."
@docker-compose run $(IMAGE_NAME) \
black --check src/ \
|| (echo "Error running 'black --check', please run 'make black' to format your code!"; exit 1)
check-migrations: compose-build
@echo "Check if there are unrun migrations..."
@docker-compose run --rm $(IMAGE_NAME) \
python -c "\
from fidesops.db.database import check_missing_migrations; \
from fidesops.core.config import config; \
check_missing_migrations(config.database.SQLALCHEMY_DATABASE_URI);"
pylint: compose-build
@echo "Running pylint checks..."
@docker-compose run $(IMAGE_NAME) \
pylint src/
mypy: compose-build
@echo "Running mypy checks..."
@docker-compose run $(IMAGE_NAME) \
mypy --ignore-missing-imports src/
pytest: compose-build
@echo "Running pytest unit tests..."
@docker-compose run $(IMAGE_NAME) \
pytest $(pytestpath) -m "not integration and not integration_erasure and not integration_external"
# Run the pytest integration tests.
pytest-integration-access: compose-build
@echo "Building additional Docker images for integration tests..."
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml build
@echo "Bringing up the integration environment..."
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml up -d
@echo "Waiting 20s for integration containers to be ready..."
@sleep 20
@echo "Running additional setup for mssql integration tests"
@docker exec fidesops python tests/integration_tests/mssql_setup.py
@echo "Running pytest integration tests..."
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml \
run $(IMAGE_NAME) \
pytest $(pytestpath) -m integration
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml down --remove-orphans
pytest-integration-erasure: compose-build
@echo "Building additional Docker images for integration tests..."
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml build
@echo "Bringing up the integration environment..."
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml up -d
@echo "Waiting 20s for integration containers to be ready..."
@sleep 20
@echo "Running additional setup for mssql integration tests"
@docker exec fidesops python tests/integration_tests/mssql_setup.py
@echo "Running pytest integration tests..."
@docker-compose -f docker-compose.yml -f docker-compose.integration-test.yml \
run $(IMAGE_NAME) \
pytest $(pytestpath) -m "integration_erasure"
# These tests connect to external third-party test databases
pytest-integration-external: compose-build
@echo "Running tests that connect to external third party test databases"
@docker-compose run -e REDSHIFT_TEST_URI -e SNOWFLAKE_TEST_URI -e REDSHIFT_TEST_DB_SCHEMA $(IMAGE_NAME) \
pytest $(pytestpath) -m "integration_external"
####################
# Utils
####################
.PHONY: black
black: compose-build
@echo "Running black formatting against the src/ directory..."
@docker-compose run $(IMAGE_NAME) \
black src/
.PHONY: clean
clean:
@echo "Cleaning project temporary files and installed dependencies..."
@docker system prune -a --volumes
@echo "Clean complete!"
.PHONY: compose-build
compose-build:
@echo "Tearing down the docker compose images, network, etc..."
@docker-compose down --remove-orphans
@docker-compose build
.PHONY: teardown
teardown:
@echo "Tearing down the dev environment..."
@docker-compose down --remove-orphans
@echo "Teardown complete"
.PHONY: docs-build
docs-build: compose-build
@docker-compose run --rm $(IMAGE_NAME) \
python generate_openapi.py ./docs/fidesops/docs/api/openapi.json
.PHONY: docs-serve
docs-serve: docs-build
@docker-compose build docs
@docker-compose up docs