|
| 1 | +name: PHPStan |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + phpstan: |
| 15 | + name: PHPStan Analysis |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + services: |
| 19 | + mariadb: |
| 20 | + image: mariadb:11.4 |
| 21 | + env: |
| 22 | + MYSQL_ROOT_PASSWORD: magento |
| 23 | + MYSQL_DATABASE: magento |
| 24 | + ports: |
| 25 | + - 3306:3306 |
| 26 | + options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 27 | + |
| 28 | + opensearch: |
| 29 | + image: opensearchproject/opensearch:3 |
| 30 | + ports: |
| 31 | + - 9200:9200 |
| 32 | + env: |
| 33 | + discovery.type: single-node |
| 34 | + DISABLE_SECURITY_PLUGIN: true |
| 35 | + OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m |
| 36 | + options: --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10 |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout code |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + path: mageforge |
| 43 | + |
| 44 | + - name: Setup PHP |
| 45 | + uses: shivammathur/setup-php@v2 |
| 46 | + with: |
| 47 | + php-version: "8.4" |
| 48 | + extensions: mbstring, intl, gd, xml, soap, zip, bcmath, pdo_mysql, curl, sockets |
| 49 | + tools: composer:v2 |
| 50 | + |
| 51 | + - name: Cache Composer packages |
| 52 | + id: composer-cache |
| 53 | + uses: actions/cache@v4 |
| 54 | + with: |
| 55 | + path: ~/.composer/cache/files |
| 56 | + key: ${{ runner.os }}-composer-2.4.8-${{ hashFiles('**/composer.json') }} |
| 57 | + restore-keys: ${{ runner.os }}-composer-2.4.8 |
| 58 | + |
| 59 | + - name: Clone Magento |
| 60 | + run: | |
| 61 | + git clone --depth=1 --branch=2.4.8 https://github.com/magento/magento2.git magento2 |
| 62 | +
|
| 63 | + - name: Install Magento |
| 64 | + working-directory: magento2 |
| 65 | + env: |
| 66 | + COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} |
| 67 | + run: | |
| 68 | + composer config minimum-stability stable |
| 69 | + composer config prefer-stable true |
| 70 | + composer install --no-interaction --no-progress |
| 71 | + bin/magento setup:install \ |
| 72 | + --base-url=http://localhost \ |
| 73 | + --db-host=127.0.0.1 \ |
| 74 | + --db-name=magento \ |
| 75 | + --db-user=root \ |
| 76 | + --db-password=magento \ |
| 77 | + --admin-firstname=Admin \ |
| 78 | + --admin-lastname=User \ |
| 79 | + --admin-email=admin@example.com \ |
| 80 | + --admin-user=admin \ |
| 81 | + --admin-password=admin12345 \ |
| 82 | + --language=en_US \ |
| 83 | + --currency=USD \ |
| 84 | + --timezone=Europe/Berlin \ |
| 85 | + --use-rewrites=1 \ |
| 86 | + --backend-frontname=admin \ |
| 87 | + --search-engine=opensearch \ |
| 88 | + --opensearch-host=localhost \ |
| 89 | + --opensearch-port=9200 \ |
| 90 | + --opensearch-index-prefix=magento \ |
| 91 | + --cleanup-database |
| 92 | +
|
| 93 | + - name: Install MageForge Module and PHPStan |
| 94 | + working-directory: magento2 |
| 95 | + run: | |
| 96 | + # Add local repository |
| 97 | + composer config repositories.mageforge-local path ../mageforge |
| 98 | +
|
| 99 | + # Install module |
| 100 | + composer require --no-update openforgeproject/mageforge:@dev |
| 101 | +
|
| 102 | + # Allow PHPStan extension installer |
| 103 | + composer config --no-plugins allow-plugins.phpstan/extension-installer true |
| 104 | +
|
| 105 | + # Install PHPStan and Magento extension |
| 106 | + composer require --dev --no-update bitexpert/phpstan-magento "phpstan/phpstan:^2.0" phpstan/extension-installer |
| 107 | +
|
| 108 | + # Update |
| 109 | + composer update --with-dependencies |
| 110 | +
|
| 111 | + # Enable module |
| 112 | + bin/magento module:enable OpenForgeProject_MageForge |
| 113 | + bin/magento setup:upgrade |
| 114 | +
|
| 115 | + - name: Run PHPStan |
| 116 | + working-directory: magento2 |
| 117 | + continue-on-error: true |
| 118 | + run: | |
| 119 | + vendor/bin/phpstan analyse -c vendor/openforgeproject/mageforge/phpstan.neon vendor/openforgeproject/mageforge/src |
0 commit comments