1
- name : " Static Analysis "
1
+ name : " Static analysis centralised "
2
2
3
3
on :
4
- pull_request :
5
- branches :
6
- - " [0-9]+.[0-9]+"
7
- - " [0-9]+.x"
4
+ schedule :
5
+ - cron : ' 0 3 * * 1,3,5'
6
+ workflow_dispatch :
8
7
push :
9
8
branches :
10
9
- " [0-9]+.[0-9]+"
11
10
- " [0-9]+.x"
11
+ - " feature-*"
12
+ pull_request :
13
+ types : [ opened, synchronize, reopened ]
14
+
15
+
16
+ env :
17
+ PIMCORE_PROJECT_ROOT : ${{ github.workspace }}
18
+ PRIVATE_REPO : ${{ github.event.repository.private }}
12
19
13
20
jobs :
14
- static-analysis-phpstan :
15
- name : " Static Analysis with PHPStan"
16
- runs-on : " ubuntu-20.04"
17
- strategy :
18
- matrix :
19
- include :
20
- - { php-version: "8.1", dependencies: "lowest", require_admin_bundle: false }
21
- - { php-version: "8.2", dependencies: "highest", require_admin_bundle: true }
22
- - { php-version: "8.3", dependencies: "highest", pimcore_version: "11.x-dev", require_admin_bundle: true }
21
+ setup-matrix :
22
+ runs-on : ubuntu-latest
23
+ outputs :
24
+ php_versions : ${{ steps.parse-php-versions.outputs.php_versions }}
25
+ matrix : ${{ steps.set-matrix.outputs.matrix }}
26
+ private_repo : ${{ env.PRIVATE_REPO }}
23
27
steps :
24
- - name : " Checkout code"
25
- uses : " actions/checkout@v2 "
28
+ - name : Checkout code
29
+ uses : actions/checkout@v4
26
30
27
- - name : " Install PHP "
28
- uses : " shivammathur/setup-php@v2 "
31
+ - name : Checkout reusable workflow repo
32
+ uses : actions/checkout@v4
29
33
with :
30
- coverage : " none"
31
- php-version : " ${{ matrix.php-version }}"
32
-
33
- - name : " Setup Pimcore environment"
34
- env :
35
- REQUIRE_ADMIN_BUNDLE : " ${{ matrix.require_admin_bundle }}"
36
- run : |
37
- .github/ci/scripts/setup-pimcore-environment.sh
34
+ repository : pimcore/workflows-collection-public
35
+ ref : main
36
+ path : reusable-workflows
38
37
39
- - name : " Update Pimcore version"
40
- env :
41
- PIMCORE_VERSION : " ${{ matrix.pimcore_version }}"
38
+ - name : Parse PHP versions from composer.json
39
+ id : parse-php-versions
42
40
run : |
43
- if [ ! -z "$PIMCORE_VERSION" ]; then
44
- composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
41
+ if [ -f composer.json ]; then
42
+ php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//')
43
+ if [ -z "$php_versions" ]; then
44
+ echo "No PHP versions found in composer.json"
45
+ echo "Setting default PHP value"
46
+ echo "php_versions=default" >> $GITHUB_OUTPUT
47
+ else
48
+ echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
49
+ echo "#### php versions #### : $php_versions"
50
+ fi
51
+ else
52
+ echo "composer.json not found"
53
+ exit 1
45
54
fi
46
55
47
- - name : " Install dependencies with Composer"
48
- uses : " ramsey/composer-install@v2"
49
- with :
50
- dependency-versions : " ${{ matrix.dependencies }}"
56
+ - name : Set up matrix
57
+ id : set-matrix
58
+ run : |
59
+ php_versions="${{ steps.parse-php-versions.outputs.php_versions }}"
60
+
61
+ MATRIX_JSON=$(cat reusable-workflows/phpstan-configuration/matrix-config.json)
62
+
63
+ IFS=',' read -ra VERSIONS_ARRAY <<< "$php_versions"
64
+
65
+ FILTERED_MATRIX_JSON=$(echo $MATRIX_JSON | jq --arg php_versions "$php_versions" '
66
+ {
67
+ matrix: [
68
+ .configs[] |
69
+ select(.php_version == $php_versions) |
70
+ .matrix[]
71
+ ]
72
+ }')
73
+
74
+ ENCODED_MATRIX_JSON=$(echo $FILTERED_MATRIX_JSON | jq -c .)
75
+
76
+ echo "matrix=${ENCODED_MATRIX_JSON}" >> $GITHUB_OUTPUT
51
77
52
- - name : " Run a static analysis with phpstan/phpstan"
53
- run : " vendor/bin/phpstan analyse --memory-limit=-1"
78
+ static-analysis :
79
+ needs : setup-matrix
80
+ strategy :
81
+ matrix : ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
82
+ uses : pimcore/workflows-collection-public/.github/workflows/reusable-static-analysis-centralized.yaml@main
83
+ with :
84
+ APP_ENV : test
85
+ PIMCORE_TEST : 1
86
+ PRIVATE_REPO : ${{ needs.setup-matrix.outputs.private_repo}}
87
+ PHP_VERSION : ${{ matrix.matrix.php-version }}
88
+ SYMFONY : ${{ matrix.matrix.symfony }}
89
+ DEPENDENCIES : ${{ matrix.matrix.dependencies }}
90
+ EXPERIMENTAL : ${{ matrix.matrix.experimental }}
91
+ PIMCORE_VERSION : ${{ matrix.matrix.pimcore_version }}
92
+ COMPOSER_OPTIONS : ${{ matrix.matrix.composer_options }}
93
+ secrets :
94
+ SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER : ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
95
+ COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN : ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
0 commit comments