Skip to content

Commit

Permalink
Try make phpstan work
Browse files Browse the repository at this point in the history
  • Loading branch information
AydinHassan committed Jan 17, 2024
1 parent b69b32e commit 654f7bc
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 20 deletions.
63 changes: 56 additions & 7 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,77 @@ on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *'

env:
SHOPWARE_TOOL_CACHE_PHPSTAN: ${{ github.workspace }}/var/phpstan
jobs:
cs:
if: github.event_name != 'schedule'
uses: shopware/github-actions/.github/workflows/cs-fixer.yml@main
# phpstan:
# uses: shopware/github-actions/.github/workflows/phpstan.yml@main
# with:
# extensionName: SwagPayPal
# shopwareVersion: trunk

phpstan:
uses: shopware/github-actions/.github/workflows/phpstan.yml@main
with:
extensionName: SwagPayPal
shopwareVersion: trunk
phpunit:
runs-on: ubuntu-latest
steps:
- name: Setup Shopware
uses: FriendsOfShopware/setup-shopware@main
with:
shopware-version: trunk
shopware-version: ${{ inputs.shopwareVersion }}
php-version: 8.2
php-extensions: pcov
env: prod
install: 'true'
- name: Clone Extension
uses: actions/checkout@v4
with:
path: custom/plugins/SwagPayPal
- name: Clone SwagCmsExtensions
run: git clone "https://shopware:$GITLAB_TOKEN@gitlab.shopware.com/shopware/6/services/cms-extensions.git" custom/plugins/SwagCmsExtensions
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
- name: Install SwagCmsExtensions with Composer
run: composer require $(composer -d custom/plugins/SwagCmsExtensions config name)
- name: Install SwagPayPal with Composer
run: composer require $(composer -d custom/plugins/SwagPayPal config name)
- name: Create phpstan.neon
working-directory: custom/plugins/SwagPayPal
run: |
printf "parameters:\n tmpDir: ${{ env.SHOPWARE_TOOL_CACHE_PHPSTAN }}\nincludes:\n - phpstan.neon.dist" > phpstan.neon
- name: PHPStan cache
uses: actions/cache@v3
with:
path: ${{ env.SHOPWARE_TOOL_CACHE_PHPSTAN }}
key: ${{ runner.OS }}-${{ github.repository }}-phpstan-${{ github.sha }}
restore-keys: |
${{ runner.OS }}-${{ github.repository }}-phpstan-
- name: Refresh
run: bin/console plugin:refresh
- name: Install Extension
run: bin/console plugin:install --activate SwagCmsExtensions
- name: Install Extension
run: bin/console plugin:install --activate SwagPayPal
- name: Build PHPStan Bootstrap
run: php ${{ github.workspace }}/src/Core/DevOps/StaticAnalyze/phpstan-bootstrap.php
- name: Run PHPStan
working-directory: custom/plugins/SwagPayPal
run: ${{ github.workspace }}/vendor/bin/phpstan analyze --error-format=github --no-progress
phpunit:
runs-on: ubuntu-latest
steps:
- name: Setup Shopware
uses: FriendsOfShopware/setup-shopware@main
with:
shopware-version: trunk
php-version: 8.2
php-extensions: pcov
- name: Clone SwagCmsExtensions
run: git clone "https://shopware:$GITLAB_TOKEN@gitlab.shopware.com/shopware/6/services/cms-extensions.git" custom/plugins/SwagCmsExtensions
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}

- name: Run PHPUnit
working-directory: custom/plugins/SwagPayPal
run: ${{ github.workspace }}/vendor/bin/phpunit --coverage-clover clover.xml
Expand Down
17 changes: 5 additions & 12 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
includes:
- %ShopwareRoot%/vendor/phpstan/phpstan/conf/bleedingEdge.neon
- ../../../vendor/phpstan/phpstan/conf/bleedingEdge.neon
- ../../../src/Core/DevOps/StaticAnalyze/PHPStan/extension.neon
- ../../../src/Core/DevOps/StaticAnalyze/PHPStan/rules.neon

parameters:
phpVersion: 80100
Expand All @@ -15,11 +17,10 @@ parameters:
excludePaths:
- src/Resources
- src/DevOps/Rector

symfony:
constant_hassers: false
# the placeholder "%ShopwareHashedCacheDir%" will be replaced on execution by bin/phpstan-config-generator.php script
container_xml_path: '../../..%ShopwareHashedCacheDir%/%ShopwareKernelClass%DevDebugContainer.xml'
containerXmlPath: '../../../var/cache/phpstan_dev/Shopware_Core_DevOps_StaticAnalyze_StaticAnalyzeKernelPhpstan_devDebugContainer.xml'
consoleApplicationLoader: ../../../src/Core/DevOps/StaticAnalyze/console-application.php

ignoreErrors:
# We won't type all arrays/iterables for now
Expand All @@ -45,11 +46,3 @@ parameters:
path: tests/Webhook/Registration/WebhookSystemConfigControllerTest.php
count: 11

bootstrapFiles:
- bin/static-analyze-autoloader.php

rules:
- Shopware\Core\DevOps\StaticAnalyze\PHPStan\Rules\Internal\InternalClassRule
- Shopware\Core\DevOps\StaticAnalyze\PHPStan\Rules\Internal\InternalClassRule
- Shopware\Core\DevOps\StaticAnalyze\PHPStan\Rules\Internal\InternalMethodRule
- Shopware\Core\DevOps\StaticAnalyze\PHPStan\Rules\PackageAnnotationRule
2 changes: 1 addition & 1 deletion tests/TestBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
->setProjectDir($_SERVER['PROJECT_ROOT'] ?? dirname(__DIR__, 4))
->setLoadEnvFile(true)
->setForceInstallPlugins(true)
//->addActivePlugins('SwagCmsExtensions')
->addActivePlugins('SwagCmsExtensions')
->addCallingPlugin()
->bootstrap()
->getClassLoader();

0 comments on commit 654f7bc

Please sign in to comment.