forked from dropbox/changes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
181 lines (146 loc) · 6.21 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
help:
@echo "Please use \`$(MAKE) <target>' where <target> is one of the following:"
@echo " setup-git optional git config & pre-commit hooks"
@echo " develop perform inital development setup"
@echo " install-requirements install basic deps (npm, bower, python)"
@echo " install-test-requirements install runtime + testing dependencies"
@echo " upgrade perform data migrations"
@echo " install-requirements (see above)"
@echo " migratedb migrate the database schema"
@echo " static update static assets (generate css, js)"
@echo " test run the unit tests"
@echo " lint inspect code for errors"
@echo " lint-js run jshint"
@echo " lint-python run flake8"
@echo " test-full run the full test suite and make a coverage report"
@echo " install-test-requirements (see above)"
@echo " lint (see above)"
@echo " coverage produce a coverage report"
@echo " resetdb drop and re-create the database"
@echo " dropdb drop the database"
@echo " createdb create an empty database"
@echo " migratedb migrate the database schema"
@echo " docker build and run in a Docker container"
@echo " docker-container build Docker container named '$(DOCKER_CONTAINER_NAME)'"
@echo " docker-image build Docker image named '$(DOCKER_IMAGE_NAME)'"
@echo " docker-browse connect via HTTP"
@echo " docker-browse-info display information about how to connect via HTTP"
@echo " docker-ssh connect via ssh"
@echo " docker-ssh-info display information about how to connect via ssh"
@echo " docker-destroy remove Docker container named '$(DOCKER_CONTAINER_NAME)'"
@echo " docker-destroy-image remove the Docker container, and image named '$(DOCKER_IMAGE_NAME)"
@echo "For help building documentation, run:"
@echo " $(MAKE) -C docs help"
# Works like "python setup.py develop"
develop: install-requirements install-test-requirements
upgrade: install-requirements
@# XXX: Can `migratedb' and `static' run in parallel?
$(MAKE) migratedb
$(MAKE) static
setup-git:
git config branch.autosetuprebase always
cd .git/hooks && ln -sf ../../hooks/* ./
install-requirements:
@# XXX: Can any of these run in parallel?
npm install
pip install pip==1.5.6
pip install -e . --use-mirrors --allow-external=argparse
install-test-requirements: install-requirements
# TODO(dcramer): we need an unreleased version due to https://github.com/spulec/moto/issues/91
pip install https://github.com/spulec/moto/archive/6e1196386f19b901cfedaa0dd2552e668149540b.zip
pip install "file://`pwd`#egg=changes[tests]" --use-mirrors
test: lint test-python test-js
test-python:
@echo "Running Python tests"
py.test tests
@echo ""
test-js:
@echo "Running JavaScript tests"
@npm run test
@echo ""
lint: lint-js lint-python
lint-python:
@echo "Linting Python files"
@PYFLAKES_NODOCTEST=1 flake8 changes tests
@echo ""
lint-js:
@echo "Linting JavaScript files"
@npm run lint
@echo ""
test-full: install-test-requirements
$(MAKE) lint
$(MAKE) coverage
@npm run test-ci
coverage:
coverage run -m py.test --junitxml=python.junit.xml tests
coverage xml
dropdb:
dropdb --if-exists changes
createdb:
createdb -E utf-8 changes
migratedb:
alembic upgrade head
resetdb:
$(MAKE) dropdb
$(MAKE) createdb
$(MAKE) migratedb
static:
npm run compile-static
# Debian/Ubuntu name collision on /usr/bin/docker
# - https://bugs.debian.org/740863
# - https://bugs.debian.org/748526
DOCKER ?= $(shell which docker.io || which docker)
# These should not be identical, or random commands will fail with
# "Error: Conflict between containers and images"
DOCKER_IMAGE_NAME ?= local/changes
DOCKER_CONTAINER_NAME ?= changes-dev
DOCKER_ENV_FILE ?= $(HOME)/.changes/changes.docker-env.conf
DOCKER_ENV_EXAMPLE_FILE ?= docs/examples/changes.docker-env.conf
$(DOCKER_ENV_FILE):
@echo "******************************************************************"
@echo "You need to configure $(DOCKER_ENV_FILE)"
@echo ""
@echo "Start here:"
@echo " cp -f docs/examples/changes.docker-env.conf $(DOCKER_ENV_FILE)"
@echo " $(or $(VISUAL),$(EDITOR),nano) $(DOCKER_ENV_FILE)"
@echo ""
@echo "Then run this command again"
@echo "******************************************************************"
@exit 1
docker-quickstart: $(DOCKER_ENV_FILE)
$(MAKE) docker
$(MAKE) docker-browse
$(MAKE) docker-ssh
docker: docker-container
$(MAKE) docker-info
docker-browse:
xdg-open $(shell $(MAKE) -s docker-browse-info) || open $(shell $(MAKE) -s docker-browse-info)
docker-browse-info:
@$(DOCKER) inspect --format='http://localhost:{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}/' $(DOCKER_CONTAINER_NAME)
docker-ssh:
$(shell $(MAKE) -s docker-ssh-info)
docker-ssh-info:
@# See http://docs.docker.io/reference/commandline/cli/ for examples of how to use --format
@$(DOCKER) inspect --format='ssh -p {{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}} root@{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostIp}}' $(DOCKER_CONTAINER_NAME)
docker-info:
@$(MAKE) -s docker-ssh-info
@$(MAKE) -s docker-browse-info
docker-container: docker-image $(DOCKER_ENV_FILE)
$(DOCKER) run --detach --env-file $(DOCKER_ENV_FILE) \
-p 127.0.0.1:5000:5000 -p 127.0.0.1::22 \
--name $(DOCKER_CONTAINER_NAME) \
$(DOCKER_IMAGE_NAME)
docker-image:
$(DOCKER) build -t $(DOCKER_IMAGE_NAME) .
docker-destroy: docker-destroy-container
@echo "Now run $(MAKE) docker-destroy-image if you also want to destroy the image"
docker-destroy-container:
-$(DOCKER) rm -f $(DOCKER_CONTAINER_NAME)
docker-destroy-image: docker-destroy-container
-$(DOCKER) rmi $(DOCKER_IMAGE_NAME)
# XXX(dlitz): We should have some real build products, too.
.PHONY: help develop upgrade setup-git \
install-requirements install-test-requirements \
test lint lint-python lint-js test-full coverage \
dropdb createdb migratedb resetdb static \
docker docker-container docker-image