Giter Site home page Giter Site logo

codeclimate-action's Introduction

codeclimate-action

Test Coverage Build Status MIT License

A GitHub action that publishes your code coverage to Code Climate.

Usage

This action requires that you set the CC_TEST_REPORTER_ID environment variable. You can find it under Repo Settings in your Code Climate project.

Inputs

Input Default Description
coverageCommand The actual command that should be executed to run your tests and capture coverage.
workingDirectory Specify a custom working directory where the coverage command should be executed.
debug false Enable Code Coverage debug output when set to true.
coverageLocations Locations to find code coverage as a multiline string.
Each line should be of the form <location>:<type>.
type can be any one of clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, lcov-json, simplecov, xccov. See examples below.
prefix undefined See --prefix
verifyDownload true Verifies the downloaded Code Climate reporter binary's checksum and GPG signature. See Verifying binaries

Note If you are a Ruby developer using SimpleCov, other users have recommended installing an additional gem – gem "simplecov_json_formatter" – this gem fixes json error from the default coverage/.resultset.json output from SimpleCov.

Example

steps:
  - name: Test & publish code coverage
    uses: paambaati/[email protected]
    env:
      CC_TEST_REPORTER_ID: <code_climate_reporter_id>
    with:
      coverageCommand: npm run coverage
      debug: true

Example with only upload

When you've already generated the coverage report in a previous step and wish to just upload the coverage data to Code Climate, you can leave out the coverageCommand option.

steps:
  - name: Test & publish code coverage
    uses: paambaati/[email protected]
    env:
      CC_TEST_REPORTER_ID: <code_climate_reporter_id>

Example with wildcard (glob) pattern

This action supports basic glob patterns to search for files matching given patterns. It uses @actions/glob to expand the glob patterns.

steps:
  - name: Test & publish code coverage
    uses: paambaati/[email protected]
    env:
      CC_TEST_REPORTER_ID: <code_climate_reporter_id>
    with:
      coverageCommand: yarn run coverage
      coverageLocations: |
        ${{github.workspace}}/*.lcov:lcov

Example with Jacoco

steps:
  - name: Test & publish code coverage
    uses: paambaati/[email protected]
    env:
      # Set CC_TEST_REPORTER_ID as secret of your repo
      CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
      JACOCO_SOURCE_PATH: "${{github.workspace}}/src/main/java"
    with:
      # The report file must be there, otherwise Code Climate won't find it
      coverageCommand: mvn test
      coverageLocations: ${{github.workspace}}/target/site/jacoco/jacoco.xml:jacoco

Example of multiple test coverages for monorepo with Jest

Let's say you have a monorepo with two folders —client and server, both with their own coverage folders and a yarn coverage script which runs Jest within both folders.

"scripts": {
  "coverage": "yarn client coverage && yarn server coverage"
}

First be sure that paths in your coverage/lcov.info are correct; they should be either absolute or relative to the root of the monorepo. Open lcov.info and search for any path. For example —

SF:src/server.ts

If you find a relative path like this (happens for Jest 25+), it's incorrect as it is relative to the sub-package. This can be fixed by configuring Jest to set the root of your monorepo —

// server/jest.config.js
module.exports = {
  ...
  coverageReporters: [['lcov', { projectRoot: '..' }]]
  ...
};
steps:
  - name: Test & publish code coverage
    uses: paambaati/[email protected]
    env:
      CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
    with:
      coverageCommand: yarn run coverage
      coverageLocations: |
        ${{github.workspace}}/client/coverage/lcov.info:lcov
        ${{github.workspace}}/server/coverage/lcov.info:lcov

Example projects

  1. paambaati/websight

  2. MartinNuc/coverage-ga-test

codeclimate-action's People

Contributors

antongolub avatar arareko avatar bennypowers avatar dependabot-preview[bot] avatar dependabot[bot] avatar fabn avatar jasonkarns avatar juanvqz avatar kengotoda avatar markvaughn avatar martinnuc avatar matthewshirley avatar miguelfrias97 avatar olly avatar paambaati avatar ralphg6 avatar rwjblue avatar sumolari avatar vladjerca avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.