Tests: Refresh PHPUnit config #60
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: CI for Plugin Boilerplate | |
on: [push] | |
jobs: | |
lint: | |
name: Lint and code standards | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
- name: Setup PHP 7.4 | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '7.4' | |
coverage: none | |
extensions: mbstring # Just enough to keep phpunit happy when installing Composer dependencies. | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress --no-suggest | |
# Needed as runs-on: system doesn't have xml-lint by default. | |
- name: Lint .phpcs.xml.dist | |
uses: ChristophWurst/xmllint-action@v1 | |
with: | |
xml-file: ./.phpcs.xml.dist | |
xml-schema-file: ./vendor/squizlabs/php_codesniffer/phpcs.xsd | |
# Needed as runs-on: system doesn't have xml-lint by default. | |
- name: Lint phpunit.xml.dist | |
uses: ChristophWurst/xmllint-action@v1 | |
with: | |
xml-file: ./phpunit.xml.dist | |
xml-schema-file: ./vendor/phpunit/phpunit/phpunit.xsd | |
- name: Lint PHP files | |
run: bin/php-lint | |
- name: Run Psalm | |
run: composer psalm | |
continue-on-error: true | |
- name: Run PHPCS | |
run: composer phpcs | |
supported-php-versions: | |
name: Determine Supported PHP Versions | |
runs-on: ubuntu-latest | |
outputs: | |
extensions: ${{ steps.supported-versions-matrix.outputs.extensions }} | |
version: ${{ steps.supported-versions-matrix.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: supported-versions-matrix | |
uses: WyriHaximus/github-action-composer-php-versions-in-range@v1 | |
test: | |
name: Unit and Integration tests | |
needs: | |
- supported-php-versions | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
php: ${{ fromJson(needs.supported-php-versions.outputs.version) }} | |
wordpress: [ 'latest' ] | |
include: | |
- php: '8.0' | |
wordpress: '6.0' | |
- php: '8.0' | |
wordpress: '6.1' | |
- php: '8.2' | |
wordpress: 'trunk' | |
experimental: true | |
- php: '8.3' | |
wordpress: 'trunk' | |
experimental: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
php-version: ${{ matrix.php }} | |
coverage: pcov | |
# https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions | |
extensions: curl, dom, exif, fileinfo, hash, json, mbstring, mysqli, libsodium, openssl, pcre, imagick, xml, zip | |
- name: Install dependencies | |
run: | | |
composer install --prefer-dist --no-progress --no-suggest | |
composer require pcov/clobber --dev | |
vendor/bin/pcov clobber | |
# See see https://dev.to/swashata/setup-php-pcov-for-5-times-faster-phpunit-code-coverage-3d9c | |
- name: Setup Problem Matchers for PHPUnit | |
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | |
- name: Run unit tests | |
run: composer unit | |
- name: Run infection tests | |
run: composer infection | |
continue-on-error: true | |
- name: Start MySQL Service | |
run: sudo systemctl start mysql.service | |
- name: Prepare environment | |
run: composer prepare | |
- name: Run integration tests | |
run: composer integration |