-
Notifications
You must be signed in to change notification settings - Fork 4
/
mix.exs
376 lines (348 loc) · 10.5 KB
/
mix.exs
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
defmodule Matcha.MixProject do
use Mix.Project
@version "VERSION" |> File.read!() |> String.trim() |> Version.parse!()
@erlang_version Path.join([
:code.root_dir(),
"releases",
:erlang.system_info(:otp_release),
"OTP_VERSION"
])
|> File.read!()
|> String.trim()
|> String.split(".")
|> Stream.unfold(fn
[] -> nil
[head | tail] -> {head, tail}
end)
|> Stream.concat(Stream.repeatedly(fn -> 0 end))
|> Enum.take(3)
|> Enum.join(".")
|> Version.parse!()
@name "Matcha"
@description "First-class match specification and match patterns for Elixir"
@authors ["Chris Keele"]
@maintainers ["Chris Keele"]
@licenses ["MIT"]
@release_branch "release"
@github_url "https://github.com/christhekeele/matcha"
@homepage_url @github_url
@dev_envs [:dev, :test]
@default_test_suite_includes "--include doctest --include unit --include usage"
def project,
do: [
# Application
app: :matcha,
elixir: "~> 1.14",
elixirc_options: [debug_info: Mix.env() in @dev_envs],
start_permanent: Mix.env() == :prod,
version: Version.to_string(@version),
# Informational
name: @name,
description: @description,
source_url: @github_url,
homepage_url: @homepage_url,
# Configuration
aliases: aliases(),
deps: deps(),
docs: docs(),
dialyzer: dialyzer(),
package: package(),
preferred_cli_env: preferred_cli_env(),
test_coverage: test_coverage()
]
def application,
do: [
mod: {Matcha.Application, []},
extra_applications: extra_applications(Mix.env())
]
defp extra_applications(:prod), do: []
defp extra_applications(_env),
do: [
:dialyzer,
:debugger,
:wx,
:observer,
:runtime_tools,
:mnesia
]
defp aliases,
do: [
# Benchmark report generation
benchmarks: [
"test --include benchmark",
"benchmarks.index"
],
"benchmarks.index": &index_benchmarks/1,
# High-level build tasks
build: [
"compile",
"typecheck.build-cache"
],
# Combination check utility
checks: [
"test.suites",
"lint",
"typecheck"
],
# Combination clean utility
clean: [
&clean_extra_folders/1,
"typecheck.clean",
&clean_build_folders/1
],
# Coverage report generation
coverage: "coveralls.html #{@default_test_suite_includes}",
# Documentation tasks
"docs.coverage": "doctor",
# "docs.coverage": "inch",
# "docs.coverage.report": "inch.report",
# Mix installation tasks
install: [
"install.rebar",
"install.hex",
"install.deps"
],
"install.rebar": "local.rebar --force",
"install.hex": "local.hex --force",
"install.deps": "deps.get",
# Linting tasks
lint: [
"lint.compile",
"lint.deps",
"lint.format",
"lint.style"
],
"lint.compile": "compile --force --warnings-as-errors",
"lint.deps": "deps.unlock --check-unused",
"lint.format": "format --check-formatted",
"lint.style": "credo --strict",
# Release tasks
release: "hex.publish",
# Static pages tasks
static: [
"benchmarks",
"coverage",
"docs",
"static.collect"
],
"static.collect": &collect_static_pages/1,
# Typecheck tasks
typecheck: [
"typecheck.run"
],
"typecheck.build-cache": "dialyzer --plt --format dialyxir",
"typecheck.clean": "dialyzer.clean",
"typecheck.explain": "dialyzer.explain --format dialyxir",
"typecheck.run": "dialyzer --format dialyxir",
# Test tasks
"test.benchmarks": "test --include benchmark",
"test.doctest": "test --include doctest",
"test.focus": "test --include focus",
"test.usage": "test --include usage",
"test.unit": "test --include unit",
# run only default test suites
"test.suites": "test #{@default_test_suite_includes}",
# coverage for everything but benchmarks
"test.coverage": "coveralls #{@default_test_suite_includes}",
"test.coverage.report": "coveralls.github #{@default_test_suite_includes}"
]
defp deps,
do: [
{:benchee, "~> 1.0", only: @dev_envs, runtime: false},
{:benchee_html, "~> 1.0", only: @dev_envs, runtime: false},
{:credo, "~> 1.6", only: @dev_envs, runtime: false},
{:dialyxir, "~> 1.0", only: @dev_envs, runtime: false},
{:erlex, "== 0.2.7-handoff",
only: [:dev, :test], runtime: false, allow_pre: true, override: true},
{:doctor, "~> 0.21", only: @dev_envs, runtime: false},
{:ex_doc, "~> 0.29", only: @dev_envs, runtime: false},
{:excoveralls, "~> 0.18", only: @dev_envs}
]
defp docs,
do: [
# Metadata
name: @name,
authors: @authors,
source_ref: @release_branch,
source_url: @github_url,
homepage_url: @homepage_url,
# Files and Layout
extra_section: "OVERVIEW",
main: "Matcha",
logo: "docs/img/logo.png",
cover: "docs/img/cover.png",
extras: [
# Guides
"docs/guides/usage.livemd": [filename: "guide-usage", title: "Using Matcha"],
"docs/guides/usage/filtering-and-mapping.livemd": [
filename: "guide-filtering-and-mapping",
title: "...for Filtering/Mapping"
],
"docs/guides/usage/tables.livemd": [
filename: "guide-tables",
title: "...for ETS/DETS/Mnesia"
],
"docs/guides/usage/tracing.livemd": [
filename: "guide-tracing",
title: "...for Tracing"
],
"docs/guides/adoption.livemd": [filename: "guide-adoption", title: "Adopting Matcha"],
# Cheatsheets
"docs/cheatsheets/adoption.cheatmd": [
filename: "cheatsheet-adoption",
title: "Adoption Cheatsheet"
],
"docs/cheatsheets/tables.cheatmd": [
filename: "cheatsheet-tables",
title: "Tables Cheatsheet"
],
"docs/cheatsheets/tracing.cheatmd": [
filename: "cheatsheet-tracing",
title: "Tracing Cheatsheet"
],
# Reference
"CHANGELOG.md": [filename: "changelog", title: "Changelog"],
"CONTRIBUTING.md": [filename: "contributing", title: "Contributing"],
"CONTRIBUTORS.md": [filename: "contributors", title: "Contributors"],
"LICENSE.md": [filename: "license", title: "License"]
],
groups_for_extras: [
Guides: ~r|docs/guides|,
Cheatsheets: ~r|docs/cheatsheets|,
Reference: [
"CHANGELOG.md",
"CONTRIBUTING.md",
"CONTRIBUTORS.md",
"LICENSE.md"
]
],
groups_for_modules: [
Core: [
Matcha,
Matcha.Filter,
Matcha.Pattern,
Matcha.Spec
],
Tables: [
Matcha.Table,
Matcha.Table.ETS,
Matcha.Table.ETS.Match,
Matcha.Table.ETS.Select,
Matcha.Table.Mnesia,
Matcha.Table.Mnesia.Match,
Matcha.Table.Mnesia.Select,
Matcha.Table.Query
],
Tracing: [
Matcha.Trace,
Matcha.Trace.Calls,
Matcha.Trace.Messages,
Matcha.Trace.Processes
],
Exceptions: [
Matcha.Error,
Matcha.Filter.Error,
Matcha.Pattern.Error,
Matcha.Rewrite.Error,
Matcha.Spec.Error,
Matcha.Trace.Error
],
Internals: [
Matcha.Context,
Matcha.Context.Erlang,
Matcha.Context.FilterMap,
Matcha.Context.Match,
Matcha.Context.Table,
Matcha.Context.Trace,
Matcha.Rewrite,
Matcha.Rewrite.AST,
Matcha.Rewrite.Bindings,
Matcha.Rewrite.Calls,
Matcha.Rewrite.Clause,
Matcha.Rewrite.Expression,
Matcha.Rewrite.Guards,
Matcha.Rewrite.Kernel,
Matcha.Rewrite.Match,
Matcha.Raw
]
],
nest_modules_by_prefix: [
# Matcha.Context,
# Matcha.Table,
# Matcha.Trace,
# Matcha.Error
]
]
# Control dialyzer success-typing engine
defp dialyzer,
do: [
plt_file: {:no_warn, "priv/plts/dialyzer.plt"},
flags:
["-Wunmatched_returns", :error_handling, :underspecs] ++
if Version.match?(@erlang_version, "< 25.0.0") do
[:race_conditions]
else
[]
end,
ignore_warnings: ".dialyzer_ignore.exs",
list_unused_filters: true,
plt_add_apps: [:mnesia],
plt_ignore_apps: []
]
# Hex.pm information
defp package,
do: [
maintainers: @maintainers,
licenses: @licenses,
links: %{
Home: @homepage_url,
GitHub: @github_url
},
files: [
"lib",
"mix.exs",
"CHANGELOG.md",
"CONTRIBUTING.md",
"LICENSE.md",
"README.md",
"VERSION"
]
]
defp preferred_cli_env,
do: aliases() |> Keyword.keys() |> Enum.map(fn alias -> {alias, :test} end)
defp test_coverage,
do: [
tool: ExCoveralls
]
defp clean_build_folders(_) do
~w[_build deps] |> Enum.map(&File.rm_rf!/1)
end
defp clean_extra_folders(_) do
~w[bench cover doc] |> Enum.map(&File.rm_rf!/1)
end
defp index_benchmarks(_) do
IO.puts("Creating bench/index.html...")
list_items =
Path.wildcard("bench/*/**/*.html")
|> Enum.map(fn html_file ->
relative_file = String.replace_leading(html_file, "bench/", "")
~s|<li><a href="#{relative_file}">Benchmark: #{relative_file}</a></li>|
end)
index_html = ["<ul>", list_items, "</ul>"]
File.write!("bench/index.html", index_html)
end
defp collect_static_pages(_) do
IO.puts("Collecting static files under static/...")
File.mkdir_p!("static")
File.cp_r!("bench", "static/bench")
File.mkdir_p!("static/cover")
File.cp!("cover/excoveralls.html", "static/cover/index.html")
File.cp_r!("doc", "static/doc")
File.write!("static/index.html", ~s|
<ul>
<li><a href="bench/index.html">Benchmarks</a></li>
<li><a href="cover/index.html">Coverage</a></li>
<li><a href="doc/index.html">Documentation</a></li>
|)
end
end