Skip to content

Commit

Permalink
Added CodeCov coverage report support and badge (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhu authored Feb 16, 2024
1 parent a0bcb5a commit 70f5ec9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
40 changes: 34 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- trying
- staging
- main
- feature/**

jobs:
yaml-lint:
Expand Down Expand Up @@ -73,7 +74,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
coverage: pcov
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install dependencies
Expand All @@ -82,29 +83,34 @@ jobs:
composer update --prefer-dist --no-progress
- name: Run test suite - default HTTP client (Guzzle 7)
run: |
sh scripts/tests.sh
sh scripts/tests.sh --coverage-clover coverage-guzzle7.xml
composer remove --dev guzzlehttp/guzzle http-interop/http-factory-guzzle
- name: Run test suite - php-http/guzzle7-adapter
run: |
composer require --dev php-http/guzzle7-adapter http-interop/http-factory-guzzle
sh scripts/tests.sh
sh scripts/tests.sh --coverage-clover coverage-guzzle7-adapter.xml
composer remove --dev php-http/guzzle7-adapter http-interop/http-factory-guzzle
- name: Run test suite - symfony/http-client
run: |
composer require --dev symfony/http-client nyholm/psr7
sh scripts/tests.sh
sh scripts/tests.sh --coverage-clover coverage-symfony-http-client.xml
composer remove --dev symfony/http-client nyholm/psr7
- name: Run test suite - php-http/curl-client
run: |
composer require --dev php-http/curl-client nyholm/psr7
sh scripts/tests.sh
sh scripts/tests.sh --coverage-clover coverage-nyholm-psr7.xml
composer remove --dev php-http/curl-client nyholm/psr7
- name: Run test suite - kriswallsmith/buzz
run: |
composer require --dev kriswallsmith/buzz nyholm/psr7 --with-all-dependencies
composer update php-http/client-common:2.6.0 php-http/httplug:2.3.0 psr/http-message
sh scripts/tests.sh
sh scripts/tests.sh --coverage-clover coverage-kriswallsmith-buzz.xml
composer remove --dev kriswallsmith/buzz nyholm/psr7
- name: Upload coverage file
uses: actions/upload-artifact@v4
with:
name: 'phpunit-${{ matrix.php-versions }}-coverage'
path: 'coverage*.xml'

test_php_7_guzzle_6:
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR)
Expand Down Expand Up @@ -139,3 +145,25 @@ jobs:
run: |
composer require --dev php-http/guzzle6-adapter http-interop/http-factory-guzzle
sh scripts/tests.sh
upload-coverage:
name: Upload coverage to Codecov
runs-on: ubuntu-latest
needs:
- tests

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Download coverage files
uses: actions/download-artifact@v4
with:
path: reports

- name: Upload to Codecov
uses: codecov/codecov-action@v3
with:
directory: reports
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</h4>

<p align="center">
<a href="https://codecov.io/gh/meilisearch/meilisearch-php/branch/main"><img src="https://codecov.io/gh/meilisearch/meilisearch-php/branch/main/graph/badge.svg" alt="Codecov coverage"></a>
<a href="https://packagist.org/packages/meilisearch/meilisearch-php"><img src="https://img.shields.io/packagist/v/meilisearch/meilisearch-php" alt="Latest Stable Version"></a>
<a href="https://github.com/meilisearch/meilisearch-php/actions"><img src="https://github.com/meilisearch/meilisearch-php/workflows/Tests/badge.svg" alt="Test"></a>
<a href="https://github.com/meilisearch/meilisearch-php/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
Expand Down
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory>src/</directory>
</include>
</coverage>
<php>
<env name="MEILISEARCH_URL" value="http://localhost:7700"/>
<env name="MEILISEARCH_API_KEY" value="masterKey"/>
Expand Down
4 changes: 3 additions & 1 deletion scripts/tests.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ echo 'Setting FDs limit to 10000'
ulimit -Sn 10000

echo "Launching tests..."
vendor/bin/phpunit --color tests/
vendor/bin/phpunit --color tests/ "$@"

exit $?

0 comments on commit 70f5ec9

Please sign in to comment.