build #437
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: build | |
on: | |
workflow_dispatch: | |
push: | |
schedule: | |
- cron: '0 12 * * 0' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php: ['7.1', '7.4', '8.0', '8.1', '8.2', '8.3'] | |
composer: ['--prefer-lowest', ''] | |
exclude: | |
- php: '8.0' | |
composer: '--prefer-lowest' | |
- php: '8.1' | |
composer: '--prefer-lowest' | |
- php: '8.2' | |
composer: '--prefer-lowest' | |
- php: '8.3' | |
composer: '--prefer-lowest' | |
steps: | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: dom, json, mbstring, libxml | |
coverage: xdebug | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
- name: Prepare Composer cache vars | |
id: composer | |
run: | | |
echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
echo "cache_key=$(date +'%Y-%m-%d')-${{ runner.os }}-${{ matrix.php }}${{ matrix.composer }}-composer-" >> $GITHUB_OUTPUT | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer.outputs.cache_dir }} | |
key: ${{ steps.composer.outputs.cache_key }}${{ hashFiles('**/composer.json') }} | |
restore-keys: ${{ steps.composer.outputs.cache_key }} | |
- name: Update Composer dependencies | |
run: composer update ${{ matrix.composer }} --prefer-dist --no-progress --no-suggest --no-interaction | |
- name: Run PHP Code Sniffer | |
run: composer run-script test:phpcs | |
if: success() | |
- name: Run PHPStan | |
run: composer run-script test:phpstan | |
if: success() || failure() | |
# Remove after drop PHPUnit version < 9.3 support | |
- name: Select PHPUnit config | |
run: | | |
PHPUNIT_VERSION=$(composer show phpunit/phpunit | grep -oP "versions : \* \K.+") | |
PHPUNIT_VERSION_MAJOR=$(echo $PHPUNIT_VERSION | grep -oP "^\d+") | |
PHPUNIT_VERSION_MINOR=$(echo $PHPUNIT_VERSION | grep -oP "\d+\.\K\d+") | |
echo "PHPUnit version: $PHPUNIT_VERSION" | |
if [[ $PHPUNIT_VERSION_MAJOR -lt 9 || ( $PHPUNIT_VERSION_MAJOR -eq 9 && $PHPUNIT_VERSION_MINOR -lt 3 ) ]]; then | |
echo "Using deprecated config: \"phpunit.xml.deprecated\"" | |
mv phpunit.xml.deprecated phpunit.xml | |
else | |
echo "Using regular config: \"phpunit.xml\"" | |
fi | |
if: success() || failure() | |
- name: Run PHPUnit with coverage | |
run: composer run-script test:phpunit-coverage | |
if: success() || failure() | |
- name: Run Covelyzer | |
run: composer run-script test:covelyzer | |
if: success() || failure() | |
- name: Run PHPBench | |
run: composer run-script test:phpbench | |
if: (success() || failure()) && matrix.php != '7.1' && matrix.composer != '--prefer-lowest' | |
# Skip for PHP 7.1 or "prefer lowest" due to obsolete config syntax in v0.16 |