Skip to content

Commit

Permalink
Add CodeClimate code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioheleno committed Jul 22, 2021
1 parent 2f498aa commit 17e7e92
Show file tree
Hide file tree
Showing 3 changed files with 341 additions and 201 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
name: PHPUnit
name: "Continuous Integration"

on:
push:
branches: [ main ]
paths-ignore:
- 'doc/**'
pull_request:
branches: [ main ]
paths-ignore:
- 'doc/**'

jobs:
test:
name: PHP ${{ matrix.php_version }}
tests:
name: PHP ${{ matrix.php-version }}

runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}

strategy:
fail-fast: false
matrix:
php_version: ['7.4', '8.0', '8.1']
composer_flags: ['--ignore-platform-reqs', '']
php-version:
- "7.4"
- "8.0"
experimental: [false]
include:
- php_version: '8.1'
- php-version: "8.1"
experimental: true

steps:
Expand All @@ -27,7 +32,7 @@ jobs:
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@2.12.0
with:
php-version: ${{ matrix.php_version }}
php-version: ${{ matrix.php-version }}
tools: composer:v2
coverage: pcov

Expand All @@ -42,12 +47,21 @@ jobs:
uses: actions/cache@v2.1.6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php_version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php_version }}-
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install ${{ matrix.composer_flags }} --prefer-dist --no-progress --optimize-autoloader --no-interaction
run: composer install --prefer-dist --no-progress --optimize-autoloader --no-interaction

- name: Run PHPUnit test suite
run: composer run-script phpunit
run: composer run-script test-ci

- name: Publish code coverage
uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: composer run-script test-coverage
coverageLocations: |
${{github.workspace}}/clover.xml:clover
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
}
},
"config": {
"sort-packages": true
"optimize-autoloader": true,
"sort-packages": true,
"preferred-install": "dist"
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.4",
"ext-pcntl": "*",
Expand All @@ -47,6 +51,8 @@
"phpstan": "vendor/bin/phpstan analyse --level=max --autoload-file=vendor/autoload.php bin/ public/ src/",
"phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation",
"psalm": "vendor/bin/psalm --taint-analysis",
"test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation",
"test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml",
"test": [
"@lint",
"@phpunit",
Expand All @@ -61,6 +67,8 @@
"phpstan": "Runs complete codebase static analysis",
"phpunit": "Runs unit and functional testing",
"psalm": "Runs complete codebase taint analysis",
"test-ci": "Runs library test suite (for continuous integration)",
"test-coverage": "Runs test-coverage analysis",
"test": "Runs all tests"
}
}
Loading

0 comments on commit 17e7e92

Please sign in to comment.