-
Notifications
You must be signed in to change notification settings - Fork 4
/
mix.exs
288 lines (262 loc) · 7.82 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
defmodule Matcha.MixProject do
use Mix.Project
@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.10",
start_permanent: Mix.env() == :prod,
version: "VERSION" |> File.read!() |> String.trim(),
extra_applications: extra_applications(Mix.env()),
# 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, []}]
defp extra_applications(:prod), do: []
defp extra_applications(_env),
do: [
:dialyzer
]
defp aliases,
do: [
# Benchmark report generation
benchmarks: [
"test --include benchmark",
"benchmarks.index"
],
"benchmarks.index": &index_benchmarks/1,
# Combination check utility
checks: [
"test.suites",
"lint",
"typecheck"
],
# Combination clean utility
clean: [
"typecheck.clean",
"deps.clean --all",
&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.format",
"lint.style"
],
"lint.compile": "compile --force --warnings-as-errors",
"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.benchmark": "test --include benchmark",
"test.doctest": "test --include doctest",
"test.usage": "test --include usage",
"test.unit": "test --include unit",
# test everything but benchmarks
"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: [
{:recon, ">= 2.3.0"},
# Dev tooling
{: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},
{:doctor, "~> 0.18", only: @dev_envs, runtime: false},
{:ex_doc, "~> 0.28", only: @dev_envs, runtime: false},
{:excoveralls, "~> 0.14 and >= 0.14.4", only: @dev_envs},
{:jason, ">= 0.0.1", only: @dev_envs, runtime: false}
]
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",
extras: [
# Guides
"docs/guides/usage.livemd": [filename: "usage", title: "Using Matcha"],
"docs/guides/usage/filtering-and-mapping.livemd": [
filename: "filtering-and-mapping",
title: "...for Filtering/Mapping"
],
"docs/guides/usage/tables.livemd": [
filename: "tables",
title: "...for ETS/DETS/Mnesia"
],
"docs/guides/usage/tracing.livemd": [
filename: "tracing",
title: "...for Tracing"
],
# Reference
"CHANGELOG.md": [filename: "changelog", title: "Changelog"],
"CONTRIBUTING.md": [filename: "contributing", title: "Contributing"],
"LICENSE.md": [filename: "license", title: "License"]
],
groups_for_extras: [
Guides: ~r/docs\/guides/,
Reference: [
"CHANGELOG.md",
"CONTRIBUTING.md",
"LICENSE.md"
]
],
groups_for_modules: [
Contexts: [
Matcha.Context,
Matcha.Context.Erlang,
Matcha.Context.FilterMap,
Matcha.Context.Match,
Matcha.Context.Table,
Matcha.Context.Trace
],
Exceptions: [
Matcha.Error,
Matcha.Pattern.Error,
Matcha.Rewrite.Error,
Matcha.Spec.Error,
Matcha.Trace.Error
],
Internals: [
Matcha.Rewrite,
Matcha.Rewrite.Kernel,
Matcha.Source
]
]
]
# Control dialyzer success-typing engine
defp dialyzer,
do: [
plt_file: {:no_warn, "priv/plts/dialyzer.plt"},
flags:
["-Wunmatched_returns", :error_handling, :underspecs] ++
if :erlang.system_info(:otp_release) != '25' do
[:race_conditions]
else
[]
end,
ignore_warnings: ".dialyzer_ignore.exs",
list_unused_filters: true,
# plt_add_deps: :apps_direct,
plt_add_apps: [],
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 bench cover deps 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