Merge pull request #181 from aik099/codecov-tests-feat #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
check_composer: | |
name: Check composer.json | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: shivammathur/setup-php@v2 | |
with: | |
coverage: none | |
php-version: '8.2' | |
- run: composer validate --strict --no-check-lock | |
static_analysis: | |
name: Static analysis | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: shivammathur/setup-php@v2 | |
with: | |
coverage: none | |
php-version: '8.2' | |
- name: Install dependencies | |
run: composer update --ansi --no-progress --prefer-dist --no-interaction | |
- run: vendor/bin/phpstan analyze | |
tests: | |
name: Tests on PHP ${{ matrix.php }} with ${{ matrix.implementation }}${{ matrix.name_suffix }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] | |
minimum_stability: [ 'stable' ] | |
name_suffix: [ '' ] | |
implementation: [ 'http_kernel' ] | |
include: | |
- php: '8.2' | |
minimum_stability: dev | |
implementation: 'http_kernel' | |
name_suffix: ' and dev deps' | |
- php: '8.2' | |
implementation: http_client | |
- php: '8.2' | |
minimum_stability: dev | |
implementation: 'http_client' | |
name_suffix: ' and dev deps' | |
fail-fast: false | |
env: | |
MATRIX_PHP: ${{ matrix.php }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
coverage: "xdebug" | |
php-version: "${{ matrix.php }}" | |
tools: composer | |
- name: Configure for minimum stability | |
if: "${{ matrix.minimum_stability == 'dev' }}" | |
run: | | |
composer config minimum-stability dev | |
- name: Install dependencies | |
run: | | |
composer update --no-interaction --prefer-dist | |
- name: Setup Mink test server | |
if: "${{ matrix.implementation == 'http_client'}}" | |
run: | | |
mkdir ./logs | |
./vendor/bin/mink-test-server &> ./logs/mink-test-server.log & | |
- name: Wait for browser & PHP to start | |
if: "${{ matrix.implementation == 'http_client'}}" | |
run: | | |
while ! nc -z localhost 8002 </dev/null; do echo Waiting for PHP server to start...; sleep 1; done | |
- name: Run tests | |
if: "${{ matrix.implementation == 'http_kernel'}}" | |
run: | | |
vendor/bin/phpunit -v --coverage-clover=coverage.clover --log-junit junit.xml | |
- name: Run tests | |
if: "${{ matrix.implementation == 'http_client'}}" | |
run: | | |
vendor/bin/phpunit -c phpunit.http_client.xml -v --coverage-clover=coverage.clover --log-junit junit.xml | |
- name: Upload coverage to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.clover | |
- name: Upload test results to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/test-results-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |