Skip to content

Commit

Permalink
Merge pull request #562 from equalizedigital/william/no-issue/add-cov…
Browse files Browse the repository at this point in the history
…erage-report-workflow

Add coverage report workflow
  • Loading branch information
pattonwebz authored Mar 29, 2024
2 parents 205410a + 43d87df commit 79588b6
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/code-coverage-and-coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Coverage Report

on:
push:
branches: [ develop ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: xdebug

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit and generate reports in clover and html format
run: ./vendor/bin/phpunit --coverage-clover=./coverage/clover.xml --coverage-html=./coverage/html

- name: Zip html coverage report
run: |
zip -r ./coverage/coverage-html.zip ./coverage/html
- name : Attach zipped coverage report as workflow artifact
uses: actions/upload-artifact@v2
with:
name: coverage-html
path: ./coverage/coverage-html.zip

- name: Convert coverage clover format to Coveralls format
run: |
composer global require php-coveralls/php-coveralls
~/.composer/vendor/bin/php-coveralls -v -x ./coverage/clover.xml -o ./coverage/coveralls.json
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/coveralls.json
11 changes: 11 additions & 0 deletions phpunit.dev.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,15 @@
<directory prefix="test-" suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./</directory>
</include>
<exclude>
<directory>./tests/</directory>
<directory>./vendor/</directory>
<directory>./node_modules/</directory>
<directory>./dist/</directory>
</exclude>
</coverage>
</phpunit>
11 changes: 11 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,15 @@
<directory prefix="test-" suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./</directory>
</include>
<exclude>
<directory>./tests/</directory>
<directory>./vendor/</directory>
<directory>./node_modules/</directory>
<directory>./dist/</directory>
</exclude>
</coverage>
</phpunit>

0 comments on commit 79588b6

Please sign in to comment.