Skip to content

PHP-Coverage-Badge is a gitaction for creating an SVG coverage badge from a PHP Clover or Cobertura XML file.

License

Notifications You must be signed in to change notification settings

athos99/php-coverage-badge

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

110 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quality gate

php-coverage-badge

PHP-Coverage-Badge is a GitAction for creating SVG coverage badges. It parses XML report files such as Clover or Cobertura and creates badges based on the coverage of lines and branches of the code.

This is the type of badge generated

badge badge badge badge

How to use in you Github action yml file

   - name: clover report
        uses: athos99/php-coverage-badge@v1
        with:
          report: 'coverage/clover.xml'
          report_type: 'clover'
          coverage_line_badge_path: 'output/coverage_line.svg'
          coverage_branch_badge_path: 'output/coverage_branch.svg'

Archiving badges in Git

Generated badges are not archived by default in your Git repository. You must archive them.

    - name: archive
        run: git config --local user.name "github-actions[bot]"
      - run: git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" 
      - run: git add out/coverage_line.svg
      - run: git add out/coverage_branch.svg
      - run: 'git commit -m "chore: add coverage badges"  || true'
        
      - name: Push changes # push the output folder to your repo
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          force: true
          branch: ${{ github.ref }}

You can take inspiration from the php-coverage-badge-test file to integrate php-covevrage-badge into your GitAction

last version

v1

how to add the badges in markdown file

![badge](https://raw.githubusercontent.com/athos99/php-coverage-badge/refs/heads/main/test/clover_coverage_line.svg)

Inputs

Paths are always relative to the root of your repository.

  • report:

    • description: 'The path to the report file.'
    • required: false
    • default: 'clover.xml'
  • report_type:

    • description: 'The type of the generated report. Currently supported: clover, cobertura.'
    • required: false
    • default: 'clover'
  • coverage_line_badge_name:

    • description: 'The name of the line coverage badge'
    • required: false
    • default: 'Line coverage'
  • coverage_branch_badge_name:

    • description: 'The name of the branch coverage badge'
    • required: false
    • default: 'Branch coverage'
  • coverage_line_badge_path:

    • description: 'The path of the line coverage badge'
    • required: false
    • default: 'coverage_line.svg'
  • coverage_branch_badge_path:

    • description: 'The path of the branch coverage badge'
    • required: false
    • default: 'coverage_breanche.svg'
  • coverage_line_percent_ok:

    • description: 'Acceptable limit of coverage line percent'
    • required: false
    • default: '80'
  • coverage_branch_percent_ok:

    • description: 'Acceptable limit of coverage barnch percent'
    • required: false
    • default: '60'

Based on https://github.com/cicirello/jacoco-badge-generator

About

PHP-Coverage-Badge is a gitaction for creating an SVG coverage badge from a PHP Clover or Cobertura XML file.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages