Tests: Fix whitespace #136
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 | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
unit-tests: | |
name: Unit tests (PHP ${{ matrix.php-versions }}) | |
runs-on: ubuntu-22.04 | |
continue-on-error: ${{ matrix.experimental }} | |
strategy: | |
fail-fast: false | |
matrix: | |
php-versions: ['7.4', '8.0', '8.1', '8.2','8.3'] | |
experimental: [false] | |
include: | |
- php-versions: '8.4' | |
experimental: true | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# Disabling shallow clone is recommended for improving relevancy of reporting | |
fetch-depth: 0 | |
- name: Setup PHP, with Composer and extensions | |
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php | |
with: | |
php-version: ${{ matrix.php-versions }} | |
coverage: none | |
extensions: gd | |
- name: Setup problem matchers for PHPUnit | |
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | |
- name: Remove unused Composer dependencies | |
run: composer remove humbug/php-scoper sirbrillig/phpcs-import-detection phpstan/phpstan szepeviktor/phpstan-wordpress --dev --no-interaction --no-update | |
- 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 update --prefer-dist | |
- name: Run PHPUnit tests | |
run: composer run-script test | |
coverage: | |
name: Coverage & SonarCloud (PHP ${{ matrix.php-versions }}) | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: true | |
matrix: | |
php-versions: ['8.3'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# Disabling shallow clone is recommended for improving relevancy of reporting | |
fetch-depth: 0 | |
- name: Setup PHP, with Composer and extensions | |
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php | |
with: | |
php-version: ${{ matrix.php-versions }} | |
coverage: xdebug | |
extensions: gd | |
- name: Remove unused Composer dependencies | |
run: composer remove humbug/php-scoper sirbrillig/phpcs-import-detection szepeviktor/phpstan-wordpress --dev --no-interaction --no-update | |
- 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 update --prefer-dist | |
- name: Run PHPUnit tests with coverage generation | |
run: | | |
mkdir -p build/logs | |
composer run-script test -- --coverage-clover build/logs/phpunit.coverage.xml --log-junit=build/logs/phpunit.test-report.xml | |
- name: Fix code coverage paths for SonarCloud | |
working-directory: ./build/logs/ | |
run: | | |
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' phpunit.coverage.xml | |
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' phpunit.test-report.xml | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
if: env.SONAR_TOKEN != '' | |
phpcs: | |
name: Check Coding Standards | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: true | |
matrix: | |
php-versions: ['8.3'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup PHP, with Composer and extensions | |
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php | |
with: | |
php-version: ${{ matrix.php-versions }} | |
coverage: none | |
extensions: gd | |
tools: cs2pr | |
- name: Remove unused Composer dependencies | |
run: composer remove humbug/php-scoper --dev --no-interaction --no-update | |
- 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 update --prefer-dist | |
- name: Run PHPCS checks | |
run: vendor/bin/phpcs -q src/ --extensions=php --report=checkstyle | cs2pr | |
phpstan: | |
name: Static Analysis | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: true | |
matrix: | |
php-versions: ['8.3'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup PHP, with Composer and extensions | |
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php | |
with: | |
php-version: ${{ matrix.php-versions }} | |
coverage: none | |
extensions: gd | |
- name: Remove unused Composer dependencies | |
run: composer remove humbug/php-scoper sirbrillig/phpcs-import-detection --dev --no-interaction --no-update | |
- 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 update --prefer-dist | |
- name: Run PHPStan | |
run: composer run-script phpstan | |
spellchecking: | |
name: Spellchecking | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Run typos | |
uses: crate-ci/typos@master |