-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
248 lines (213 loc) · 5.74 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
SHELL=/bin/bash
LAST_TAG_COMMIT = $(shell git rev-list --tags --max-count=1)
LAST_TAG = $(shell git describe --tags $(LAST_TAG_COMMIT) )
TAG_PREFIX = "v"
VERSION != grep -oP '^v\K(.+)$$' VERSION
include .env
git_user != git config user.name
nsname=http://$(NS_DOMAIN)/\#$(NAME)
title != echo $(TITLE)
include inc/*
.PHONY: default
default: clean compile-main build
build: deploy/$(NAME).xar
@echo '##[ $@ ]##'
@bin/xQdeploy $<
@bin/semVer $(VERSION) patch > VERSION
@#touch unit-tests/t-$(NAME).xqm
@echo -n 'INFO: prepped for next build: ' && cat VERSION
.PHONY: test
test: compile-test
@prove -v bin/xQtest
.PHONY: clean
clean:
@rm -rfv tmp &>/dev/null
@rm -rfv build &>/dev/null
@rm -rfv deploy &>/dev/null
.PHONY: up
up: clean
@echo -e '##[ $@ ]##'
@bin/exStartUp
@touch VERSION && echo 'v0.0.1' > VERSION
.PHONY: down
down:
@echo -e '##[ $@ ]##'
@docker-compose down
.PHONY: compile-main
compile-main: content/${NAME}.xqm
@echo '##[ $@ $< ]##'
@mkdir -p tmp
@bin/xQcompile $<
.PHONY: compile-test
compile-test: unit-tests/t-${NAME}.xqm
@#' that will not compile unless ${NAME}.xqm is deployed '
@echo '##[ $@ $< ]##'
@mkdir -p tmp
@bin/xQcompile $< | grep -oP '^INFO:(.+)OK!$$' \
|| ( bin/xQcompile $< ; false )
build/repo.xml: export repoXML:=$(repoXML)
build/repo.xml:
@echo '##[ $@ ]##'
@echo "$${repoXML}"
@mkdir -p $(dir $@)
@echo "$${repoXML}" > $@
build/expath-pkg.xml: export expathPkgXML:=$(expathPkgXML)
build/expath-pkg.xml:
@echo '##[ $@ ]##'
@echo "$${expathPkgXML}"
@mkdir -p $(dir $@)
@echo "$${expathPkgXML}" > $@
build/content/$(NAME).xqm: content/$(NAME).xqm
@echo '##[ $@ ]##'
@mkdir -p $(dir $@)
@cp $< $@
deploy/$(NAME).xar: \
build/repo.xml \
build/expath-pkg.xml \
build/content/$(NAME).xqm
@echo '##[ $@ ]## '
@mkdir -p $(dir $@)
@cd build && zip $(abspath $@) -r .
.PHONY: prep-release
prep-release:
@echo '##[ $@ ]##'
@echo ' - working VERSION: $(VERSION) '
@echo ' - last tag: $(LAST_TAG)'
@if [ -z '$(LAST_TAG)' ] ; \
then echo 'v0.0.0' > VERSION ; \
else echo '$(LAST_TAG)' > VERSION ; fi
@bin/semVer $$(< ./VERSION) patch > VERSION
@echo " - bumped VERSION: $$(< ./VERSION) "
@echo ' - do a build from the bumped version'
@$(MAKE) --silent
@echo -n ' - expath-pkg version: '
@grep -oP 'version="\K((\d+\.){2}\d+)' build/expath-pkg.xml
.PHONY: release
release:
@git tag v$$(grep -oP 'version="\K((\d+\.){2}\d+)' build/expath-pkg.xml)
@git push origin v$$(grep -oP 'version="\K((\d+\.){2}\d+)' build/expath-pkg.xml)
.PHONY: log
log:
@docker logs -f --since 1m $(CONTAINER)
.PHONY: travis-enable
travis-enable:
@echo '##[ $@ ]##'
@travis enable
# https://docs.travis-ci.com/user/deployment/releases
.PHONY: travis-setup-releases
travis-setup-releases:
@echo '##[ $@ ]##'
@travis setup releases
.PHONY: gitLog
gitLog:
@clear
@git --no-pager log \
-n 10\
--pretty=format:'%Cred%h%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
.PHONY: smoke
smoke:
@echo '##[ $@ ]##'
@bin/xQcall 'csv:example()' \
| grep -oP '^(\d{4}(.+))|(.+\.\d{2})|(\s+)$$'
.PHONY: coverage
coverage:
@echo '##[ $@ ]##'
@bin/xQcall 'system:clear-trace()' &>/dev/null
@bin/xQcall 'system:enable-tracing(true())' &>/dev/null
@bin/xQcall 'csv:example()' &>/dev/null
@bin/xQcall 'system:enable-tracing(false())' &>/dev/null
@bin/xQtrace
.PHONY: guide
guide:
@echo '##[ $@ ]##'
@bin/xQguide
.PHONY: rec
rec:
@mkdir ../tmp
@asciinema rec ../tmp/csv.cast \
--overwrite \
--title='grantmacken/csv ran `make up'\
--idle-time-limit 1 \
--command='nvim'
.PHONY: rec-example
rec-example:
@mkdir -p ../tmp
@clear
@asciinema rec ../tmp/csv.cast \
--overwrite \
--title="grantmacken/csv called 'csv:example()'" \
--command="\
sleep 1 && printf %60s | tr ' ' '=' && echo && \
echo ' - given this csv file ... ' && \
sleep 1 && printf %60s | tr ' ' '-' && echo && \
cat unit-tests/fixtures/2018-12.csv && \
sleep 1 && printf %60s | tr ' ' '-' && echo && \
echo ' - when we provide mapped key-values ..' && \
sleep 1 && printf %60s | tr ' ' '-' && echo && \
echo 'map {\"href\" : \"/db/unit-tests/fixtures/2018-12.csv\", ' && \
echo ' \"header-line\": 6,' && \
echo ' \"record-start\": 8,' && \
echo ' \"separator\": \",\"}' && \
sleep 1 && printf %60s | tr ' ' '-' && echo && \
echo ' - then calling csv:example function results in... ' && \
sleep 1 && printf %60s | tr ' ' '-' && echo && \
bin/xQcall 'csv:example()' && \
sleep 1 && printf %60s | tr ' ' '-' && echo && \
sleep 1 && printf %60s | tr ' ' '=' && echo\
"
.PHONY: rec-up
rec-up:
@asciinema rec tmp/csv.cast \
--overwrite \
--title='grantmacken/csv ran `make up'\
--command='make up'
.PHONY: rec-build
rec-build:
@clear
@asciinema rec tmp/csv.cast \
--overwrite \
--title='grantmacken/csv ran `make'\
--command='make'
.PHONY: rec-test
rec-test:
@clear
@asciinema rec tmp/csv.cast \
--overwrite \
--title='grantmacken/csv ran `make test'\
--command='make test'
.PHONY: rec-smoke
rec-smoke:
@clear
@asciinema rec tmp/csv.cast \
--overwrite \
--title='grantmacken/csv ran `make smoke'\
--command='make smoke'
.PHONY: rec-cov
rec-cov:
@clear
@asciinema rec tmp/csv.cast \
--overwrite \
--title='grantmacken/csv ran `make coverage'\
--command='make coverage'
.PHONY: rec-guide
rec-guide:
@clear
@asciinema rec tmp/csv.cast \
--overwrite \
--title='grantmacken/csv ran `make guide'\
--command='make guide'
.PHONY: rec-test-all
rec-test-all:
asciinema rec tmp/csv.cast \
--overwrite \
--title='grantmacken/csv run `make test && make smoke && make coverage and make guide`'\
--command='make test --silent && \
make smoke --silent && \
make coverage --silent && \
make guide --silent'
PHONY: play
play:
@clear && asciinema play ../tmp/csv.cast
.PHONY: upload
upload:
asciinema upload ../tmp/csv.cast