forked from isso-comments/isso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
150 lines (110 loc) · 4.56 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
# INSTALLATION:
# Docs:
# pip install sphinx
# apt install sassc
# Python unit tests:
# pip install pytest pytest-cov
# Javascript frontend client:
# make init
ISSO_JS_SRC := $(shell find isso/js/app -type f) \
$(shell ls isso/js/*.js | grep -vE "(min|dev)")
ISSO_JS_DST := isso/js/embed.min.js isso/js/embed.dev.js \
isso/js/count.min.js isso/js/count.dev.js \
isso/js/count.dev.js.map isso/js/embed.dev.js.map
ISSO_PY_SRC := $(shell find isso/ | grep -E '^isso/.+.py$$')
DOCS_RST_SRC := $(shell find docs/ -type f -name '*.rst') \
$(wildcard docs/_theme/*) \
docs/index.html docs/conf.py docs/docutils.conf \
$(shell find docs/_extensions/)
DOCS_CSS_SRC := docs/_static/css/site.scss
DOCS_CSS_DEP := $(shell find docs/_static/css/neat -type f) \
$(shell find docs/_static/css/bourbon -type f)
DOCS_CSS_DST := docs/_static/css/site.css
DOCS_HTML_DST := docs/_build/html
APIDOC_SRC := apidoc/apidoc.json apidoc/header.md apidoc/footer.md apidoc/_apidoc.js
APIDOC_DST := apidoc/_output
APIDOC = npx --no-install apidoc
SASS = sassc
TESTBED_IMAGE ?= isso-js-testbed:latest
all: js site
init:
npm install --no-optional
flakes:
flake8 isso/ contrib/ --count --max-line-length=127 --show-source --statistics
# Note: It doesn't make sense to split up configs by output file with
# webpack, just run everything at once
isso/js/embed.min.js: $(ISSO_JS_SRC)
npm run build-prod
isso/js/count.min.js: isso/js/embed.min.js
isso/js/embed.dev.js: $(ISSO_JS_SRC)
npm run build-dev
isso/js/count.dev.js: isso/js/embed.dev.js
# Note: No need to depend on css sources since they are no longer inlined
js: $(ISSO_JS_DST)
css: $(DOCS_CSS_DST)
${DOCS_CSS_DST}: $(DOCS_CSS_SRC) $(DOCS_CSS_DEP)
$(SASS) $(DOCS_CSS_SRC) $@
# Sphinx: "-W" flag turns warnings into errors, can be disabled for debugging
${DOCS_HTML_DST}: $(DOCS_RST_SRC) $(DOCS_CSS_DST)
sphinx-build -b dirhtml -W docs/ $@
site: $(DOCS_HTML_DST)
# Generate docs using apiDoc. Config inside apidoc.json
# https://apidocjs.com/
apidoc-init:
npm install apidoc
apidoc: $(ISSO_PY_SRC) $(APIDOC_SRC)
$(APIDOC) --config apidoc/apidoc.json \
--input isso/views/ --input apidoc/ \
--output $(APIDOC_DST) --private
cp -rT $(APIDOC_DST) $(DOCS_HTML_DST)/docs/api/
coverage: $(ISSO_PY_SRC)
coverage run --omit='*/tests/*' --source isso -m pytest
coverage report --omit='*/tests/*'
test: $($ISSO_PY_SRC)
PYTHONPATH=. pytest --doctest-modules isso/
docker:
DOCKER_BUILDKIT=1 docker build -t isso:latest .
docker-push:
docker tag isso:latest ghcr.io/isso-comments/isso:dev
docker push ghcr.io/isso-comments/isso:dev
docker-testbed:
docker build -f docker/Dockerfile-js-testbed -t isso-js-testbed .
docker-testbed-push:
docker tag isso-js-testbed:latest ghcr.io/isso-comments/isso-js-testbed:latest
docker push ghcr.io/isso-comments/isso-js-testbed:latest
docker-js-unit:
docker run \
--mount type=bind,source=$(PWD)/package.json,target=/src/package.json,readonly \
--mount type=bind,source=$(PWD)/isso/js/,target=/src/isso/js/,readonly \
$(TESTBED_IMAGE) npm run test-unit
docker-js-integration:
docker run \
--mount type=bind,source=$(PWD)/package.json,target=/src/package.json,readonly \
--mount type=bind,source=$(PWD)/isso/js/,target=/src/isso/js/ \
--env ISSO_ENDPOINT='http://isso-dev.local:8080' \
--network container:isso-server \
$(TESTBED_IMAGE) npm run test-integration
docker-generate-screenshots:
docker run \
--mount type=bind,source=$(PWD)/package.json,target=/src/package.json,readonly \
--mount type=bind,source=$(PWD)/isso/js/,target=/src/isso/js/ \
--network container:isso-server \
--env ISSO_ENDPOINT='http://isso-dev.local:8080' \
$(TESTBED_IMAGE) npm run test-screenshots
docker-compare-screenshots: docker-generate-screenshots
docker run \
--mount type=bind,source=$(PWD)/package.json,target=/src/package.json,readonly \
--mount type=bind,source=$(PWD)/isso/js/,target=/src/isso/js/ \
$(TESTBED_IMAGE) bash isso/js/tests/screenshots/compare-hashes.sh
docker-update-screenshots: docker-generate-screenshots
docker run \
--mount type=bind,source=$(PWD)/package.json,target=/src/package.json,readonly \
--mount type=bind,source=$(PWD)/isso/js/,target=/src/isso/js/ \
$(TESTBED_IMAGE) bash isso/js/tests/screenshots/compare-hashes.sh -u
clean:
rm -f $(ISSO_JS_DST)
rm -rf $(DOCS_HTML_DST)
rm -rf $(APIDOC_DST)
rm -rf .pytest_cache/
rm -rf .coverage
.PHONY: apidoc apidoc-init clean coverage docker docker-compare-screenshots docker-generate-screenshots docker-update-screenshots docker-js-unit docker-js-integration docker-push docker-testbed docker-testbed-push init test