Unit #5146
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: Unit | |
on: | |
pull_request: | |
push: | |
schedule: | |
- cron: '0 0/2 * * *' | |
jobs: | |
smoke-test: | |
name: Smoke | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/mvorisek/image-php:${{ matrix.php }} | |
strategy: | |
fail-fast: false | |
matrix: | |
php: ['latest'] | |
type: ['Phpunit'] | |
include: | |
- php: 'latest' | |
type: 'CodingStyle' | |
- php: 'latest' | |
type: 'StaticAnalysis' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure PHP | |
run: | | |
rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini | |
php --version | |
- name: Setup cache 1/2 | |
id: composer-cache | |
run: | | |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Setup cache 2/2 | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-smoke-${{ matrix.php }}-${{ matrix.type }}-${{ hashFiles('composer.json') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Install PHP dependencies | |
run: | | |
if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpunit/phpunit johnkary/phpunit-speedtrap --dev; fi | |
if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer --dev; fi | |
if [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpstan/\* behat/\* --dev; fi | |
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader | |
- name: "Run tests: SQLite (only for Phpunit)" | |
if: startsWith(matrix.type, 'Phpunit') | |
run: | | |
echo "not implemented" || vendor/bin/phpunit --exclude-group none --no-coverage -v | |
- name: Check Coding Style (only for CodingStyle) | |
if: matrix.type == 'CodingStyle' | |
run: | | |
if [ "$(find demos/ -name '*.php' -print0 | xargs -0 grep -L "namespace Atk4\\\\Chart\\\\Demos[;\\\\]" | tee /dev/fd/2)" ]; then echo 'All demos/ files must have namespace declared' && (exit 1); fi | |
vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --verbose | |
composer config --unset version && composer config --unset require-release | |
composer validate --strict --no-check-lock && composer normalize --dry-run --no-check-lock | |
- name: Run Static Analysis (only for StaticAnalysis) | |
if: matrix.type == 'StaticAnalysis' | |
run: | | |
echo "memory_limit = 2G" > /usr/local/etc/php/conf.d/custom-memory-limit.ini | |
vendor/bin/phpstan analyse |