Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update php and pimcore, fix deprecations #82

Merged
merged 7 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 76 additions & 67 deletions .github/workflows/codeception.yaml
Original file line number Diff line number Diff line change
@@ -1,85 +1,94 @@
name: "Codeception Tests"
name: "Codeception Tests centralised"

on:
schedule:
- cron: '0 3 * * 1,3,5'
pull_request:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
paths-ignore:
- 'doc/**'
- 'src/Resources/public/**'
workflow_dispatch:
push:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
paths-ignore:
- 'doc/**'
- 'src/Resources/public/**'
- "feature-*"
pull_request:
types: [opened, synchronize, reopened]

env:
PIMCORE_PROJECT_ROOT: ${{ github.workspace }}
APP_ENV: test
PIMCORE_TEST: 1
PIMCORE_TEST_DB_DSN: "mysql://root@127.0.0.1:33006/pimcore_test"
PRIVATE_REPO: ${{ github.event.repository.private }}

jobs:
codeception-tests:
name: "Codeception tests"
runs-on: "ubuntu-20.04"
continue-on-error: ${{ matrix.experimental }}
env:
PIMCORE_TEST_DB_DSN: "mysql://root@127.0.0.1:33006/pimcore_test"
strategy:
matrix:
include:
- { php-version: 8.1, database: "mariadb:10.3", dependencies: lowest, experimental: false }
- { php-version: 8.2, database: "mariadb:10.11", dependencies: highest, experimental: false }
- { php-version: 8.3, database: "mariadb:10.11", pimcore_version: "11.x-dev", dependencies: highest, experimental: true }
services:
mariadb:
image: "${{ matrix.database }}"
ports:
- 33006:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes

setup-matrix:
runs-on: ubuntu-latest
outputs:
php_versions: ${{ steps.parse-php-versions.outputs.php_versions }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
private_repo: ${{ env.PRIVATE_REPO }}
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
- name: Checkout code
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: imagick
ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767
php-version: "${{ matrix.php-version }}"
- name: Checkout reusable workflow repo
uses: actions/checkout@v4
with:
repository: pimcore/workflows-collection-public
ref: main
path: reusable-workflows

- name: Verify MariaDB connection
run: |
cp .github/ci/files/.my.cnf ~/.my.cnf
while ! mysqladmin ping --silent; do
sleep 1
done
- name: "Setup Pimcore environment"
run: |
mysql -e "CREATE DATABASE pimcore_test CHARSET=utf8mb4;"
chmod 755 .github/ci/scripts/setup-pimcore-environment.sh
.github/ci/scripts/setup-pimcore-environment.sh
- name: "Update Pimcore version"
env:
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
run: |
if [ ! -z "$PIMCORE_VERSION" ]; then
composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
composer require --no-update pimcore/admin-ui-classic-bundle:1.x-dev
- name: Parse PHP versions from composer.json
id: parse-php-versions
run: |
if [ -f composer.json ]; then
php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//')
if [ -z "$php_versions" ]; then
echo "No PHP versions found in composer.json"
echo "Setting default PHP value"
echo "php_versions=default" >> $GITHUB_OUTPUT
else
echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
echo "#### php versions #### : $php_versions"
fi
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"
else
echo "composer.json not found"
exit 1
fi

- name: Set up matrix
id: set-matrix
run: |
php_versions="${{ steps.parse-php-versions.outputs.php_versions }}"

MATRIX_JSON=$(cat reusable-workflows/codeception-tests-configuration/matrix-config.json)

IFS=',' read -ra VERSIONS_ARRAY <<< "$php_versions"

FILTERED_MATRIX_JSON=$(echo $MATRIX_JSON | jq --arg php_versions "$php_versions" '
{
matrix: [
.configs[] |
select(.php_version == $php_versions) |
.matrix[]
]
}')

ENCODED_MATRIX_JSON=$(echo $FILTERED_MATRIX_JSON | jq -c .)

echo "matrix=${ENCODED_MATRIX_JSON}" >> $GITHUB_OUTPUT

- name: "Run Codeception"
run: "vendor/bin/codecept run -c . -vvv --xml"
codeception-tests:
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
uses: pimcore/workflows-collection-public/.github/workflows/reusable-codeception-tests-centralized.yaml@main
with:
APP_ENV: test
PIMCORE_TEST: 1
PRIVATE_REPO: ${{ needs.setup-matrix.outputs.private_repo}}
PHP_VERSION: ${{ matrix.matrix.php-version }}
DATABASE: ${{ matrix.matrix.database }}
SERVER_VERSION: ${{ matrix.matrix.server_version }}
DEPENDENCIES: ${{ matrix.matrix.dependencies }}
EXPERIMENTAL: ${{ matrix.matrix.experimental }}
PIMCORE_VERSION: ${{ matrix.matrix.pimcore_version }}
secrets:
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
1 change: 0 additions & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ jobs:
run: |
npm install
npm run build

136 changes: 85 additions & 51 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,95 @@
name: "Static Analysis"
name: "Static analysis centralised"

on:
schedule:
- cron: '0 3 * * 1,3,5'
pull_request:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
paths-ignore:
- 'doc/**'
- 'src/Resources/public/**'
- cron: '0 3 * * 1,3,5'
workflow_dispatch:
push:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
paths-ignore:
- 'doc/**'
- 'src/Resources/public/**'
- "feature-*"
pull_request:
types: [ opened, synchronize, reopened ]


env:
PIMCORE_PROJECT_ROOT: ${{ github.workspace }}
PRIVATE_REPO: ${{ github.event.repository.private }}

jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
include:
- { php-version: "8.1", dependencies: "lowest", pimcore_version: "", phpstan_args: "", experimental: false }
- { php-version: "8.2", dependencies: "highest", phpstan_args: "", experimental: false }
- { php-version: "8.3", dependencies: "highest", pimcore_version: "11.x-dev", phpstan_args: "", experimental: true }
setup-matrix:
runs-on: ubuntu-latest
outputs:
php_versions: ${{ steps.parse-php-versions.outputs.php_versions }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
private_repo: ${{ env.PRIVATE_REPO }}
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Setup Pimcore environment"
run: |
.github/ci/scripts/setup-pimcore-environment.sh

- name: "Update Pimcore version"
env:
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
run: |
if [ ! -z "$PIMCORE_VERSION" ]; then
composer require --no-update pimcore/pimcore:${PIMCORE_VERSION}
composer require --no-update pimcore/admin-ui-classic-bundle:1.x-dev
fi

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse ${{ matrix.phpstan_args }} -c phpstan.neon --memory-limit=-1"
- name: Checkout code
uses: actions/checkout@v4

- name: Checkout reusable workflow repo
uses: actions/checkout@v4
with:
repository: pimcore/workflows-collection-public
ref: main
path: reusable-workflows

- name: Parse PHP versions from composer.json
id: parse-php-versions
run: |
if [ -f composer.json ]; then
php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//')
if [ -z "$php_versions" ]; then
echo "No PHP versions found in composer.json"
echo "Setting default PHP value"
echo "php_versions=default" >> $GITHUB_OUTPUT
else
echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
echo "#### php versions #### : $php_versions"
fi
else
echo "composer.json not found"
exit 1
fi

- name: Set up matrix
id: set-matrix
run: |
php_versions="${{ steps.parse-php-versions.outputs.php_versions }}"

MATRIX_JSON=$(cat reusable-workflows/phpstan-configuration/matrix-config.json)

IFS=',' read -ra VERSIONS_ARRAY <<< "$php_versions"

FILTERED_MATRIX_JSON=$(echo $MATRIX_JSON | jq --arg php_versions "$php_versions" '
{
matrix: [
.configs[] |
select(.php_version == $php_versions) |
.matrix[]
]
}')

ENCODED_MATRIX_JSON=$(echo $FILTERED_MATRIX_JSON | jq -c .)

echo "matrix=${ENCODED_MATRIX_JSON}" >> $GITHUB_OUTPUT

static-analysis:
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
uses: pimcore/workflows-collection-public/.github/workflows/reusable-static-analysis-centralized.yaml@main
with:
APP_ENV: test
PIMCORE_TEST: 1
PRIVATE_REPO: ${{ needs.setup-matrix.outputs.private_repo}}
PHP_VERSION: ${{ matrix.matrix.php-version }}
SYMFONY: ${{ matrix.matrix.symfony }}
DEPENDENCIES: ${{ matrix.matrix.dependencies }}
EXPERIMENTAL: ${{ matrix.matrix.experimental }}
PIMCORE_VERSION: ${{ matrix.matrix.pimcore_version }}
COMPOSER_OPTIONS: ${{ matrix.matrix.composer_options }}
secrets:
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"pimcore/pimcore": "^11.0",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"pimcore/pimcore": "^11.0 || ^12.0",
"geoip2/geoip2": "^2.9",
"symfony/stopwatch": "^6.2",
"symfony/form": "^6.2",
Expand All @@ -23,11 +23,11 @@
"pimcore/newsletter-bundle": "^1.0",
"colinmollenhour/credis": "^1.10.0",
"mjaschen/phpgeo": "^4.0",
"pimcore/admin-ui-classic-bundle": "^1.0.6"
"pimcore/admin-ui-classic-bundle": "^1.0.6 || ^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.10.5",
"phpstan/phpstan": "^1.12.15",
"phpstan/phpstan-symfony": "^1.2.14",
"codeception/phpunit-wrapper": "^9",
"codeception/codeception": "^5.0.10",
Expand Down
15 changes: 7 additions & 8 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
parameters:
level: 6
reportUnmatchedIgnoredErrors: false
ignoreErrors:
-
identifier: missingType.iterableValue
-
identifier: missingType.generics
-
identifier: new.static
paths:
- src
bootstrapFiles:
- phpstan-bootstrap.php
excludePaths:
- src/Migrations/*
- src/Tests/*
ignoreErrors:
- '~^Unsafe usage of new static\(\)~'
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false

includes:
- vendor/phpstan/phpstan-symfony/extension.neon
- phpstan-baseline.neon
2 changes: 1 addition & 1 deletion src/Debug/Traits/StopwatchTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait StopwatchTrait
{
private ?Stopwatch $stopwatch = null;

public function setStopwatch(Stopwatch $stopwatch = null): void
public function setStopwatch(?Stopwatch $stopwatch = null): void
{
$this->stopwatch = $stopwatch;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Document/Targeting/TargetingDocumentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface TargetingDocumentInterface extends ElementInterface
*
*
*/
public function getTargetGroupEditablePrefix(int $targetGroupId = null): string;
public function getTargetGroupEditablePrefix(?int $targetGroupId = null): string;

/**
* Adds target group prefix to element name if it is not already prefixed and
Expand All @@ -46,7 +46,7 @@ public function getTargetGroupEditableName(string $name): string;
* Sets the target group to use
*
*/
public function setUseTargetGroup(int $useTargetGroup = null): void;
public function setUseTargetGroup(?int $useTargetGroup = null): void;

/**
* Returns the target group to use
Expand Down
Loading
Loading