build: fix release workflow #21
This file contains hidden or 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/CD | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| tests: | |
| name: Tests (PHP ${{ matrix.php }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['8.0', '8.1', '8.2', '8.3', '8.4'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: mbstring, intl | |
| coverage: xdebug | |
| - name: Get composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Setup PHPUnit config | |
| run: | | |
| if [[ "${{ matrix.php }}" == "8.0" ]]; then | |
| cp phpunit-9.xml.dist phpunit.xml.dist | |
| echo "Using PHPUnit 9 config for PHP ${{ matrix.php }}" | |
| elif [[ "${{ matrix.php }}" == "8.1" ]]; then | |
| cp phpunit-10.xml.dist phpunit.xml.dist | |
| echo "Using PHPUnit 10 config for PHP ${{ matrix.php }}" | |
| fi | |
| - name: Run tests | |
| run: | | |
| if [[ "${{ matrix.php }}" == "8.0" ]]; then | |
| # Run PHPUnit directly for PHP 8.0 to avoid grumphp issues | |
| vendor/bin/phpunit | |
| else | |
| # Use grumphp for other PHP versions | |
| composer test | |
| fi | |
| - name: Run tests with coverage | |
| if: matrix.php == '8.4' | |
| run: vendor/bin/phpunit --coverage-clover=coverage.xml | |
| - name: Upload coverage to Codecov | |
| if: matrix.php == '8.4' | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage.xml | |
| code-quality: | |
| name: Code Quality | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.4' | |
| extensions: mbstring, intl | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Run PHP CS Fixer | |
| run: composer lint | |
| - name: Run PHPStan | |
| run: composer static-analysis | |
| - name: Run security check | |
| run: composer security | |
| - name: Run PHPMND | |
| run: composer code-quality |