[#114] Improved tests.
[akkoma] / mix.exs
1 defmodule Pleroma.Mixfile do
2 use Mix.Project
3
4 def project do
5 [
6 app: :pleroma,
7 version: version("0.9.0"),
8 elixir: "~> 1.4",
9 elixirc_paths: elixirc_paths(Mix.env()),
10 compilers: [:phoenix, :gettext] ++ Mix.compilers(),
11 elixirc_options:
12 if Mix.env() == :test do
13 []
14 else
15 [warnings_as_errors: true]
16 end,
17 start_permanent: Mix.env() == :prod,
18 aliases: aliases(),
19 deps: deps(),
20
21 # Docs
22 name: "Pleroma",
23 source_url: "https://git.pleroma.social/pleroma/pleroma",
24 source_url_pattern:
25 "https://git.pleroma.social/pleroma/pleroma/blob/develop/%{path}#L%{line}",
26 homepage_url: "https://pleroma.social/",
27 docs: [
28 logo: "priv/static/static/logo.png",
29 extras: ["README.md", "config/config.md"],
30 main: "readme"
31 ]
32 ]
33 end
34
35 # Configuration for the OTP application.
36 #
37 # Type `mix help compile.app` for more information.
38 def application do
39 [mod: {Pleroma.Application, []}, extra_applications: [:logger, :runtime_tools, :comeonin]]
40 end
41
42 # Specifies which paths to compile per environment.
43 defp elixirc_paths(:test), do: ["lib", "test/support"]
44 defp elixirc_paths(_), do: ["lib"]
45
46 # Specifies your project dependencies.
47 #
48 # Type `mix help deps` for examples and options.
49 defp deps do
50 [
51 {:phoenix, "~> 1.3.3"},
52 {:phoenix_pubsub, "~> 1.0.2"},
53 {:phoenix_ecto, "~> 3.3"},
54 {:postgrex, ">= 0.13.5"},
55 {:gettext, "~> 0.15"},
56 {:cowboy, "~> 1.1.2", override: true},
57 {:comeonin, "~> 4.1.1"},
58 {:pbkdf2_elixir, "~> 0.12.3"},
59 {:trailing_format_plug, "~> 0.0.7"},
60 {:html_sanitize_ex, "~> 1.3.0"},
61 {:phoenix_html, "~> 2.10"},
62 {:calendar, "~> 0.17.4"},
63 {:cachex, "~> 3.0.2"},
64 {:httpoison, "~> 1.2.0"},
65 {:tesla, "~> 1.2"},
66 {:jason, "~> 1.0"},
67 {:mogrify, "~> 0.6.1"},
68 {:ex_aws, "~> 2.0"},
69 {:ex_aws_s3, "~> 2.0"},
70 {:earmark, "~> 1.2"},
71 {:ex_machina, "~> 2.2", only: :test},
72 {:credo, "~> 0.9.3", only: [:dev, :test]},
73 {:mock, "~> 0.3.1", only: :test},
74 {:crypt,
75 git: "https://github.com/msantos/crypt", ref: "1f2b58927ab57e72910191a7ebaeff984382a1d3"},
76 {:cors_plug, "~> 1.5"},
77 {:ex_doc, "> 0.18.3 and < 0.20.0", only: :dev, runtime: false},
78 {:web_push_encryption, "~> 0.2.1"},
79 {:swoosh, "~> 0.20"},
80 {:gen_smtp, "~> 0.13"}
81 ]
82 end
83
84 # Aliases are shortcuts or tasks specific to the current project.
85 # For example, to create, migrate and run the seeds file at once:
86 #
87 # $ mix ecto.setup
88 #
89 # See the documentation for `Mix` for more info on aliases.
90 defp aliases do
91 [
92 "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
93 "ecto.reset": ["ecto.drop", "ecto.setup"],
94 test: ["ecto.create --quiet", "ecto.migrate", "test"]
95 ]
96 end
97
98 # Builds a version string made of:
99 # * the application version
100 # * a pre-release if ahead of the tag: the describe string (-count-commithash)
101 # * build info:
102 # * a build name if `PLEROMA_BUILD_NAME` or `:pleroma, :build_name` is defined
103 # * the mix environment if different than prod
104 defp version(version) do
105 {git_tag, git_pre_release} =
106 with {tag, 0} <- System.cmd("git", ["describe", "--tags", "--abbrev=0"]),
107 tag = String.trim(tag),
108 {describe, 0} <- System.cmd("git", ["describe", "--tags", "--abbrev=8"]),
109 describe = String.trim(describe),
110 ahead <- String.replace(describe, tag, "") do
111 {String.replace_prefix(tag, "v", ""), if(ahead != "", do: String.trim(ahead))}
112 else
113 _ -> {nil, nil}
114 end
115
116 if git_tag && version != git_tag do
117 Mix.shell().error(
118 "Application version #{inspect(version)} does not match git tag #{inspect(git_tag)}"
119 )
120 end
121
122 build_name =
123 cond do
124 name = Application.get_env(:pleroma, :build_name) -> name
125 name = System.get_env("PLEROMA_BUILD_NAME") -> name
126 true -> nil
127 end
128
129 env_name = if Mix.env() != :prod, do: to_string(Mix.env())
130
131 build =
132 [build_name, env_name]
133 |> Enum.filter(fn string -> string && string != "" end)
134 |> Enum.join("-")
135 |> (fn
136 "" -> nil
137 string -> "+" <> string
138 end).()
139
140 [version, git_pre_release, build]
141 |> Enum.filter(fn string -> string && string != "" end)
142 |> Enum.join()
143 end
144 end