forked from for-GET/jesse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
186 lines (144 loc) · 4.57 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
# See LICENSE for licensing information.
CHMOD := $(shell command -v chmod 2>/dev/null)
CURL := $(shell command -v curl 2>/dev/null)
LN := $(shell command -v ln 2>/dev/null)
OTP_RELEASE = $(shell erl -eval 'io:format("~s", [erlang:system_info(otp_release)]), halt().' -noshell)
ifdef CI
REBAR3 = ./rebar3.OTP$(OTP_RELEASE)
else
REBAR3 ?= $(shell command -v rebar3 2>/dev/null || echo "./rebar3.OTP$(OTP_RELEASE)")
endif
REBAR_CONFIG = rebar.OTP$(OTP_RELEASE).config
SRCS := $(wildcard src/* include/* rebar.config)
GIT_DESCRIBE := $(shell git describe --tags --first-parent --always --dirty)
.PHONY: all
all: ebin/jesse.app bin/jesse
# Clean
.PHONY: clean
clean:
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) clean
.PHONY: distclean
distclean:
$(MAKE) clean
$(RM) -r _build
$(RM) doc/*.html
$(RM) doc/edoc-info
$(RM) doc/erlang.png
$(RM) doc/stylesheet.css
$(RM) -r logs
.PHONY: clean-tests
clean-tests:
@ rm -rf _build/test/lib
# Docs
.PHONY: docs
docs:
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) edoc
# Compile
bin/jesse: escript
mkdir -p bin
cp -a _build/default/bin/jesse bin/jesse
ebin/jesse.app: compile
.PHONY: escript
escript: ebin/jesse.app
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) escriptize
./_build/default/bin/jesse --help
.PHONY: compile
compile: $(SRCS)
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) compile
# Tests
test/JSON-Schema-Test-Suite/tests:
git submodule sync --recursive
git submodule update --init --recursive
.PHONY: test
# Would be nice to include elvis to test, but it fails on OTP-18
# test: elvis
test: eunit ct xref dialyzer proper cover
.PHONY: elvis
elvis:
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) lint
.PHONY: check
check: elvis
.PHONY: eunit
eunit:
@ $(MAKE) clean-tests
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) eunit
.PHONY: ct
ct: test/JSON-Schema-Test-Suite/tests
@ $(MAKE) clean-tests
TEST_DIR=_build/default/test/lib/jesse/test REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) ct
.PHONY: xref
xref:
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) xref
.PHONY: dialyzer
dialyzer:
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) dialyzer
.PHONY: cover
cover:
@ $(MAKE) clean-tests
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) cover -v
.PHONY: proper
proper:
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) proper
.PHONY: publish
publish: docs
REBAR_CONFIG=$(REBAR_CONFIG) $(REBAR3) hex publish -r hexpm --yes
# TODO: there must be a better way
.PHONY: symlinks
symlinks: test/JSON-Schema-Test-Suite/tests
cd test/jesse_tests_draft3_SUITE_data && \
ln -sf ../../test/JSON-Schema-Test-Suite/tests/draft3 standard && \
ln -sf ../../test/JSON-Schema-Test-Suite/remotes remotes
cd test/jesse_tests_draft4_SUITE_data && \
ln -sf ../../test/JSON-Schema-Test-Suite/tests/draft4 standard && \
ln -sf ../../test/JSON-Schema-Test-Suite/remotes remotes
cd test/jesse_tests_draft6_SUITE_data && \
ln -sf ../../test/JSON-Schema-Test-Suite/tests/draft6 standard && \
ln -sf ../../test/JSON-Schema-Test-Suite/remotes remotes
.PHONY: rebar3.OTP18
rebar3.OTP18:
$(CURL) -fqsS -L -o $@ https://github.com/erlang/rebar3/releases/download/3.13.3/rebar3
$(CHMOD) +x $@
.PHONY: rebar3.OTP19
rebar3.OTP19:
$(CURL) -fqsS -L -o $@ https://github.com/erlang/rebar3/releases/download/3.15.2/rebar3
$(CHMOD) +x $@
.PHONY: rebar3.OTP20
rebar3.OTP20:
$(LN) -sf rebar3.OTP19 $@
.PHONY: rebar3.OTP21
rebar3.OTP21:
$(LN) -sf rebar3.OTP19 $@
.PHONY: rebar3.OTP22
rebar3.OTP22:
$(CURL) -fqsS -L -o $@ https://github.com/erlang/rebar3/releases/download/3.16.1/rebar3
$(CHMOD) +x $@
.PHONY: rebar3.OTP23
rebar3.OTP23:
$(LN) -sf rebar3.OTP22 $@
.PHONY: rebar3.OTP24
rebar3.OTP24:
$(LN) -sf rebar3.OTP22 $@
.PHONY: docker
docker:
if git tag | grep -q -Fx "$(GIT_DESCRIBE)"; then \
$(MAKE) docker-force; \
else \
echo "Current version $(GIT_DESCRIBE) isn't in 'git tag'."; \
echo "Run 'make docker-force' if you really want to build and push a $(GIT_DESCRIBE) version."; \
exit 1; \
fi
.PHONY: docker-force
docker-force:
# docker context create aws-docker-amd64 --docker host=ssh://ec2-13-51-198-153.eu-north-1.compute.amazonaws.com
# docker context create aws-docker-arm64 --docker host=ssh://ec2-13-48-46-86.eu-north-1.compute.amazonaws.com
# docker buildx create --name aws-multiarch-builder aws-docker-amd64
# docker buildx create --name aws-multiarch-builder --append aws-docker-arm64
# docker buildx use aws-multiarch-builder
docker buildx build . \
--push \
--platform linux/amd64,linux/arm64 \
--tag ysoftwareab/jesse:$(GIT_DESCRIBE) \
--tag ysoftwareab/jesse:latest \
--build-arg FROM=erlang:slim \
--build-arg LABEL_VCS_REF=$$(git rev-parse HEAD) \
--build-arg LABEL_BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ")