-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
122 lines (102 loc) · 4.22 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
.PHONY: help
help:
@echo "make help Show this help message"
@echo "make dev Run the app in the development server"
@echo "make lint Run the code linter(s) and print any warnings"
@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 functests Run the functional tests"
@echo "make coverage Print the unit test coverage report"
@echo "make sure Make sure that the formatter, linter, tests, etc all pass"
@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 the Docker image "
@echo " locally in production mode. It assumes that h's Elasticsearch "
@echo " service is being run using docker-compose in the 'h_default' "
@echo " network."
.PHONY: dev
dev: node_modules/.uptodate python
@tox -qe dev
.PHONY: lint
lint: backend-lint frontend-lint
.PHONY: backend-lint
backend-lint: python
@tox -qe lint
.PHONY: frontend-lint
frontend-lint: node_modules/.uptodate
@./node_modules/.bin/eslint bouncer/scripts
.PHONY: format
format: python
@tox -qe format
.PHONY: checkformatting
checkformatting: python
@tox -qe checkformatting
.PHONY: test
test: backend-test frontend-test
.PHONY: functests
functests: python
@tox -qe functests
.PHONY: backend-test
backend-test: python
@tox -q
.PHONY: frontend-test
frontend-test: node_modules/.uptodate
@./node_modules/karma/bin/karma start karma.config.js
.PHONY: coverage
coverage: python
@tox -qe coverage
# Tell make how to compile requirements/*.txt files.
#
# `touch` is used to pre-create an empty requirements/%.txt file if none
# exists, otherwise tox crashes.
#
# $(subst) is used because in the special case of making requirements.txt we
# actually need to touch dev.txt not requirements.txt and we need to run
# `tox -e dev ...` not `tox -e requirements ...`
#
# $(basename $(notdir $@))) gets just the environment name from the
# requirements/%.txt filename, for example requirements/foo.txt -> foo.
requirements/%.txt: requirements/%.in
@touch -a $(subst requirements.txt,dev.txt,$@)
@tox -qe $(subst requirements,dev,$(basename $(notdir $@))) --run-command 'pip --quiet --disable-pip-version-check install pip-tools'
@tox -qe $(subst requirements,dev,$(basename $(notdir $@))) --run-command 'pip-compile --allow-unsafe --quiet $(args) $<'
# Inform make of the dependencies between our requirements files so that it
# knows what order to re-compile them in and knows to re-compile a file if a
# file that it depends on has been changed.
requirements/dev.txt: requirements/requirements.txt
requirements/tests.txt: requirements/requirements.txt
requirements/functests.txt: requirements/requirements.txt
requirements/lint.txt: requirements/tests.txt requirements/functests.txt
# Add a requirements target so you can just run `make requirements` to
# re-compile *all* the requirements files at once.
#
# This needs to be able to re-create requirements/*.txt files that don't exist
# yet or that have been deleted so it can't just depend on all the
# requirements/*.txt files that exist on disk $(wildcard requirements/*.txt).
#
# Instead we generate the list of requirements/*.txt files by getting all the
# requirements/*.in files from disk ($(wildcard requirements/*.in)) and replace
# the .in's with .txt's.
.PHONY: requirements requirements/
requirements requirements/: $(foreach file,$(wildcard requirements/*.in),$(basename $(file)).txt)
.PHONY: sure
sure: checkformatting lint test coverage functests
.PHONY: docker
docker:
@git archive --format=tar.gz HEAD | docker build -t hypothesis/bouncer:$(DOCKER_TAG) -
.PHONY: run-docker
run-docker:
@docker run \
--net h_default \
-e "ELASTICSEARCH_URL=http://elasticsearch:9200" \
-p 8000:8000 \
hypothesis/bouncer:$(DOCKER_TAG)
.PHONY: python
python:
@./bin/install-python
DOCKER_TAG = dev
node_modules/.uptodate: package.json
@echo installing javascript dependencies
@node_modules/.bin/check-dependencies 2>/dev/null || npm install
@touch $@