diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000..f383baa2 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,169 @@ +name: ๐Ÿงช Run Tests & ๐Ÿ› ๏ธ Static Analysis + +on: + push: + branches: + - main + - 2.x + pull_request: + schedule: + - cron: '0 0 * * *' # Daily at midnight + +jobs: + static-analysis: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ 8.2 ] + + name: ๐Ÿ˜ PHP ${{ matrix.php }} Static Analysis + + steps: + - name: ๐Ÿ“ฅ Checkout Code + uses: actions/checkout@v4 + + - name: ๐Ÿ”ง Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: ๐Ÿšš Cache Composer Dependencies + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('composer.json') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.php }}- + + - name: ๐Ÿ“ฆ Install Dependencies + run: | + composer config --global allow-plugins true + composer install + + - name: ๐Ÿงน Run PHP CS Fixer (Code Style) + run: vendor/bin/php-cs-fixer fix --dry-run + + - name: ๐Ÿ” Run PHPStan (Static Analysis) + run: vendor/bin/phpstan analyse + + - name: ๐Ÿš€ Run PHPLint (Syntax Check) + run: vendor/bin/phplint + + prime-test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - { php: 8.4, phpunit: 10.5.* } + - { php: 8.3, phpunit: 10.5.* } + - { php: 8.2, phpunit: 10.5.* } + + name: ๐Ÿ˜ PHP ${{ matrix.php }} + + steps: + - name: ๐Ÿ“ฅ Checkout code + uses: actions/checkout@v4 + + - name: ๐Ÿ”ง Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: ๐Ÿšš Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('composer.json') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.php }}- + + - name: ๐Ÿ“ฆ Install dependencies + run: | + sed -i '/"require": {/,/},/d; /"require-dev": {/,/},/d' composer.json + composer config --global allow-plugins true + composer require "phpunit/phpunit:${{ matrix.phpunit }}" "mockery/mockery" "psr/container" --no-interaction --no-update + composer update --prefer-lowest -W + + - name: โœ… Execute tests + run: vendor/bin/phpunit --testsuite prime + + symfony-test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - { symfony: 7.1.*, php: 8.4, phpunit: 10.5.* } + - { symfony: 7.1.*, php: 8.3, phpunit: 10.5.* } + - { symfony: 7.0.*, php: 8.2, phpunit: 10.5.* } + + name: ๐ŸŒ‰ Symfony ${{ matrix.symfony }} PHP ${{ matrix.php }} + + steps: + - name: ๐Ÿ“ฅ Checkout code + uses: actions/checkout@v4 + + - name: ๐Ÿ”ง Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: ๐Ÿšš Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('composer.json') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.php }}- + + - name: ๐Ÿ“ฆ Install dependencies + run: | + sed -i '/"require": {/,/},/d; /"require-dev": {/,/},/d' composer.json + composer config --global allow-plugins true + composer config extra.symfony.require "${{ matrix.symfony }}" + composer require "symfony/config:${{ matrix.symfony }}" "symfony/console:${{ matrix.symfony }}" "symfony/dependency-injection:${{ matrix.symfony }}" "symfony/framework-bundle:${{ matrix.symfony }}" "symfony/http-kernel:${{ matrix.symfony }}" "symfony/translation:${{ matrix.symfony }}" "symfony/twig-bundle:${{ matrix.symfony }}" "phpunit/phpunit:${{ matrix.phpunit }}" "mockery/mockery" "psr/container" "monolog/monolog" --no-interaction --no-update + composer update --prefer-lowest -W + + - name: โœ… Execute tests + run: vendor/bin/phpunit --testsuite symfony + + laravel-test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - { laravel: 11.*, testbench: 9.*, php: 8.3, phpunit: 10.5.* } + - { laravel: 11.*, testbench: 9.*, php: 8.2, phpunit: 10.5.* } + + name: ๐Ÿ— Laravel ${{ matrix.laravel }} PHP ${{ matrix.php }} + + steps: + - name: ๐Ÿ“ฅ Checkout code + uses: actions/checkout@v4 + + - name: ๐Ÿ”ง Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: fileinfo + coverage: none + + - name: ๐Ÿšš Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: ${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + restore-keys: ${{ matrix.php }}-composer + + - name: ๐Ÿ“ฆ Install dependencies + run: | + sed -i '/\"require\": {/,/},/d; /\"require-dev\": {/,/},/d' composer.json + composer config --global allow-plugins true + composer require "laravel/framework:${{ matrix.laravel }}" "phpunit/phpunit:${{ matrix.phpunit }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --prefer-lowest -W + + - name: โœ… Execute tests + run: vendor/bin/phpunit --testsuite laravel