Code. Codecov YML implemented. #2
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: Test Coverage | |
| on: | |
| pull_request: | |
| branches: [ dev, fix, beta ] | |
| env: | |
| PHP_VERSION: 7.4 | |
| jobs: | |
| coverage: | |
| name: PHPUnit Code Coverage | |
| runs-on: ubuntu-22.04 | |
| env: | |
| DB_CONNECTION: mysql | |
| DB_HOST: localhost | |
| DB_PORT: 3306 | |
| DB_DATABASE: wordpress_test | |
| DB_USERNAME: root | |
| DB_PASSWORD: root | |
| steps: | |
| # 1️⃣ Checkout кода | |
| - name: Code Checkout | |
| uses: actions/checkout@v4 | |
| # 2️⃣ Установка PHP и расширений | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ env.PHP_VERSION }} | |
| extensions: mbstring, intl, mysqli, xdebug | |
| # 3️⃣ Установка Composer зависимостей | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-interaction | |
| # 4️⃣ Запуск MySQL | |
| - name: Run MySQL server | |
| run: sudo systemctl start mysql | |
| # 5️⃣ WP тестовая база | |
| - name: Make WP setup script executable | |
| run: chmod +x ./tests/wp-test-setup.sh | |
| - name: Install WP develop | |
| run: ./tests/wp-test-setup.sh wordpress_test root root localhost latest | |
| # 6️⃣ Запуск PHPUnit с coverage | |
| - name: Run PHPUnit Coverage | |
| run: ./vendor/bin/phpunit \ | |
| --configuration tests/phpunit.xml \ | |
| --coverage-clover=coverage.clover \ | |
| --colors=never | |
| # 7️⃣ Загрузка на Codecov | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage.clover | |
| fail_ci_if_error: true | |
| flags: unittests | |
| comment: "true" | |
| comment-indirect: "false" | |
| # 8️⃣ Сохранение артефакта coverage | |
| - name: Upload coverage artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage.clover | |
| retention-days: 5 |