Codecov Elixir (Umbrella Project) Example
This repository serves as an example on how to use Codecov Global for an Elixir Umbrella Project.
Coverage for this example project will be less than ideal as I commented the tests out for example_two, and phoenix by default only has 25% coverage.
The main configuration required for the projects to work.
Add excoveralls to your top level umbrella mix.exs deps.
defp deps do
[
{:excoveralls, "~> 0.7", only: :test},
]
end
preferred_cli_env: [
"coveralls": :test,
"coveralls.html": :test,
"coveralls.json": :test,
],
test_paths: test_paths(),
test_coverage: [tool: ExCoveralls],
Assuming this matches your apps path and you have tests available for each subapp!
defp test_paths do
"apps/*/test" |> Path.wildcard |> Enum.sort
end
Add to your .travis.yml
file.
NOTE: Use any elixir or otp_release versions you need, these are examples.
language: elixir
elixir:
- 1.3
- 1.4
- 1.5
otp_release:
- 18.3
- 19.3
- 20.0
matrix:
exclude:
- elixir: 1.3
otp_release: 20.0
- elixir: 1.4
otp_release: 20.0
script:
- "MIX_ENV=test mix do compile, coveralls.json --umbrella"
after_success:
- bash <(curl -s https://codecov.io/bash)
NOTE: You may want to include "--warnings-as-errors" if you know your dependencies in your project are clean otherwise the build will fail. If you include it during a build, use this for the script:
script:
- "MIX_ENV=test mix do compile --warnings-as-errors, coveralls.json --umbrella"
See the Travis CI documentation for more information.
View source and learn more about Codecov Global Uploader
For each subapp:
test_coverage: [tool: ExCoveralls]
In the example subapps, only example_one and example_two are included in the coverage. This can be seen on both codecov.io and on travis-ci at the end of the build when it shows the results. Also, as stated above, coverage for this example project will be less than ideal as I commented the tests out for example_two, and phoenix by default only has 25% coverage.
Frameworks such as Phoenix need only have this added to their mix.exs too (as seen in the example_web sub-app). As the back-end is Elixir, it takes advantage of the Elixir test suite and only uses that in the coverage reports.
To test the coverage of each individual app:
mix coveralls
To test the coverage of all coverage-included subapps in the umbrella project:
mix coveralls --umbrella
Need help? Contact support https://github.com/codecov/support