-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
60 lines (47 loc) · 1.13 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
#
# Providence
# Makefile
#
.PHONY := all fmt lint
.DEFAULT_GOAL := all
define PHONY_RULE
.PHONY += $(1)-$(2)
$(1): $(1)-$(2)
endef
define PYTHON_RULES
$(eval $(call PHONY_RULE,fmt,$(1)))
fmt-$(1): $(2)
black $$<
$(eval $(call PHONY_RULE,lint,$(1)))
lint-$(1): $(2)
black --check $$<
$(eval $(call PHONY_RULE,test,$(1)))
test-$(1): $(2)
cd $$< && pytest
endef
all: deps fmt lint build test
# DBT transform
DBT_DIR := transforms/dbt
DBT_TARGET := dev
$(eval $(call PHONY_RULE,deps,dbt))
deps-dbt: $(DBT_DIR)
cd $< && pip install -r requirements-dev.txt
cd $< && dbt deps
$(eval $(call PHONY_RULE,fmt,dbt))
fmt-dbt: $(DBT_DIR)
cd $< && sqlfluff fix -f .
cd $< && sqlfmt .
$(eval $(call PHONY_RULE,lint,dbt))
lint-dbt: $(DBT_DIR)
cd $< && sqlfluff lint .
cd $< && sqlfmt --check .
$(eval $(call PHONY_RULE,build,dbt))
build-dbt: $(DBT_DIR)
cd $< && dbt build --target $(DBT_TARGET)
# Prefect Pipelines
PIPELINES_DIR := pipelines
$(eval $(call PYTHON_RULES,pipelines,$(PIPELINES_DIR)))
$(eval $(call PHONY_RULE,deps,pipelines))
deps-pipelines: $(PIPELINES_DIR)
cd $< && pip install -r requirements-dev.txt
cd $(DBT_DIR) && dbt deps