diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 1562a68..a09cf0e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -7,36 +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" - - "8.4" - dependency-versions: - - "lowest" - - "highest" + php-version: ["8.1", "8.2", "8.3"] + dependency-versions: ["lowest", "highest"] steps: - - name: Checkout + - 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 + uses: ramsey/composer-install@v2 + with: + dependency-versions: ${{ matrix.dependency-versions }} - - name: Install composer dependencies - run: composer install --prefer-dist --no-progress + - 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 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" 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