Skip to content

Commit 9c7c05a

Browse files
committed
Add CodeClimate code coveraget
1 parent 2f498aa commit 9c7c05a

File tree

3 files changed

+341
-201
lines changed

3 files changed

+341
-201
lines changed
Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
name: PHPUnit
1+
name: "Continuous Integration"
22

33
on:
44
push:
5-
branches: [ main ]
5+
paths-ignore:
6+
- 'doc/**'
67
pull_request:
7-
branches: [ main ]
8+
paths-ignore:
9+
- 'doc/**'
810

911
jobs:
10-
test:
11-
name: PHP ${{ matrix.php_version }}
12+
tests:
13+
name: PHP ${{ matrix.php-version }}
14+
1215
runs-on: ubuntu-latest
1316
continue-on-error: ${{ matrix.experimental }}
17+
1418
strategy:
1519
fail-fast: false
1620
matrix:
17-
php_version: ['7.4', '8.0', '8.1']
18-
composer_flags: ['--ignore-platform-reqs', '']
21+
php-version:
22+
- "7.4"
23+
- "8.0"
1924
experimental: [false]
2025
include:
21-
- php_version: '8.1'
26+
- php-version: "8.1"
2227
experimental: true
2328

2429
steps:
@@ -27,7 +32,7 @@ jobs:
2732
- name: Setup PHP with PECL extension
2833
uses: shivammathur/[email protected]
2934
with:
30-
php-version: ${{ matrix.php_version }}
35+
php-version: ${{ matrix.php-version }}
3136
tools: composer:v2
3237
coverage: pcov
3338

@@ -42,12 +47,21 @@ jobs:
4247
uses: actions/[email protected]
4348
with:
4449
path: ${{ steps.composer-cache.outputs.dir }}
45-
key: ${{ runner.os }}-php-${{ matrix.php_version }}-${{ hashFiles('**/composer.lock') }}
46-
restore-keys: ${{ runner.os }}-php-${{ matrix.php_version }}-
50+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
51+
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-
4752

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

5257
- name: Run PHPUnit test suite
53-
run: composer run-script phpunit
58+
run: composer run-script test-ci
59+
60+
- name: Publish code coverage
61+
uses: paambaati/[email protected]
62+
env:
63+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
64+
with:
65+
coverageCommand: composer run-script test-coverage
66+
coverageLocations: |
67+
${{github.workspace}}/clover.xml:clover

composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
}
2121
},
2222
"config": {
23-
"sort-packages": true
23+
"optimize-autoloader": true,
24+
"sort-packages": true,
25+
"preferred-install": "dist"
2426
},
27+
"minimum-stability": "dev",
28+
"prefer-stable": true,
2529
"require": {
2630
"php": ">=7.4",
2731
"ext-pcntl": "*",
@@ -47,6 +51,8 @@
4751
"phpstan": "vendor/bin/phpstan analyse --level=max --autoload-file=vendor/autoload.php bin/ public/ src/",
4852
"phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation",
4953
"psalm": "vendor/bin/psalm --taint-analysis",
54+
"test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation",
55+
"test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml",
5056
"test": [
5157
"@lint",
5258
"@phpunit",
@@ -61,6 +67,8 @@
6167
"phpstan": "Runs complete codebase static analysis",
6268
"phpunit": "Runs unit and functional testing",
6369
"psalm": "Runs complete codebase taint analysis",
70+
"test-ci": "Runs library test suite (for continuous integration)",
71+
"test-coverage": "Runs test-coverage analysis",
6472
"test": "Runs all tests"
6573
}
6674
}

0 commit comments

Comments
 (0)