forked from meltano/meltano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
212 lines (165 loc) · 5.19 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
# General
# =======
#
# - `make` or `make build` initializes the project
# - Install node_modules needed by UI and API
# - Build static UI artifacts
# - Build all docker images needed for dev
# - `make test` runs pytest
# - `make clean` deletes all the build artifacts
# - `make docker_images` builds all the docker images including the production
# image
#
# To build and publish:
#
# > make sdist-public
# > poetry publish --build
ifdef DOCKER_REGISTRY
base_image_tag = ${DOCKER_REGISTRY}/meltano/meltano/base
prod_image_tag = ${DOCKER_REGISTRY}/meltano/meltano
else
base_image_tag = meltano/meltano/base
prod_image_tag = meltano/meltano
endif
DOCKER_RUN=docker run -it --rm -v $(shell pwd):/app -w /app
PYTHON_RUN=${DOCKER_RUN} --name python-$(shell uuidgen) python
DCR=docker-compose run --rm
DCRN=${DCR} --no-deps
MELTANO_WEBAPP = src/webapp
MELTANO_API = src/meltano/api
MELTANO_RELEASE_MARKER_FILE = ./src/meltano/core/tracking/.release_marker
.PHONY: build test clean docker_images release
build: ui api
test:
${DCRN} api poetry run pytest tests/
# pip related
TO_CLEAN = ./build ./dist
# built UI
TO_CLEAN += ./${MELTANO_API}/static/js
TO_CLEAN += ./${MELTANO_API}/static/css
TO_CLEAN += ./${MELTANO_WEBAPP}/dist
# release marker
TO_CLEAN += ${MELTANO_RELEASE_MARKER_FILE}
clean:
rm -rf ${TO_CLEAN}
docker_images: base_image prod_image
# Docker Image Related
# ====================
#
# - `make base_image` builds meltano/base
# - `make prod_image` builds meltano/meltano which is an all-in-one production
# image that includes the static ui artifacts in the image.
.PHONY: base_image prod_image
base_image:
docker build \
--file docker/base/Dockerfile \
-t $(base_image_tag) \
.
prod_image: base_image ui
docker build \
--file docker/main/Dockerfile \
-t $(prod_image_tag) \
--build-arg BASE_IMAGE=$(base_image_tag) \
.
# API Related
# ===========
#
# - `make api` assembles all the necessary dependencies to run the API
.PHONY: api
api: prod_image ${MELTANO_API}/node_modules
${MELTANO_API}/node_modules:
${DCRN} -w /meltano/${MELTANO_API} api yarn
# Packaging Related
# ===========
#
# - `make lock` pins dependency versions. We use Poetry to generate
# a lockfile.
lock:
poetry lock
bundle: clean ui
mkdir -p src/meltano/api/templates && \
cp src/webapp/dist/index.html src/meltano/api/templates/webapp.html && \
cp src/webapp/dist/index-embed.html src/meltano/api/templates/embed.html && \
cp -r src/webapp/dist/static/. src/meltano/api/static
freeze_db:
poetry run scripts/alembic_freeze.py
# sdist:
# Build the source distribution
# Note: plese use `sdist-public` for the actual release build
sdist: freeze_db bundle
poetry build
# sdist_public:
# Same as sdist, except add release marker before poetry build
# The release marker differentiates installations 'in the wild' versus inernal dev builds and tests
sdist_public: freeze_db bundle
touch src/meltano/core/tracking/.release_marker
poetry build
echo "Builds complete. You can now publish to PyPi using 'poetry publish'."
docker_sdist: base_image
docker run --rm -v `pwd`:/meltano ${base_image_tag} \
bash -c "make sdist" && \
bash -c "chmod 777 dist/*"
# UI Related Tasks
# =================
#
# - `make ui` assembles the necessary UI dependencies and builds the static UI
# artifacts to ui/dist
.PHONY: ui
ui:
cd src/webapp && yarn && yarn build
${MELTANO_WEBAPP}/node_modules: ${MELTANO_WEBAPP}/yarn.lock
cd ${MELTANO_WEBAPP} && yarn install --frozen-lockfile
# Docs Related Tasks
# ==================
#
.PHONY: makefile_docs docs_image docs_shell
docs_image: base_image
docker build \
--file docker/docs/Dockerfile \
-t meltano/docs_build \
.
docs_shell: docs_image
${DOCKER_RUN} -w /app/docs meltano/docs_build bash
docs/build: docs_image docs/source
${DOCKER_RUN} -w /app/docs meltano/docs_build make html
docs/serve: docs/build
${DOCKER_RUN} \
-w /app/docs \
-p 8080:8081 \
meltano/docs_build sphinx-serve -b build
# Lint Related Tasks
# ==================
#
.PHONY: lint show_lint
TOX_RUN = poetry run tox -e
ESLINT_RUN = cd ${MELTANO_WEBAPP} && yarn run lint
JSON_YML_VALIDATE = poetry run python src/meltano/core/utils/validate_json_schema.py
args = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
lint_python:
${JSON_YML_VALIDATE}
${TOX_RUN} fix -- $(call args)
lint_eslint: ${MELTANO_WEBAPP}/node_modules
${ESLINT_RUN} --fix
show_lint_python:
${TOX_RUN} lint -- $(call args)
show_lint_eslint: ${MELTANO_WEBAPP}/node_modules
${ESLINT_RUN}
lint: lint_python lint_eslint
show_lint: show_lint_python show_lint_eslint
# Makefile Related Tasks
# ======================
#
# - `make explain_makefile` will bring up a web server with this makefile annotated.
explain_makefile:
docker stop explain_makefile || echo 'booting server'
${DOCKER_RUN} --name explain_makefile -p 8081:8081 node ./Makefile_explain.sh
# Release
# =====================
# Note:
# - this code is old and may be stale.
# - process currently runs in CI
release:
git diff --quiet || { echo "Working directory is dirty, please commit or stash your changes."; exit 1; }
yes | poetry run changelog release --$(type)
git add CHANGELOG.md
poetry run bumpversion --tag --allow-dirty --new-version `poetry run changelog current` $(type)