Skip to content
Daniel Perez edited this page Nov 29, 2015 · 1 revision

Setup OpenCov with Elixir

  1. Follow the instructions to setup ExCoveralls.

  2. Add the following line to your config file.

    config :excoveralls, :endpoint, "http://example.com/opencov"

    Do not forget to replace http://example.com/opencov with your OpenCov endpoint.

  3. Put the following in a shell script. I will call it cover.sh here. Check the comments in the shell script.

    #!/bin/sh
    
    # this should be kept secret
    # if your CI is able to setup env vars, this one should be better there
    export COVERALLS_REPO_TOKEN="your_opencov_repo_token"
    
    # when using Travis CI
    export GIT_COMMIT="$TRAVIS_COMMIT"
    export GIT_BRANCH="$TRAVIS_BRANCH"
    
    # use the env variables provided by your CI when possible
    # if non is available, or you want to run it locally, use
    # export GIT_COMMIT="$(git rev-parse HEAD)"
    # export GIT_BRANCH="$(git name-rev --name-only HEAD)"
    
    MIX_ENV=test mix coveralls.post \
      --sha="$GIT_COMMIT" \
      --committer="$(git log -1 $GIT_COMMIT --pretty=format:'%cN')" \
      --message="$(git log -1 $GIT_COMMIT --pretty=format:'%s')" \
      --branch="$GIT_BRANCH"
  4. Replace your CI test task with cover.sh instead of mix test.

Clone this wiki locally