Merge pull request #137 from nlemoine/feat-sf-dotenv-7 #156
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: PHP Quality Assurance | |
on: | |
push: | |
paths: | |
- '**workflows/php-qa.yml' | |
- '**.php' | |
- '**templates/**' | |
- '**phpcs.xml.dist' | |
- '**phpunit.xml.dist' | |
- '**psalm.xml' | |
- '**composer.json' | |
pull_request: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
static-qa: | |
runs-on: ubuntu-latest | |
if: ${{ !contains(github.event.head_commit.message, 'skip qa') }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 7.4 | |
coverage: none | |
tools: cs2pr | |
- name: Setup Composer aut for GitHub | |
run: composer config github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} | |
- name: Install dependencies | |
uses: ramsey/composer-install@v2 | |
- name: Check code styles | |
run: ./vendor/bin/phpcs -q ${{ ((github.event_name == 'pull_request') && '--report-checkstyle="phpcs-report.xml" ') || '' }}--report-full --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | |
- name: Annotate code styles for PRs | |
if: ${{ github.event_name == 'pull_request' }} | |
run: cs2pr --graceful-warnings phpcs-report.xml | |
- name: Check Psalm | |
run: ./vendor/bin/psalm ${{ ((github.event_name == 'pull_request') && '--output-format=github ') || '' }} --no-suggestions --find-unused-psalm-suppress --no-diff --no-cache --no-file-cache | |
unit-tests: | |
runs-on: ubuntu-latest | |
if: ${{ !contains(github.event.head_commit.message, 'skip tests') }} | |
env: | |
USE_COVERAGE: no | |
strategy: | |
fail-fast: false | |
matrix: | |
php-ver: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ] | |
composer-ver: [ '^1', '~2.0.0', '~2.1.0', '~2.2.0', '~2.3.0', '~2.4.0', '~2.5.0' ] | |
exclude: | |
- php-ver: '7.1' | |
composer-ver: '~2.3.0' | |
- php-ver: '7.1' | |
composer-ver: '~2.4.0' | |
- php-ver: '7.1' | |
composer-ver: '~2.5.0' | |
- php-ver: '8.1' | |
composer-ver: '^1' | |
- php-ver: '8.1' | |
composer-ver: '~2.0.0' | |
- php-ver: '8.2' | |
composer-ver: '^1' | |
- php-ver: '8.2' | |
composer-ver: '~2.0.0' | |
- php-ver: '8.2' | |
composer-ver: '~2.1.0' | |
steps: | |
- name: Update "USE_COVERAGE" env var based on matrix | |
if: ${{ matrix.php-ver == '7.4' && matrix.composer-ver == '~2.3.0' }} | |
run: echo "USE_COVERAGE=yes" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-ver }} | |
# WP CLI does not support yet PHP 8.2, so we hide deprecation messages | |
ini-values: zend.assertions=1, error_reporting=${{ ((matrix.php-ver == '8.2') && 'E_ALL & ~E_DEPRECATED & ~E_STRICT') || 'E_ALL' }}, display_errors=${{ ((matrix.php-ver == '8.2') && 'Off') || 'On' }} | |
coverage: ${{ ((env.USE_COVERAGE == 'yes') && 'xdebug') || 'none' }} | |
- name: Adjust Composer dependencies | |
run: | | |
composer remove --dev --no-update "roave/security-advisories" | |
composer require --dev --no-update "composer/composer:${{ matrix.composer-ver }}" | |
- name: Install dependencies | |
uses: ramsey/composer-install@v2 | |
with: | |
dependency-versions: highest | |
- name: Run unit tests | |
run: | | |
./vendor/bin/phpunit --atleast-version 9 && ./vendor/bin/phpunit --migrate-configuration || echo 'Config does not need updates.' | |
./vendor/bin/phpunit ${{ ((env.USE_COVERAGE == 'yes') && '--coverage-html=coverage-report') || '--no-coverage' }} | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v3 | |
if: ${{ env.USE_COVERAGE == 'yes' }} | |
with: | |
name: coverage-report | |
path: coverage-report/ | |
lint: | |
runs-on: ubuntu-latest | |
if: ${{ !contains(github.event.head_commit.message, 'skip lint') }} | |
strategy: | |
fail-fast: true | |
matrix: | |
php-ver: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-ver }} | |
ini-values: zend.assertions=1, error_reporting=E_ALL, display_errors=On | |
tools: parallel-lint | |
- name: Check syntax error in sources | |
run: parallel-lint ./src/ |