[FEATURE] Add coverage to unit tests #388
Workflow file for this run
This file contains 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: Tests | |
on: | |
pull_request: | |
jobs: | |
unit-test: | |
name: "Unit tests" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout repo" | |
uses: actions/checkout@v4 | |
- name: "Install PHP" | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
tools: composer:v2 | |
coverage: xdebug | |
- name: "Install composer dependencies" | |
run: composer install --prefer-dist --no-progress | |
- name: "Run unit tests with coverage" | |
run: composer run test:coverage | |
- name: "Send coverage to Coveralls" | |
env: | |
COVERALLS_REPO_TOKEN: ${{ github.token }} | |
if: ${{ env.COVERALLS_REPO_TOKEN && matrix.coverage }} | |
uses: coverallsapp/github-action@v2 | |
with: | |
github-token: ${{ env.COVERALLS_REPO_TOKEN }} | |
flag-name: "Unit" | |
allow-empty: false | |
wp-test: | |
name: "WordPress tests with WP ${{ matrix.wp_version }}" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
wp_version: ["6.3", "6.4", "6.5", "6.6", "6.7", "latest"] | |
services: | |
mysql: | |
image: mysql:9.1 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: false | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10 | |
steps: | |
- name: "Install subversion" | |
run: sudo apt-get install -y subversion | |
- name: "Checkout repo" | |
uses: actions/checkout@v4 | |
- name: "Install PHP" | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
tools: composer:v2 | |
coverage: none | |
- name: "Install composer dependencies" | |
run: composer install --prefer-dist --no-progress | |
# WordPress tests works only with PHPUnit 9.x :( | |
# https://github.com/dimitriBouteille/wp-orm/actions/runs/11192354429/job/31116408495 | |
- name: "Install PHPUnit v9" | |
run: | | |
composer require --dev phpunit/phpunit ^9.0 -W | |
composer require --dev yoast/phpunit-polyfills ^3.0 -W | |
- name: "Install WP" | |
shell: bash | |
run: ./config/scripts/install-wp-tests.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp_version }} | |
- name: "Run WordPress tests" | |
run: composer run test:wordPress |