add archeometer

This commit is contained in:
Mayel de Borniol 2022-09-08 14:50:23 +12:00
parent 7c4e0b022c
commit 63423b18b1
7 changed files with 109 additions and 33 deletions

20
.credo.exs Normal file
View file

@ -0,0 +1,20 @@
%{
configs: [
%{
name: "default",
files: %{
included: ["mix.exs", "flavours/", "lib/", "forks/*/mix.exs", "forks/*/lib"],
excluded: [~r"/_build/", "**/*_test.exs"]
},
plugins: [],
requires: [],
strict: false,
parse_timeout: 5000,
color: true,
# checks: [
# {Credo.Check.Design.AliasUsage, priority: :low},
# # ... other checks omitted for readability ...
# ]
}
]
}

51
.github/workflows/docs.yaml vendored Normal file
View file

@ -0,0 +1,51 @@
name: Maybe generate docs
on:
push:
branches:
- main
jobs:
docs:
name: Generate docs upon new release
runs-on: ubuntu-latest
container: elixir:1.13-alpine
env:
FLAVOUR: classic
FLAVOUR_PATH: flavours/classic
MIX_ENV: dev
WITH_DOCKER: no
CI: true
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2 # needed for action-detect-and-tag-new-version
-
name: Detect new version
id: version
uses: salsify/action-detect-and-tag-new-version@v2
with:
version-command: |
grep -m 1 'version:' mix.exs | cut -d '"' -f2
-
if: steps.version.outputs.current-version == steps.version.outputs.previous-version
name: Cancel workflow if the version has not changed
uses: andymckay/cancel-action@0.2
-
name: Prep
run: sudo apt-get install -y cargo && cargo install just && echo "/github/home/.cargo/bin" >> $GITHUB_PATH &&
-
name: Generate docs
run: just docs
-
name: Generate arch reports
run: just arch && mv reports/dev/static/html ./docs/exdoc/arch
-
name: Deploy docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/exdoc
cname: doc.bonfirenetworks.org

View file

@ -120,7 +120,7 @@ jobs:
with:
fetch-depth: 2 # needed for action-detect-and-tag-new-version
-
name: Maybe tag/release new version
name: Detect new version
id: version
uses: salsify/action-detect-and-tag-new-version@v2
with:
@ -191,7 +191,7 @@ jobs:
with:
fetch-depth: 2 # needed for action-detect-and-tag-new-version
-
name: Detect version
name: Detect new version
id: version
uses: salsify/action-detect-and-tag-new-version@v2
with:

View file

@ -88,14 +88,6 @@ jobs:
run: mix bonfire.deps.clean.data
- name: Compile deps & app
run: mix compile
- name: Generate docs
run: mix docs
- name: Deploy docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/exdoc
cname: doc.bonfirenetworks.org
- name: Set up database
run: mix ecto.setup
- name: Run tests

View file

@ -123,11 +123,13 @@ arch:
just mix arch.explore.static
just mix arch.explore.xrefs
just mix arch.explore.apps
MIX_ENV=test just mix arch.explore.coverage
just mix arch.report.html
-MIX_ENV=test just mix arch.explore.coverage
just mix arch.dsm
just mix arch.xref --format png --out reports/dev/static/modules.png Bonfire.Web.Router Bonfire.UI.Social.Routes Bonfire.UI.Me.Routes
just mix arch.apps.xref --format png --out reports/dev/static/apps.png
just mix arch.report.html
mkdir -p reports/dev/static/html/data/
just mix arch.apps.xref --format mermaid --out reports/dev/static/html/data/apps.mermaid
just mix arch.apps.xref --format svg --out reports/dev/static/html/data/apps.svg
# just mix arch.xref --format svg --out reports/dev/static/modules.png Bonfire.Web.Router Bonfire.UI.Social.Routes Bonfire.UI.Me.Routes
# Force the app to recompile
recompile:

View file

49
mix.exs
View file

@ -3,7 +3,7 @@ defmodule Bonfire.MixProject do
use Mix.Project
@config [ # TODO: put these in ENV or an external writeable config file similar to deps.*
version: "0.3.4-beta.12", # note that the flavour will automatically be added where the dash appears
version: "0.3.4-beta.13", # note that the flavour will automatically be added where the dash appears
elixir: "~> 1.13",
default_flavour: "classic",
logo: "assets/static/images/bonfire-icon.png",
@ -21,11 +21,11 @@ defmodule Bonfire.MixProject do
"docs/CHANGELOG-autogenerated.md",
],
deps_prefixes: [
docs: ["bonfire_", "pointers", "paginator", "ecto_shorts", "ecto_sparkles", "absinthe_client", "activity_pub", "arrows", "ecto_materialized_path", "flexto", "grumble", "linkify", "verbs", "voodoo", "waffle", "zest"],
test: ["bonfire_", "pointers", "paginator", "ecto_shorts", "ecto_sparkles", "activity_pub", "linkify", "fetch_favicon"],
docs: ["bonfire", "pointers", "paginator", "ecto_shorts", "ecto_sparkles", "absinthe_client", "activity_pub", "arrows", "ecto_materialized_path", "flexto", "grumble", "linkify", "verbs", "voodoo", "waffle", "zest"],
test: ["bonfire", "pointers", "paginator", "ecto_shorts", "ecto_sparkles", "activity_pub", "linkify", "fetch_favicon"],
data: ["bonfire_data_", "bonfire_data_edges", "pointers", "bonfire_boundaries", "bonfire_tag", "bonfire_classify", "bonfire_geolocate", "bonfire_quantify", "bonfire_valueflows"],
api: ["bonfire_me", "bonfire_social", "bonfire_tag", "bonfire_classify", "bonfire_geolocate", "bonfire_valueflows"],
localise: ["bonfire_"],
localise: ["bonfire"],
localise_self: []
]
]
@ -35,13 +35,17 @@ defmodule Bonfire.MixProject do
app: :bonfire,
version: version(),
elixir: @config[:elixir],
elixirc_paths: elixirc_paths(Mix.env()),
elixirc_options: [debug_info: true, docs: true],
elixirc_paths: elixirc_paths(Mix.env()),
test_paths: test_paths(),
test_deps: deps(:test),
compilers: compilers(Mix.env()),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps(),
multirepo_deps: deps(:bonfire),
in_multirepo_fn: &in_multirepo?/1,
multirepo_recompile_fn: &deps_recompile/0,
config_path: config_path("config.exs"),
releases: [
bonfire: [
@ -60,7 +64,7 @@ defmodule Bonfire.MixProject do
# extra pages to include
extras: readme_paths(),
# extra apps to include in module docs
source_beam: docs_paths(),
source_beam: beam_paths(:docs),
deps: doc_deps(),
groups_for_extras: [ # Note: first match wins
"Guides": Path.wildcard("docs/*"),
@ -151,14 +155,14 @@ defmodule Bonfire.MixProject do
# {:changelog, "~> 0.1", only: [:dev, :test], runtime: false}, # retrieve changelogs of latest dependency versions
{:versioce, "~> 1.1.2", only: :dev}, # changelog generation
{:git_cli, "~> 0.3.0", only: :dev}, # needed for changelog generation
{:archeometer, "~> 0.1.0", only: [:dev, :test]},
{:archeometer, git: "https://gitlab.com/mayel/archeometer", only: [:dev, :test]}, # "~> 0.1.0"
# tests
{:floki, ">= 0.0.0", only: [:dev, :test]},
{:ex_machina, "~> 2.4", only: :test},
{:mock, "~> 0.3", only: :test},
{:mox, "~> 1.0", only: :test},
{:zest, "~> 0.1"},
{:zest, "~> 0.1.0"},
{:grumble, "~> 0.1.3", only: [:test], override: true},
{:mix_test_watch, "~> 1.0", only: :test, runtime: false},
{:mix_test_interactive, "~> 1.2", only: :test, runtime: false},
@ -199,9 +203,17 @@ defmodule Bonfire.MixProject do
end
def deps(deps \\ deps(), deps_subtype)
def deps(deps, :bonfire) do
deps_prefixes = multirepo_prefixes()
Enum.filter(deps, &in_multirepo?(&1, deps_prefixes))
end
def deps(deps, deps_subtype) when is_atom(deps_subtype), do:
Enum.filter(deps, &include_dep?(deps_subtype, &1))
Enum.filter(deps, &include_dep?(deps_subtype, &1, @config[:deps_prefixes][deps_subtype]))
def multirepo_prefixes(), do: Enum.flat_map(@config[:deps_prefixes], fn {_, list} -> list end) |> Enum.uniq()
def in_multirepo?(dep, deps_prefixes \\ multirepo_prefixes()), do: include_dep?(:bonfire, dep, deps_prefixes)
def deps_recompile(deps \\ deps_for(:bonfire)), do: Mix.Task.run("bonfire.dep.compile", ["--force"] ++ List.wrap(deps))
def flavour_path(), do:
System.get_env("FLAVOUR_PATH", "flavours/"<>flavour())
@ -235,12 +247,12 @@ defmodule Bonfire.MixProject do
# Specifies which paths to include in docs
def docs_paths() do
def beam_paths(type \\ :all) do
build = Mix.Project.build_path()
([:bonfire] ++ deps(:docs))
|> Enum.map(&docs_path(&1, build))
([:bonfire] ++ deps(type))
|> Enum.map(&beam_path(&1, build))
end
defp docs_path(app, build), do: Path.join([build, "lib", dep_name(app), "ebin"])
defp beam_path(app, build), do: Path.join([build, "lib", dep_name(app), "ebin"])
def readme_paths(), do: @config[:docs]
++ Enum.map(Path.wildcard("flavours/*/README.md"), &flavour_readme/1)
@ -275,11 +287,10 @@ defmodule Bonfire.MixProject do
defp elixirc_paths(:test), do: ["lib", "test/support" | Enum.flat_map(deps(:test), &dep_paths(&1, "test/support"))]
defp elixirc_paths(env), do: ["lib"] ++ catalogues(env)
defp include_dep?(:update, dep) when is_tuple(dep), do: unpinned_git_dep?(dep)
defp include_dep?(:docs = type, dep), do: String.starts_with?(dep_name(dep), @config[:deps_prefixes][type]) || git_dep?(dep)
defp include_dep?(type, dep), do: String.starts_with?(dep_name(dep), @config[:deps_prefixes][type])
defp include_dep?(type, dep, deps_prefixes \\ nil)
defp include_dep?(:update, dep, _deps_prefixes) when is_tuple(dep), do: unpinned_git_dep?(dep)
# defp include_dep?(:docs = type, dep, deps_prefixes), do: String.starts_with?(dep_name(dep), deps_prefixes || @config[:deps_prefixes][type]) || git_dep?(dep)
defp include_dep?(type, dep, deps_prefixes), do: String.starts_with?(dep_name(dep), deps_prefixes || @config[:deps_prefixes][type])
defp git_dep?(dep) do
spec = elem(dep, 1)