Giter VIP home page Giter VIP logo

report-test-coverage-action's Introduction

Report test coverage example

Determines the test coverage of a Python module using coverage.py. Generates a badge for the determined coverage when triggered by a push event. When triggered by a pull_request event, the determined coverage is added as a comment to the corresponding pull request.

Example badge generated using this action:

Coverage


Steps required to set this action up for a repository:

  1. The workflow should be triggered by push and pull_request events. For push events, make sure that the workflow is only triggered on the main branch, or whichever branch you want to be associated with the value reported by the generated badge:
    on:
      pull_request:
      push:
        branches: ['master']
  2. Make sure the workflow job has the following permissions:
    permissions:
      issues: write
      pull-requests: write
  3. Create a Gist which will be used to store the values for the badge. To do that, simply create an empty Gist. You will need the ID of the Gist. If https://gist.github.com/kostrykin/d152375a04f7ab9ee9b247de41245b24 is the URL of your Gist, then d152375a04f7ab9ee9b247de41245b24 is the ID.
  4. Create a PAT with Gist permission, and add it as your GIST_SECRET by going to your repository Settings > Secrets and variables > Actions > New repository secret.
  5. Add the action to the workflow and replace d152375a04f7ab9ee9b247de41245b24 by your Gist ID:
    - uses: kostrykin/[email protected]
      with:
        gist-id: d152375a04f7ab9ee9b247de41245b24
        github-auth: ${{ secrets.GITHUB_TOKEN }}
        gist-auth: ${{ secrets.GIST_SECRET }}
    When embedded into a matrix strategy (e.g., for testing multiple Python versions), the reporting should be restricted to a single step. This can be achieved, for example, by adding:
        report: ${{ strategy.job-index == 0 }}
    You can also specify a working-directory as a relative path to the root of the repository (e.g., ./example) if your Python module and the corresponding tests directory are not direct descendents of the repository root.

For a full example, see the workflow file .github/workflows/example.yml and the example/ directory.

List of further examples:

report-test-coverage-action's People

Contributors

kostrykin avatar

Watchers

 avatar  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.