Test Coverage - Branch Names

Successfully generating test coverage for your branches, but not seeing the results populated in GitHub via the browser extension or PR statuses?

1856

👍

Code Climate Needs:

  • GIT_COMMIT_SHA
  • GIT_BRANCH

How to:

Here's the basic troubleshooting checklist, with additional details below:

  1. Get debug output from your CI build using the --debug option
  2. View the output
  3. Check your CI's env var names
  4. Adjust your coverage setup

Get debug output

The cc-test-reporter command has an option to output additional debug messages during operation.

For single builds, use:

  • after-build --debug.
1366

For tests run in parallel, use:

  • format-coverage --debug and upload-coverage --debug.
1908

View CI output

Once you've added the --debug option, you'll find the branch name identified in your build log, like this:

1604

Check your CI's environmental variable names

When looking at a payload, Code Climate looks for a specific set of environmental variable names.

Double-check to make sure your CI's GIT_COMMIT_SHA and GIT_BRANCH variable names can be matched against the ones listed at the bottom of this file:

Additionally, the test reporter must be able to determine the time of commit. We'll attempt to read this information from git if no ENV VAR is explicitly set, but it may be necessary to set GIT_COMMITTED_AT.

1928

Adjust coverage setup as needed

Working with a Docker container?

When using docker, it’s common to not export the git directory to the workspace, which means our test reporter requires environment variables to get the information it needs. Make sure to pass the environment variables through.

You could pass the env variable to the docker container doing something like this:

docker run \
      --env CI \
      --env CIRCLECI \
      --env CIRCLE_BUILD_NUM \
      --env CIRCLE_BRANCH \
      --env CIRCLE_SHA1 \
    your-org/app bundle exec rspec

AWS Codebuild and Azure Pipelines

📘

Find additional information on getting Branch names and other env vars here: