forked from getsentry/sentry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
287 lines (235 loc) · 8.85 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
NPM_ROOT = ./node_modules
STATIC_DIR = src/sentry/static/sentry
DJANGO_VERSION := ">=1.6,<1.7"
ifneq "$(wildcard /usr/local/opt/libxmlsec1/lib)" ""
LDFLAGS += -L/usr/local/opt/libxmlsec1/lib
endif
ifneq "$(wildcard /usr/local/opt/openssl/lib)" ""
LDFLAGS += -L/usr/local/opt/openssl/lib
endif
PIP = LDFLAGS="$(LDFLAGS)" pip -q
develop-only: update-submodules install-brew install-python install-yarn
develop: setup-git develop-only
@echo ""
install-yarn:
@echo "--> Installing Node dependencies"
@hash yarn 2> /dev/null || (echo 'Cannot continue with JavaScript dependencies. Please install yarn before proceeding. For more information refer to https://yarnpkg.com/lang/en/docs/install/'; echo 'If you are on a mac run:'; echo ' brew install yarn'; exit 1)
# Use NODE_ENV=development so that yarn installs both dependencies + devDependencies
NODE_ENV=development yarn install --pure-lockfile
install-brew:
@hash brew 2> /dev/null && brew bundle || (echo '! Homebrew not found, skipping system dependencies.')
install-python:
# must be executed serialially
$(MAKE) install-python-base
$(MAKE) install-python-develop
install-python-base:
@echo "--> Installing Python dependencies"
$(PIP) install "setuptools>=0.9.8" "pip>=8.0.0"
# order matters here, base package must install first
$(PIP) install -e .
$(PIP) install "file://`pwd`#egg=sentry[dev]"
install-python-develop:
$(PIP) install "file://`pwd`#egg=sentry[dev,tests]"
install-python-tests:
$(PIP) install "file://`pwd`#egg=sentry[dev,tests,optional]"
dev-postgres: install-python
dev-docs:
$(PIP) install -r doc-requirements.txt
reset-db:
@echo "--> Dropping existing 'sentry' database"
dropdb sentry || true
@echo "--> Creating 'sentry' database"
createdb -E utf-8 sentry
@echo "--> Applying migrations"
sentry upgrade
setup-git:
@echo "--> Installing git hooks"
git config branch.autosetuprebase always
cd .git/hooks && ln -sf ../../config/hooks/* ./
@echo ""
build: locale
clean:
@echo "--> Cleaning static cache"
rm -rf dist/* static/dist/*
@echo "--> Cleaning integration docs cache"
rm -rf src/sentry/integration-docs
@echo "--> Cleaning pyc files"
find . -name "*.pyc" -delete
@echo "--> Cleaning python build artifacts"
rm -rf build/ dist/ src/sentry/assets.json
@echo ""
build-js-po:
mkdir -p build
SENTRY_EXTRACT_TRANSLATIONS=1 ./node_modules/.bin/webpack
locale: build-js-po
cd src/sentry && sentry django makemessages -i static -l en
./bin/merge-catalogs en
./bin/find-good-catalogs src/sentry/locale/catalogs.json
cd src/sentry && sentry django compilemessages
update-transifex: build-js-po
pip install -q transifex-client
cd src/sentry && sentry django makemessages -i static -l en
./bin/merge-catalogs en
tx push -s
tx pull -a
./bin/find-good-catalogs src/sentry/locale/catalogs.json
cd src/sentry && sentry django compilemessages
update-submodules:
@echo "--> Updating git submodules"
git submodule init
git submodule update
@echo ""
build-platform-assets:
@echo "--> Building platform assets"
sentry init
@echo "from sentry.utils.integrationdocs import sync_docs; sync_docs(quiet=True)" | sentry exec
test: develop lint test-js test-python test-cli
testloop: develop
pip install -q pytest-xdist
py.test tests -f
test-cli:
@echo "--> Testing CLI"
rm -rf test_cli
mkdir test_cli
cd test_cli && sentry init test_conf > /dev/null
cd test_cli && sentry --config=test_conf upgrade --traceback --noinput > /dev/null
cd test_cli && sentry --config=test_conf help 2>&1 | grep start > /dev/null
rm -r test_cli
@echo ""
test-js:
@echo "--> Building static assets"
@${NPM_ROOT}/.bin/webpack --profile --json > webpack-stats.json
@echo "--> Running JavaScript tests"
@npm run test-ci
@echo ""
# builds and creates percy snapshots
test-styleguide:
@echo "--> Building and snapshotting styleguide"
@npm run snapshot
@echo ""
test-python: build-platform-assets
@echo "--> Running Python tests"
py.test tests/integration tests/sentry --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" || exit 1
@echo ""
test-network:
@echo "--> Building platform assets"
sentry init
@echo "from sentry.utils.integrationdocs import sync_docs; sync_docs(quiet=True)" | sentry exec
@echo "--> Running network tests"
py.test tests/network --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml"
@echo ""
test-snuba:
@echo "--> Running snuba tests"
py.test tests/snuba --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml"
@echo ""
test-acceptance: build-platform-assets
@echo "--> Building static assets"
@${NPM_ROOT}/.bin/webpack --display errors-only
@echo "--> Running acceptance tests"
py.test tests/acceptance --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" --html="pytest.html"
@echo ""
lint: lint-python lint-js
lint-python:
@echo "--> Linting python"
bash -eo pipefail -c "bin/lint --python --parseable | tee flake8.pycodestyle.log"
@echo ""
lint-js:
@echo "--> Linting javascript"
bash -eo pipefail -c "bin/lint --js --parseable | tee eslint.checkstyle.xml"
@echo ""
scan-python:
@echo "--> Running Python vulnerability scanner"
python -m pip install -q safety
bin/scan
@echo ""
coverage: develop
$(MAKE) test-python
coverage html
publish:
python setup.py sdist bdist_wheel upload
extract-api-docs:
rm -rf api-docs/cache/*
cd api-docs; python generator.py
.PHONY: develop dev-postgres dev-docs setup-git build clean locale update-transifex update-submodules test testloop test-cli test-js test-styleguide test-python test-acceptance lint lint-python lint-js coverage publish scan-python
############################
# Halt, Travis stuff below #
############################
# Bases for all builds
travis-upgrade-pip:
python -m pip install -q "pip>=9,<10"
travis-setup-cassandra:
echo "create keyspace sentry with replication = {'class' : 'SimpleStrategy', 'replication_factor': 1};" | cqlsh --cqlversion=3.1.7
echo 'create table nodestore (key text primary key, value blob, flags int);' | cqlsh -k sentry --cqlversion=3.1.7
travis-install-python:
pip install -q Django${DJANGO_VERSION}
$(MAKE) travis-upgrade-pip
$(MAKE) install-python-base
$(MAKE) install-python-tests
python -m pip install -q codecov
travis-noop:
@echo "nothing to do here."
.PHONY: travis-upgrade-pip travis-setup-cassandra travis-install-python travis-noop
travis-install-sqlite: travis-install-python
travis-install-postgres: travis-install-python dev-postgres
psql -c 'create database sentry;' -U postgres
travis-install-mysql: travis-install-python
pip install -q mysqlclient
echo 'create database sentry;' | mysql -uroot
travis-install-acceptance: install-yarn travis-install-postgres
wget -N http://chromedriver.storage.googleapis.com/$(shell curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip -P ~/
unzip ~/chromedriver_linux64.zip -d ~/
rm ~/chromedriver_linux64.zip
chmod +x ~/chromedriver
mkdir -p ~/.bin
mv ~/chromedriver ~/.bin/
travis-install-network: travis-install-postgres
travis-install-snuba: travis-install-postgres
travis-install-js:
$(MAKE) travis-upgrade-pip
$(MAKE) travis-install-python install-yarn
travis-install-cli: travis-install-postgres
travis-install-dist:
$(MAKE) travis-upgrade-pip
$(MAKE) travis-install-python install-yarn
travis-install-django-18: travis-install-postgres
.PHONY: travis-install-sqlite travis-install-postgres travis-install-js travis-install-cli travis-install-dist
# Lint steps
travis-lint-sqlite: lint-python
travis-lint-postgres: lint-python
travis-lint-mysql: lint-python
travis-lint-acceptance: travis-noop
travis-lint-network: lint-python
travis-lint-snuba: lint-python
travis-lint-js: lint-js
travis-lint-cli: travis-noop
travis-lint-dist: travis-noop
travis-lint-django-18: travis-lint-postgres
.PHONY: travis-lint-sqlite travis-lint-postgres travis-lint-mysql travis-lint-js travis-lint-cli travis-lint-dist
# Test steps
travis-test-sqlite: test-python
travis-test-postgres: test-python
travis-test-mysql: test-python
travis-test-acceptance: test-acceptance
travis-test-network: test-network
travis-test-snuba: test-snuba
travis-test-js:
$(MAKE) test-js
$(MAKE) test-styleguide
travis-test-cli: test-cli
travis-test-dist:
SENTRY_BUILD=$(TRAVIS_COMMIT) SENTRY_LIGHT_BUILD=0 python setup.py sdist bdist_wheel
@ls -lh dist/
travis-test-django-18: travis-test-postgres
.PHONY: travis-test-sqlite travis-test-postgres travis-test-mysql travis-test-js travis-test-cli travis-test-dist
# Scan steps
travis-scan-sqlite: scan-python
travis-scan-postgres: scan-python
travis-scan-mysql: scan-python
travis-scan-acceptance: travis-noop
travis-scan-network: travis-noop
travis-scan-snuba: scan-python
travis-scan-js: travis-noop
travis-scan-cli: travis-noop
travis-scan-dist: travis-noop
travis-scan-django-18: travis-noop
.PHONY: travis-scan-sqlite travis-scan-postgres travis-scan-mysql travis-scan-acceptance travis-scan-network travis-scan-snuba travis-scan-js travis-scan-cli travis-scan-dist travis-scan-django-18