-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (39 loc) · 1.87 KB
/
Makefile
File metadata and controls
49 lines (39 loc) · 1.87 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
SHELL = /bin/bash
.DEFAULT_GOAL := help
.PHONY: help build
# If the first argument is "run"...
ifeq (build,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
build: pre-commit-no-lint lint deploy-dev-db ## Run pre-commit and lint separately on files provided
.ONESHELL:
pre-commit: ## Run pre-commit on all files
pre-commit run --all-files
pre-commit-no-lint: ## Run pre-commit on all files, skipping sqlfluff-lint
SKIP=sqlfluff-lint pre-commit run --all-files
lint: ## Lint sql files
for i in $(RUN_ARGS) ; \
do echo echo $$i ; \
echo sqlfluff lint $$i; \
done | parallel -k -j 10 2>&1 | grep -v '^==='
lint-all: ## Lint all sql files
for i in macros/*.sql models/**/*.sql ; \
do echo echo $$i ; \
echo sqlfluff lint $$i; \
done | parallel -k -j 10 2>&1 | grep -v '^==='
deploy-dev-db: ## Deploys models to dev database
# try it 3 times in case of new incremental model with self reference
# use smart reruns later on when available
# https://github.com/dbt-labs/dbt-core/pull/4017
dbt run --target dev || dbt run --target dev || dbt run --target dev
deploy: ## Deploy models and manifests to Airflow GCS bucket
dbt compile
gsutil cp target/manifest.json gs://$$COMPOSER_BUCKET/dags/dbt/target/manifest.json
gsutil -m rsync -r -d -x '.*\.pyc$$|.git/.*|.github/.*|^dbt_modules/|^target/.*|^logs/.*|README.md' . gs://$$COMPOSER_BUCKET/dags/dbt
# gsutil -m rsync -r ./dbt_modules/dbt_utils/macros gs://$$COMPOSER_BUCKET/dags/dbt/dbt_modules/dbt_utils/macros
# gsutil cp ./dbt_modules/dbt_utils/dbt_project.yml gs://$$COMPOSER_BUCKET/dags/dbt/dbt_modules/dbt_utils/dbt_project.yml
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'