From 3235622bfcda95a0d0be0f9740777708a750272d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Fri, 18 Apr 2025 09:34:46 +0200 Subject: [PATCH 1/3] feat: add dependencies for workflow --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index eddad93..4a7157a 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "ext-mbstring": "*" }, "require-dev": { - "phpunit/phpunit": "^9.5.10" + "phpunit/phpunit": "^9.5.10", + "phpstan/phpstan": "^2.1" }, "scripts": { "test": "vendor/bin/phpunit" From 93e17fd90fbf17bf882f4db52801626230c3c21f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Fri, 18 Apr 2025 09:34:57 +0200 Subject: [PATCH 2/3] feat: add config for phpstan --- phpstan.neon | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 phpstan.neon diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..46b0f47 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 5 + paths: + - src + - tests From 39bf338d79471bc138c041b89223c21641dd85c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Fri, 18 Apr 2025 09:35:21 +0200 Subject: [PATCH 3/3] feat: update workflow with cache composer and phpstan --- .github/workflows/php.yml | 45 +++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c22980e..a09cf0e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -7,37 +7,54 @@ on: branches: [master] jobs: - phpunit: - name: PHPUnit + name: PHPUnit - PHP ${{ matrix.php-version }} - ${{ matrix.dependency-versions }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php-version: - - "8.0" - - "8.1" - - "8.2" - - "8.3" - dependency-versions: - - "lowest" - - "highest" + php-version: ["8.1", "8.2", "8.3"] + dependency-versions: ["lowest", "highest"] steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - coverage: none + coverage: ${{ (matrix.php-version == '8.3' && matrix.dependency-versions == 'highest') && 'xdebug' || 'none' }} + + - name: Cache Composer dependencies + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ matrix.dependency-versions }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ matrix.dependency-versions }}- - - name: Install composer dependencies + - name: Install Composer dependencies uses: ramsey/composer-install@v2 with: dependency-versions: ${{ matrix.dependency-versions }} + - name: Run static analysis (PHPStan) + run: vendor/bin/phpstan analyse --level=5 src/ + continue-on-error: true + - name: Run PHPUnit + if: matrix.php-version != '8.3' || matrix.dependency-versions != 'highest' run: vendor/bin/phpunit + + - name: Run PHPUnit with Coverage + if: matrix.php-version == '8.3' && matrix.dependency-versions == 'highest' + run: vendor/bin/phpunit --coverage-clover=coverage.xml + + - name: Upload coverage to Codecov + if: matrix.php-version == '8.3' && matrix.dependency-versions == 'highest' + uses: codecov/codecov-action@v3 + with: + files: ./coverage.xml + fail_ci_if_error: true