Code. Codecov YML implemented. #1
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: | |
| push: | |
| branches: [ dev, fix, beta ] | |
| 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️⃣ Настройка PHP | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ env.PHP_VERSION }} | |
| # 2️⃣ Запуск MySQL | |
| - name: Run MySQL server | |
| run: sudo systemctl start mysql | |
| # 3️⃣ Checkout кода | |
| - name: Code Checkout | |
| uses: actions/checkout@v4 | |
| # 4️⃣ Исполняем скрипт WP setup | |
| - name: Make the 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 | |
| # 5️⃣ Запуск PHPUnit с clover | |
| - name: Run PHPUnit Coverage | |
| run: ./vendor/bin/phpunit \ | |
| --configuration tests/phpunit.xml \ | |
| --coverage-clover=coverage.clover \ | |
| --colors=never | |
| # 6️⃣ Загрузка на Codecov | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage.clover | |
| fail_ci_if_error: true | |
| flags: unittests | |
| # скрыть indirect changes в комментарии PR | |
| comment: "true" | |
| comment-indirect: "false" | |
| # 7️⃣ Сохранение артефакта | |
| - name: Upload coverage artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage.clover | |
| retention-days: 5 |