Git Product home page Git Product logo

coverage-checker's Introduction

coverage-checker

A Github action to check if you didn't degrade your code coverage.

Description

This action is split into two actions :

Context Action Description
Push on main branch update By configuring the "update" action to be ran on pushes to your main branch, it will parse your clover file, generate a JSON containing interesting metrics, and push it to a branch named coverage. You'll benefit from the natural commits history to track the evolution of your overall coverage.
Pull request check By configuring the "check" action to be ran on pull requests, it will get the main branch's coverage, located in the coverage branch, and compare it to your pull request's coverage. A report will be posted as a comment on your pull request, and the action will fail if the coverage has been degraded.

Workflow diagram

The actions

Update

The update process is the one used to update coverage report for the main branch of the project. After calculation, it pushes results to a dedicated coverage branch.

Here is an exemple of how to use it (on a php project) :

name: Coverage update
on:
  push:
    branches:
      - main
jobs:
  coverage_update:
    runs-on: ubuntu-lastest
    steps:
      - uses: actions/checkout@v2
      - name: Install dependencies
        run: composer install --prefer-dist --no-progress --no-suggest
      - name: Run test suite
        run: make test
      - name: Coverage update
        uses: OpenClassrooms/[email protected]
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          action: update

Note that the Run test suite step will generate a clover file containing the coverage information. This action will use this file to generate the report.

Badge generation

If a "badge" property is defined in the configuration, the update action will generate an SVG badge and commit it in the coverage branch.

Coverage history

A file named coverage-history.json, persisted in the coverage branch, will be updated at each base coverage update. By querying it and using it in a visualization tool, you'll be able to share metrics regarding your coverage history easily.

Check

name: Coverage check
on: [pull_request]
jobs:
  coverage_check:
    runs-on: ubuntu-lastest
    steps:
      - uses: actions/checkout@v2
      - name: Install dependencies
        run: composer install --prefer-dist --no-progress --no-suggest
      - name: Run test suite
        run: make test
      - name: Coverage check
        uses: OpenClassrooms/[email protected]
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          action: check

The output of this action is a comment on the PR to simply see if the coverage has been degraded or not, and an action failure in case of degradation.

Workflow diagram

Workflow diagram

Configuration reference

Parameter Required Default Comment
token Yes No default The action token. Will be used to push or read from coverage branch
action No update The action to be executed. Either update or check
files No [{"coverage": "coverage.xml", "summary": "coverage-summary.json", "label": "Coverage", "badge": "coverage.svg"}] An array of objects representing the clover file that will be generated by your test suite, the json file and SVG badge that will be created by this action and uploaded to the coverage branch, and the label to display on reports and badges

Contributing

Setup your dev env

After having cloned the project, run make install, that will install dependencies, and ncc (required to compile code before pushing it).

Compile & commit

Compile code before committing by running this command: make

coverage-checker's People

Contributors

prollandoc avatar limbasiyaketan0821 avatar cvernerie avatar nicolasguerin avatar olivmai 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.