diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..e0d896a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,46 @@ +name: Coverage + +on: + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + workflow_dispatch: + +jobs: + coverage: + runs-on: ubuntu-latest + + name: Coverage (PHP 8.4 - Laravel 12) + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv + coverage: xdebug + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Install dependencies + run: | + composer remove "crescat-io/saloon-sdk-generator" "larastan/larastan" "laravel/boost" "laravel/pint" --dev --no-interaction + composer require "laravel/framework:12.*" "saloonphp/laravel-plugin" --no-interaction --no-update + composer update --prefer-dist --no-interaction + + - name: Run tests with coverage + run: ./vendor/bin/pest --coverage --coverage-clover coverage.xml + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + files: ./coverage.xml + fail_ci_if_error: false + verbose: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c86395e..22df1b4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,7 +38,11 @@ jobs: - name: Install dependencies run: | composer remove "crescat-io/saloon-sdk-generator" "larastan/larastan" "laravel/boost" "laravel/pint" --dev --no-interaction - composer require "laravel/framework:${{ matrix.laravel }}" " saloonphp/laravel-plugin" --no-interaction --no-update + if [[ "${{ matrix.laravel }}" == "10.*" ]]; then + composer require "laravel/framework:${{ matrix.laravel }}" "saloonphp/laravel-plugin:^3.5.0" --no-interaction --no-update + else + composer require "laravel/framework:${{ matrix.laravel }}" "saloonphp/laravel-plugin" --no-interaction --no-update + fi composer update --prefer-dist --no-interaction - name: Run Pest tests diff --git a/README.md b/README.md index 7334abb..629472c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Timatic PHP SDK [![Tests](https://github.com/Timatic/timatic-php-sdk/actions/workflows/tests.yml/badge.svg)](https://github.com/Timatic/timatic-php-sdk/actions/workflows/tests.yml) +[![codecov](https://codecov.io/gh/Timatic/timatic-php-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/Timatic/timatic-php-sdk) [![Code Style](https://github.com/Timatic/timatic-php-sdk/actions/workflows/code-style.yml/badge.svg)](https://github.com/Timatic/timatic-php-sdk/actions/workflows/code-style.yml) [![Static Analysis](https://github.com/Timatic/timatic-php-sdk/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/Timatic/timatic-php-sdk/actions/workflows/static-analysis.yml) @@ -245,7 +246,11 @@ The SDK uses a custom `JsonApiDtoGenerator` that: ### Running Tests ```bash +# Run tests composer test + +# Run tests with code coverage +composer coverage ``` ## License diff --git a/composer.json b/composer.json index 355847f..32d726c 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,7 @@ ], "scripts": { "test": "pest", + "coverage": "pest --coverage --coverage-clover coverage.xml", "format": "pint", "analyse": "phpstan analyse --memory-limit=2G", "regenerate": [