-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
305 lines (194 loc) · 7.01 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/usr/bin/make -f
DOCKER_COMPOSE_DEV = docker-compose
DOCKER_COMPOSE_CI = docker-compose -f docker-compose.yml -f docker-compose.ci.yml
DOCKER_COMPOSE = $(DOCKER_COMPOSE_DEV)
VENV = venv
PIP = $(VENV)/bin/pip
PYTHON = $(VENV)/bin/python
DOCKER_PROJECT_HOME = /opt/bigquery-views-manager
RUN_DEV = $(DOCKER_COMPOSE) run --rm \
--entrypoint "" \
--workdir "$(DOCKER_PROJECT_HOME)" \
bigquery-views-manager
GOOGLE_CLOUD_PROJECT = bigquery-views-manager
BIGQUERY_VIEWS_MANAGER_CLI_DOCKER = $(RUN_DEV) python -m bigquery_views_manager.cli
BIGQUERY_VIEWS_MANAGER_CLI_VENV = GOOGLE_CLOUD_PROJECT=$(GOOGLE_CLOUD_PROJECT) \
$(PYTHON) -m bigquery_views_manager.cli
BIGQUERY_VIEWS_MANAGER_CLI = $(BIGQUERY_VIEWS_MANAGER_CLI_DOCKER)
ARGS =
.require-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
venv-clean:
@if [ -d "$(VENV)" ]; then \
rm -rf "$(VENV)"; \
fi
venv-create:
python3 -m venv $(VENV)
venv-link:
ln -s $(VENV) venv
dev-install:
$(PIP) install --disable-pip-version-check -r requirements.build.txt
$(PIP) install --disable-pip-version-check -r requirements.txt
$(PIP) install --disable-pip-version-check -r requirements.dev.txt
dev-venv: venv-create dev-install
dev-flake8:
$(PYTHON) -m flake8 bigquery_views_manager tests
dev-pylint:
$(PYTHON) -m pylint bigquery_views_manager tests
dev-lint: dev-flake8 dev-pylint
dev-pytest:
$(PYTHON) -m pytest -p no:cacheprovider $(ARGS)
dev-watch:
$(PYTHON) -m pytest_watch --verbose -- -p no:cacheprovider -k 'not slow' $(ARGS)
dev-watch-slow:
$(PYTHON) -m pytest_watch --verbose -- -p no:cacheprovider $(ARGS)
dev-test: dev-lint dev-pytest
dev-example-data-clean-dataset-config-data:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-clean-dataset-config-data
dev-example-data-clean-dataset-views:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-clean-dataset-views
dev-example-data-clean-dataset-materialized-tables:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-clean-dataset-materialized-tables
dev-example-data-clean-dataset:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-clean-dataset
dev-example-data-update-dataset-config-data:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-update-dataset-config-data
dev-example-data-update-dataset-views-and-materialize:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-update-dataset-views-and-materialize
dev-example-data-materialize-views:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-materialize-views
dev-example-data-diff-views:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-diff-views
dev-example-data-get-view:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-get-view
dev-example-data-get-all-views:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-get-all-views
dev-example-data-sort-view-list:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-sort-view-list
dev-example-data-update-dataset:
$(MAKE) BIGQUERY_VIEWS_MANAGER_CLI="$(BIGQUERY_VIEWS_MANAGER_CLI_VENV)" \
example-data-update-dataset
.PHONY: build
build:
$(DOCKER_COMPOSE) build venv bigquery-views-manager
build-dev: build
# currently there is no separate dev image
flake8:
$(RUN_DEV) flake8 bigquery_views_manager tests
pylint:
$(RUN_DEV) pylint bigquery_views_manager tests
lint: flake8 pylint
pytest:
$(RUN_DEV) pytest
test: lint pytest
views-manager-cli:
$(RUN_DEV) python -m bigquery_views_manager.cli \
$(ARGS)
example-data-clean-dataset-config-data: .require-DATASET_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
delete-config-tables \
--dataset=$(DATASET_NAME) \
--config-tables-base-dir=./example-data/config-tables
example-data-clean-dataset-views: .require-DATASET_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
delete-views \
--dataset=$(DATASET_NAME) \
--view-list-config=./example-data/views/views.yml
example-data-clean-dataset-materialized-tables: .require-DATASET_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
delete-materialized-tables \
--dataset=$(DATASET_NAME) \
--view-list-config=./example-data/views/views.yml
example-data-clean-dataset: \
example-data-clean-dataset-views \
example-data-clean-dataset-materialized-tables \
example-data-clean-dataset-config-data
example-data-update-dataset-config-data: .require-DATASET_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
create-or-replace-config-tables \
--dataset=$(DATASET_NAME) \
--config-tables-base-dir=./example-data/config-tables \
$(ARGS)
example-data-update-dataset-views-and-materialize: .require-DATASET_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
create-or-replace-views \
--dataset=$(DATASET_NAME) \
--view-list-config=./example-data/views/views.yml \
--materialize \
$(ARGS)
example-data-materialize-views: .require-DATASET_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
materialize-views \
--dataset=$(DATASET_NAME) \
--view-list-config=./example-data/views/views.yml \
$(ARGS)
example-data-diff-views: .require-DATASET_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
diff-views \
--dataset=$(DATASET_NAME) \
--view-list-config=./example-data/views/views.yml \
$(ARGS)
example-data-get-view: .require-DATASET_NAME .require-VIEW_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
get-views \
--dataset=$(DATASET_NAME) \
--view-list-config=./example-data/views/views.yml \
$(VIEW_NAME) \
$(ARGS)
example-data-get-all-views: .require-DATASET_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
get-views \
--dataset=$(DATASET_NAME) \
--view-list-config=./example-data/views/views.yml \
$(ARGS)
example-data-sort-view-list: .require-DATASET_NAME
$(BIGQUERY_VIEWS_MANAGER_CLI) \
sort-view-list \
--dataset=$(DATASET_NAME) \
--view-list-config=./example-data/views/views.yml \
$(ARGS)
example-data-update-dataset: \
example-data-update-dataset-config-data \
example-data-update-dataset-views-and-materialize
ci-build-and-test:
make DOCKER_COMPOSE="$(DOCKER_COMPOSE_CI)" \
build \
build-dev \
test
ci-views-manager-cli:
make DOCKER_COMPOSE="$(DOCKER_COMPOSE_CI)" \
views-manager-cli
ci-example-data-clean-dataset: .require-DATASET_NAME
make DOCKER_COMPOSE="$(DOCKER_COMPOSE_CI)" \
example-data-clean-dataset
ci-example-data-update-dataset: .require-DATASET_NAME
make DOCKER_COMPOSE="$(DOCKER_COMPOSE_CI)" \
example-data-update-dataset
ci-push-testpypi: .require-COMMIT
$(DOCKER_COMPOSE_CI) run --rm \
--entrypoint "" \
--workdir "$(DOCKER_PROJECT_HOME)" \
bigquery-views-manager \
./docker/push-testpypi-commit-version.sh "$(COMMIT)"
ci-push-pypi: .require-VERSION
$(DOCKER_COMPOSE_CI) run --rm \
--entrypoint "" \
--workdir "$(DOCKER_PROJECT_HOME)" \
bigquery-views-manager \
./docker/push-pypi-version.sh "$(VERSION)"
ci-clean:
docker-compose down -v