Skip to content

Commit e349af5

Browse files
committed
[TASK] Switch our code coverage CI from Codacy to Coveralls
Coveralls does not require an API key, provides a nice GitHub Action, and it can post code coverage comments to PRs. Also add a code coverage badge to the README. Also align the GitHub Action workflow with that of our sister project Emogrifier. Also add a Composer script for running the tests with coverage. Fixes #535 Fixes #299
1 parent 5a25712 commit e349af5

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

.github/workflows/codecoverage.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ jobs:
1515
runs-on: ubuntu-22.04
1616

1717
strategy:
18+
fail-fast: false
1819
matrix:
19-
php-version: [ '7.4' ]
20+
php-version:
21+
- '7.4'
22+
dependencies:
23+
- highest
2024

2125
steps:
2226
- name: Checkout
@@ -30,28 +34,39 @@ jobs:
3034
tools: composer:v2
3135
coverage: xdebug
3236

37+
- name: Show the Composer version
38+
run: composer --version
39+
3340
- name: Show the Composer configuration
3441
run: composer config --global --list
3542

3643
- name: Cache dependencies installed with composer
3744
uses: actions/cache@v4
3845
with:
3946
path: ~/.cache/composer
40-
key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
47+
key: php${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
4148
restore-keys: |
42-
php${{ matrix.php-version }}-composer-
49+
php${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-
4350
4451
- name: Install Composer dependencies
4552
run: |
46-
composer update --with-dependencies --no-progress;
53+
if [[ "${{ matrix.dependencies }}" == 'lowest' ]]; then
54+
DEPENDENCIES='--prefer-lowest';
55+
else
56+
DEPENDENCIES='';
57+
fi;
58+
composer install --no-progress;
59+
composer update --with-dependencies --no-progress "${DEPENDENCIES}";
4760
composer show;
4861
4962
- name: Run Tests
50-
run: ./vendor/bin/phpunit --coverage-clover build/coverage/xml
63+
run: composer ci:tests:coverage
64+
65+
- name: Show generated coverage files
66+
run: ls -lah
5167

52-
- name: Upload coverage results to Codacy
68+
- name: Upload coverage results to Coveralls
69+
uses: coverallsapp/github-action@v2
5370
env:
54-
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
55-
if: "${{ env.CODACY_PROJECT_TOKEN != '' }}"
56-
run: |
57-
./vendor/bin/codacycoverage clover build/coverage/xml
71+
github-token: ${{ secrets.GITHUB_TOKEN }}
72+
file: coverage.xml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/.php_cs.cache
44
/.phpunit.result.cache
55
/composer.lock
6+
/coverage.xml
67
/phpstan.neon
78
/vendor/
89
!/.phive/phars.xml

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# PHP CSS Parser
22

33
[![Build Status](https://github.com/MyIntervals/PHP-CSS-Parser/workflows/CI/badge.svg?branch=main)](https://github.com/MyIntervals/PHP-CSS-Parser/actions/)
4+
[![Coverage Status](https://coveralls.io/repos/github/MyIntervals/PHP-CSS-Parser/badge.svg?branch=main)](https://coveralls.io/github/MyIntervals/PHP-CSS-Parser?branch=main)
45

56
A Parser for CSS Files written in PHP. Allows extraction of CSS files into a data structure, manipulation of said structure and output as (optimized) CSS.
67

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"ext-iconv": "*"
2828
},
2929
"require-dev": {
30-
"codacy/coverage": "^1.4.3",
3130
"php-parallel-lint/php-parallel-lint": "^1.4.0",
3231
"phpstan/extension-installer": "^1.4.1",
3332
"phpstan/phpstan": "^1.11.11",
@@ -83,6 +82,7 @@
8382
"ci:tests": [
8483
"@ci:tests:unit"
8584
],
85+
"ci:tests:coverage": "phpunit --do-not-cache-result --coverage-clover=coverage.xml",
8686
"ci:tests:sof": "phpunit --stop-on-failure --do-not-cache-result",
8787
"ci:tests:unit": "phpunit --do-not-cache-result",
8888
"fix:php": [
@@ -102,6 +102,7 @@
102102
"ci:php:rector": "Checks the code for possible code updates and refactoring.",
103103
"ci:static": "Runs all static code analysis checks for the code.",
104104
"ci:tests": "Runs all dynamic tests (i.e., currently, the unit tests).",
105+
"ci:tests:coverage": "Runs the unit tests with code coverage.",
105106
"ci:tests:sof": "Runs the unit tests and stops at the first failure.",
106107
"ci:tests:unit": "Runs all unit tests.",
107108
"fix:php": "Autofixes all autofixable issues in the PHP code.",

0 commit comments

Comments
 (0)