diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f92a3c8 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @m0hanraj \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..40586f0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: 'composer' + directory: '/' + schedule: + interval: 'weekly' + + - package-ecosystem: 'docker' + directory: '/' + schedule: + interval: 'weekly' \ No newline at end of file diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..d9d688e --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,37 @@ +name: PHP lint & test + +on: [push, pull_request] + +jobs: + lint-test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: xdebug + coverage: xdebug + tools: composer:v2 + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run PHPCS Lint + run: composer lint + + - name: Run PHPUnit tests + run: composer test + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index fb84033..5ad3023 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use the official PHP 8.2 image from Docker Hub -FROM php:8.2-cli +FROM php:8.3-cli # Install Xdebug extension RUN pecl install xdebug && docker-php-ext-enable xdebug diff --git a/README.md b/README.md index 127dbe7..4be704e 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,29 @@ # CoverageBadge -![](./badges/php.svg) +[![PHP lint & test](https://github.com/codebtech/coveragebadge/actions/workflows/php.yml/badge.svg)](https://github.com/codebtech/coveragebadge/actions/workflows/php.yml) ![](./badges/php.svg) -CoverageBadge is a library for creating an SVG coverage badge from a Clover XML file. -## Installation +CoverageBadge is a PHP library for creating SVG coverage badges from Clover XML files. -Composer +## Installation `composer require codebtech/coveragebadge --dev` ## Features -- Generate coverage badge from PHPUnit Clover XML file -- Generate coverage badge based on multiple Clover XML files, and it merges the coverage percentage automatically -- Can accept coverage name and the badge will be generated with the coverage name - +- Produces a code coverage badge utilizing a Clover coverage XML file +- Creates a code coverage badge from several Clover XML files, automatically incorporating the coverage percentages +- Accepts a coverage name as an input to include in the generated badge ## Usage - -1. Generate [XML Code Coverage](https://docs.phpunit.de/en/11.1/code-coverage.html) and generate [Clover](https://docs.phpunit.de/en/11.1/configuration.html#the-report-element) XML files. -2. Run `vendor/bin/coverage-badge /path/to/clover.xml /path/to/badge/destination.svg test-name` -3. To merge multiple clover files provide the input XML files `comma` separated run `vendor/bin/coverage-badge /path/to/clover.xml,/path/to/clover2.xml /path/to/badge/destination.svg test-name` +- Execute the command to generate badge for single Clover XML input +``` +vendor/bin/coverage-badge /path/to/clover.xml /path/to/badge/destination.svg test-name +``` +- To blend multiple Clover files, enumerate the XML inputs separated by commas and use the command +``` +vendor/bin/coverage-badge /path/to/clover.xml,/path/to/clover2.xml /path/to/badge/destination.svg test-name +``` + +## Acknowledgements + +This library is inspired by [JASchilz/PHPCoverageBadge](https://github.com/JASchilz/PHPCoverageBadge) \ No newline at end of file diff --git a/composer.json b/composer.json index e8eebfa..76868f8 100644 --- a/composer.json +++ b/composer.json @@ -30,6 +30,6 @@ "scripts": { "lint": "phpcs --ignore=/vendor/* --standard=PSR12 .", "lint:fix": "phpcbf --ignore=/vendor/* --standard=PSR12 .", - "test": "phpunit --testdox --coverage-clover coverage/clover.xml --coverage-filter src/" + "test": "phpunit --testdox --coverage-clover coverage/clover.xml --coverage-html coverage --coverage-filter src/" } } diff --git a/phpunit.xml b/phpunit.xml index 09b3621..3e737d4 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,7 +2,7 @@ - ./Tests/ + ./tests/