Current section
Files
Jump to
Current section
Files
mix.exs
defmodule Gjallar.MixProject do
use Mix.Project
def project do
[
app: :gjallar,
version: version_from_env_or_git(),
elixir: "~> 1.18",
coveralls: [mininum_coverage: 100],
start_permanent: Mix.env() == :prod,
deps: deps(),
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
coveralls: :test,
"coveralls.html": :test,
"coveralls.json": :test,
"gjallar.test": :test,
# gjallar tasks
gjallar: :test,
"gjallar.test": :test,
"gjallar.format": :dev,
"gjallar.credo": :dev,
# credo native task (if users run it directly)
credo: :dev
],
description: "Opinionated CI helper: deps, compile, format, tests, coverage gate",
package: [
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/kstatz12/gjallar"}
],
docs: [main: "readme", extras: ["README.md"]]
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger, :tools]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:excoveralls, "~> 0.18", only: [:dev, :test], runtime: false},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false, optional: true},
{:ex_doc, "~> 0.34", only: :dev, runtime: false}
]
end
defp version_from_env_or_git do
# Prefer CI-provided env
case System.get_env("PROJECT_VERSION") do
nil ->
git_tag_version()
v ->
normalize(v)
end
end
defp git_tag_version do
# Works if tags are fetched (see checkout step below)
case System.cmd("git", ["describe", "--tags", "--abbrev=0"]) do
{tag, 0} -> normalize(String.trim(tag))
# sane fallback for e.g. source tarballs without .git
_ -> "0.0.0"
end
end
defp normalize(tag) do
tag |> String.trim_leading("v") |> String.trim()
end
end