forked from hypothesis/h
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
186 lines (154 loc) · 5.76 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
.PHONY: help
help:
@echo "make help Show this help message"
@echo 'make services Run the services that `make dev` requires'
@echo " (Postgres, Elasticsearch, etc) in Docker Compose"
@echo 'make db Upgrade the DB schema to the latest version'
@echo "make dev Run the app in the development server"
@echo "make devdata Upsert standard development data into the DB, and set"
@echo " standard environment variables for a development"
@echo " environment"
@echo "make shell Launch a Python shell in the dev environment"
@echo "make sql Connect to the dev database with a psql shell"
@echo "make lint Run the code linter(s) and print any warnings"
@echo "make analyze Slower and more thorough code quality analysis (pylint)"
@echo "make format Correctly format the code"
@echo "make checkformatting Crash if the code isn't correctly formatted"
@echo "make test Run the unit tests"
@echo "make coverage Print the unit test coverage report"
@echo "make functests Run the functional tests"
@echo "make docs Build docs website and serve it locally"
@echo "make checkdocs Crash if building the docs website fails"
@echo "make sure Make sure that the formatter, linter, tests, etc all pass"
@echo "make pip-compile Compile requirements.in to requirements.txt."
@echo " Use this command after editing requirements.in, for"
@echo " example after adding or removing a requirement."
@echo "make upgrade-package Upgrade the version of a package in requirements.txt."
@echo ' Usage: `make upgrade-package name=some-package`.'
@echo "make docker Make the app's Docker image"
@echo "make run-docker Run the app's Docker image locally. "
@echo " This command exists for conveniently testing "
@echo " the Docker image locally in production mode. "
@echo " It assumes the services are being run using "
@echo " docker-compose in the 'h_default' network."
@echo "make clean Delete development artefacts (cached files, "
@echo " dependencies, etc)"
.PHONY: services
services: args?=up -d
services: python
@tox -qe docker-compose -- $(args)
.PHONY: db
db: args?=upgrade head
db: python
@tox -qqe dev --run-command 'sh bin/hypothesis --dev init'
@tox -qe dev --run-command 'sh bin/hypothesis --dev migrate $(args)'
.PHONY: dev
dev: build/manifest.json python
@tox -qe dev
.PHONY: devssl
devssl: export H_GUNICORN_CERTFILE=.tlscert.pem
devssl: export H_GUNICORN_KEYFILE=.tlskey.pem
devssl: export APP_URL=https://localhost:5000
devssl: export WEBSOCKET_URL=wss://localhost:5001/ws
devssl: build/manifest.json python
@tox -qe dev
.PHONY: devdata
devdata: python
@tox -qe dev -- sh bin/hypothesis --dev devdata
.PHONY: shell
shell: python
@tox -qe dev -- sh bin/hypothesis --dev shell
.PHONY: sql
sql: python
@tox -qe docker-compose -- exec postgres psql --pset expanded=auto -U postgres
.PHONY: lint
lint: backend-lint frontend-lint
.PHONY: backend-lint
backend-lint: python
@tox -qe lint
.PHONY: frontend-lint
frontend-lint: node_modules/.uptodate
@npm run-script lint
.PHONY: analyze
analyze: python
@tox -qe analyze
.PHONY: format
format: python
@tox -qe format
PHONY: checkformatting
checkformatting: backend-checkformatting frontend-checkformatting
.PHONY: backend-checkformatting
backend-checkformatting: python
@tox -qe checkformatting
.PHONY: frontend-checkformatting
frontend-checkformatting: node_modules/.uptodate
@npm run-script checkformatting
.PHONY: test
test: node_modules/.uptodate python
@tox -q
@$(GULP) test
.PHONY: coverage
coverage: python
@tox -qe coverage
.PHONY: functests
functests: build/manifest.json python
@tox -qe functests
.PHONY: docs
docs: python
@tox -qe docs
.PHONY: checkdocs
checkdocs: python
@tox -qe checkdocs
.PHONY: sure
sure: checkformatting lint test coverage functests
.PHONY: pip-compile
pip-compile: python
@tox -qe pip-compile
.PHONY: upgrade-package
upgrade-package: python
@tox -qe pip-compile -- --upgrade-package $(name)
.PHONY: docker
docker:
@git archive --format=tar.gz HEAD | docker build -t hypothesis/hypothesis:$(DOCKER_TAG) -
.PHONY: run-docker
run-docker:
# To use the local client with the Docker container, you must run the service,
# navigate to /admin/oauthclients and register an "authorization_code" OAuth
# client, then restart the service with the `CLIENT_OAUTH_ID` environment
# variable set.
#
# If you don't intend to use the client with the container, you can skip this.
@docker run \
--net h_default \
-e "APP_URL=http://localhost:5000" \
-e "AUTHORITY=localhost" \
-e "BROKER_URL=amqp://guest:guest@rabbit:5672//" \
-e "CLIENT_OAUTH_ID" \
-e "CLIENT_URL=http://localhost:3001/hypothesis" \
-e "DATABASE_URL=postgresql://postgres@postgres/postgres" \
-e "ELASTICSEARCH_URL=http://elasticsearch:9200" \
-e "NEW_RELIC_APP_NAME=h (dev)" \
-e "NEW_RELIC_LICENSE_KEY" \
-e "SECRET_KEY=notasecret" \
-p 5000:5000 \
hypothesis/hypothesis:$(DOCKER_TAG)
.PHONY: clean
clean:
@find . -type f -name "*.py[co]" -delete
@find . -type d -name "__pycache__" -delete
@rm -f node_modules/.uptodate
@rm -rf build
DOCKER_TAG = dev
GULP := node_modules/.bin/gulp
build/manifest.json: node_modules/.uptodate
@$(GULP) build
node_modules/.uptodate: package.json
@echo installing javascript dependencies
@node_modules/.bin/check-dependencies 2>/dev/null || npm install
@touch $@
.PHONY: python
python:
@./bin/install-python
.PHONY: gulp
gulp: node_modules/.uptodate
@$(GULP) $(args)