@@ -2,9 +2,25 @@ name: Magento 2 Static Tests
22on : ['push', 'pull_request']
33
44jobs :
5- static-tests :
6- name : Magento 2 Static Tests
7- # runs-on: self-hosted
5+ phpcs :
6+ name : Magento PHPCS
7+ runs-on : ubuntu-latest
8+ container :
9+ image : yireo/magento2installed:2.4.8-p3
10+ steps :
11+ - name : Checkout sources
12+ uses : actions/checkout@v4
13+
14+ - name : Run Magento 2 PHPCS Tests
15+ run : |
16+ export PHPCS_LEVEL=$(jq -r '.phpcs_severity // 10' MODULE.json)
17+ test -z "$PHPCS_LEVEL" && PHPCS_LEVEL=10
18+ echo "Testing for PHPCS severity $PHPCS_LEVEL"
19+ cd /tmp/magento
20+ php vendor/bin/phpcs --standard=Magento2 --ignore=Test/,node_modules/ --colors --extensions=php,phtml --severity=$PHPCS_LEVEL ${GITHUB_WORKSPACE}
21+
22+ phpstan :
23+ name : Magento PHPStan
824 runs-on : ubuntu-latest
925 container :
1026 image : yireo/magento2installed:2.4.8-p3
@@ -16,23 +32,30 @@ jobs:
1632 run : |
1733 test -n "${{ secrets.GITLAB_TOKEN }}" || exit 0
1834 cd /tmp/magento
35+ composer config gitlab-domains gitlab.yireo.com
1936 composer config --auth gitlab-token.gitlab.yireo.com ${{ secrets.GITLAB_TOKEN }}
2037 composer config repositories.loki-checkout composer https://gitlab.yireo.com/api/v4/group/loki-checkout/-/packages/composer/packages.json
2138
2239 - name : Add module source
2340 run : |
2441 export COMPOSER_NAME=`cat .module.ini | grep COMPOSER_NAME | cut -f2 -d= | tr -d '"'`
42+ export COMPOSER_DEV_REQUIREMENTS=`jq -r '.["require-dev"] // {} | to_entries | map("\(.key):\(.value)") | join(" ")' composer.json`
2543 cp -R ${GITHUB_WORKSPACE} /tmp/magento/package-source
2644 cd /tmp/magento
2745 composer config repositories.local-source path package-source/
2846 composer config --no-plugins allow-plugins true
47+ composer remove --dev magento/magento-coding-standard
48+ test -z "$COMPOSER_DEV_REQUIREMENTS" || composer require --dev $COMPOSER_DEV_REQUIREMENTS
49+ composer require --dev --prefer-source -- phpstan/phpstan:^2.0 bitexpert/phpstan-magento:^0.42 phpstan/extension-installer
2950 composer require --prefer-source -- ${COMPOSER_NAME}:@dev yireo/magento2-integration-test-helper
30- composer require --dev --prefer-source -- phpstan/phpstan bitexpert/phpstan-magento phpstan/extension-installer
3151
3252 - name : Run Magento 2 PHPStan Tests
3353 run : |
3454 export COMPOSER_NAME=`cat .module.ini | grep COMPOSER_NAME | cut -f2 -d= | tr -d '"'`
35- export LEVEL=$(jq -r '.phpstan_level // 1' MODULE.json)
55+ export PHPSTAN_LEVEL=$(jq -r '.phpstan_level // 1' MODULE.json)
56+ test -z "$PHPSTAN_LEVEL" && PHPSTAN_LEVEL=1
3657 test -f /tmp/magento/phpstan.neon || echo 'parameters:' > /tmp/magento/phpstan.neon
37- php -d memory_limit=4G /tmp/magento/vendor/bin/phpstan analyse --level $LEVEL ${GITHUB_WORKSPACE}
58+ echo "Testing for PHPStan level $PHPSTAN_LEVEL"
59+ cd /tmp/magento
60+ php -d memory_limit=4G vendor/bin/phpstan analyse --level $PHPSTAN_LEVEL ${GITHUB_WORKSPACE}
3861
0 commit comments