Skip to content
Merged
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
55 changes: 20 additions & 35 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ env:
PIMCORE_PROJECT_ROOT: ${{ github.workspace }}
PRIVATE_REPO: ${{ github.event.repository.private }}

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
php_versions: ${{ steps.parse-php-versions.outputs.php_versions }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
phpstan_matrix: ${{ steps.set-matrix.outputs.phpstan_matrix }}
private_repo: ${{ env.PRIVATE_REPO }}
steps:
- name: Checkout code
Expand All @@ -41,55 +45,36 @@ jobs:
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
echo "php_versions=default" >> "$GITHUB_OUTPUT"
else
echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
echo "#### php versions #### : $php_versions"
echo "php_versions=$php_versions" >> "$GITHUB_OUTPUT"
Comment on lines 45 to +50
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PHP version parsing regex (grep -oP '\d+\.\d+') will incorrectly extract patch parts as separate versions for constraints like this repo’s "php": "~8.3.0 || ~8.4.0" (it yields 8.3,3.0,8.4,4.0). This will likely produce an invalid/empty matrix selection downstream. Consider extracting full major.minor.patch tokens first (e.g., \d+\.\d+\.\d+) and then normalizing to major.minor, or otherwise parsing Composer constraints more robustly.

Copilot uses AI. Check for mistakes.
fi
else
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When composer.json is missing, the step exits with status 1 but prints no error message. Adding a short message to stderr before exiting would make failures easier to diagnose in CI logs.

Suggested change
else
else
echo "Error: composer.json not found; cannot parse PHP versions." >&2

Copilot uses AI. Check for mistakes.
echo "composer.json not found"
exit 1
fi

- name: Set up matrix
- name: Set up matrix JSON
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
FILTERED_MATRIX_JSON=$(echo "$MATRIX_JSON" | jq --arg php_versions "$php_versions" '{ include: [ .configs[] | select(.php_version == $php_versions) | .matrix[] ] }')
ENCODED_MATRIX_JSON=$(echo "$FILTERED_MATRIX_JSON" | jq -c .)
echo "phpstan_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
uses: pimcore/workflows-collection-public/.github/workflows/reusable-static-analysis-unified.yaml@main
with:
phpstan_matrix: ${{ needs.setup-matrix.outputs.phpstan_matrix }}
private_repo: ${{ needs.setup-matrix.outputs.private_repo }}
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 }}
REQUIRE_ADMIN_BUNDLE: "true"
COVERAGE: "none"
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 }}
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
PIMCORE_CI_INSTANCE_IDENTIFIER: ${{ secrets.PIMCORE_CI_INSTANCE_IDENTIFIER }}
PIMCORE_CI_ENCRYPTION_SECRET: ${{ secrets.PIMCORE_CI_ENCRYPTION_SECRET }}
PIMCORE_CI_PRODUCT_KEY: ${{ secrets.PIMCORE_CI_PRODUCT_KEY }}
Loading