Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Climate test reporter command fails. #387

Open
harshmittal29 opened this issue Feb 6, 2019 · 6 comments
Open

Code Climate test reporter command fails. #387

harshmittal29 opened this issue Feb 6, 2019 · 6 comments
Assignees

Comments

@harshmittal29
Copy link

harshmittal29 commented Feb 6, 2019

I am setting up my config.yml file for Circle CI.
The cc-test-reporter command fails.

config.yml file

version: 2
jobs:
  build:
    working_directory: ~/mva
    docker:
    - image: circleci/android:api-28
    environment:
      JVM_OPTS: -Xmx2048m
      CC_TEST_REPORTER_ID: XXXXXXXXXXX
    steps:
    - checkout
    - restore_cache:
        key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
    #      - run:
    #         name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
    #         command: sudo chmod +x ./gradlew
    - run:
        name: Download Dependencies
        command: ./gradlew androidDependencies
    - save_cache:
        paths:
        - ~/.gradle
        key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
#    - run:
#        name: Run Lint Tests
#        command: ./gradlew lint test
#    - run:
#        name: Run Instrument Tests
#        command: ./gradlew connectedAndroidTest

    #Run coverage report for Code Climate
    - run:
        name: Setup Code Climate test-reporter
        command: |
            # download test reporter as a static binary
            curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-0.6.3-linux-amd64 > ./cc-test-reporter
            chmod +x ./cc-test-reporter
            ./cc-test-reporter before-build
        when: always

    - run:
        name: Run Tests
        command: ./gradlew test

    - run:
        name: code-coverage
        command: |
            ./cc-test-reporter after-build -d -t cobertura --exit-code $?
        when: always

    - store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
        path: app/build/reports
        destination: app/reports
    - store_test_results: # for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
        path: build/test-results
    # See https://circleci.com/docs/2.0/deployment-integrations/ for deploy examples

Logs on Circle CI

#!/bin/bash -eo pipefail
./cc-test-reporter after-build -d -t cobertura --exit-code $?
DEBU[0000] about to run format-coverage
DEBU[0000] using formatter cobertura
DEBU[0000] checking search path for cobertura formatter
DEBU[0000] checking search path cobertura.xml for cobertura formatter
DEBU[0000] checking search path cobertura.ser for cobertura formatter
ERRO[0000] could not find coverage file
could not find any files in search paths for cobertura. search paths were: , cobertura.xml, cobertura.ser
Error: could not find any files in search paths for cobertura. search paths were: , cobertura.xml, cobertura.ser
Usage:
cc-test-reporter after-build [flags]

Flags:
-s, --batch-size int batch size for source files (default 500)
-e, --coverage-endpoint string endpoint to upload coverage information to (default "https://api.codeclimate.com/v1/test_reports")
-t, --coverage-input-type string type of input source to use [clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, simplecov]
--exit-code int exit code of the test run
-r, --id string reporter identifier (default "")
--insecure send coverage insecurely (without HTTPS)
-p, --prefix string the root directory where the coverage analysis was performed (default "/home/circleci/mva")

Global Flags:
-d, --debug run in debug mode

Exited with code 255

My CircleCI repo https://circleci.com/gh/mindvalley/Mobile_Android_MVA/2038

@harshmittal29 harshmittal29 changed the title Circle CI test reporter command fails. Code Climate test reporter command fails. Feb 6, 2019
@harshmittal29
Copy link
Author

Dear Team,
Do you have any suggestion for this?

@efueger
Copy link
Member

efueger commented Feb 11, 2019

Hi @harshmittal29 -

It looks like you might need to use low level commands to tell the test reporter where your coverage file is.

Here's a few examples of how to do that:

Let me know if that resolves the error message. Happy to take another look. 👍

@harshmittal29
Copy link
Author

Thanks @efueger .
I have few queries

  1. How is this coverage_data generated? Is there anything we mention in our gradle for cobertura for generating result file?
  2. Is there a working sample for Android which i can refer to using Circle CI and code climate cc-test-reporter command?

@amccaleb
Copy link

Experiencing the same thing and am using the Cobertura Gradle Plugin.

@amccaleb
Copy link

@harshmittal29 On second glance of your config.yml file, I noticed this:
- run: name: Run Tests command: ./gradlew test

Have you configured Cobertura into Gradle at all? That config suggests otherwise.

@efueger
Copy link
Member

efueger commented Apr 23, 2019

Hi @harshmittal29 and @amccaleb,

Are you using these instructions:

Instead of after-build, please use these two sub-commands_

  1. format-coverage, which has 2 important settings:

  2. JACOCO_SOURCE_PATH: the path to Java source files
    coverage file: to path to JaCoCo coverage XML file

    upload-coverage

Example:

JACOCO_SOURCE_PATH=src/main/java ./cc-test-reporter \
  format-coverage target/site/jacoco/jacoco.xml     \
  --input-type jacoco
./cc-test-reporter upload-coverage

(Link to JACOCO_SOURCE_PATH.)

If you are already using that:

Thanks,
Emily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants