1-
2- name : " Codeception Tests"
1+ name : " Codeception Tests centralised"
32
43on :
5- pull_request :
6- branches :
7- - " *.*"
8- - " master"
4+ workflow_dispatch :
95 push :
106 branches :
11- - " *.*"
12- - " master"
13- - " *_actions"
7+ - " [0-9]+.[0-9]+"
8+ - " [0-9]+.x"
9+ - " feature-*"
10+ pull_request :
11+ types : [opened, synchronize, reopened]
1412
1513env :
1614 PIMCORE_PROJECT_ROOT : ${{ github.workspace }}
17- APP_ENV : test
18- PIMCORE_TEST : 1
19- PIMCORE_TEST_DB_DSN :
" mysql://[email protected] :33006/pimcore_test" 20- PIMCORE_TEST_REDIS_DSN : " redis://127.0.0.1:63379"
15+ PRIVATE_REPO : ${{ github.event.repository.private }}
2116
2217jobs :
23- codeception-tests :
24- name : " Codeception tests"
25- runs-on : " ubuntu-20.04"
26- continue-on-error : ${{ matrix.experimental }}
27- strategy :
28- matrix :
29- include :
30- - { php-version: 8.1, database: "mariadb:10.3", dependencies: lowest, experimental: false }
31- - { php-version: 8.2, database: "mariadb:10.11", dependencies: highest, experimental: false }
32- - { php-version: 8.3, database: "mariadb:10.11", dependencies: highest, pimcore_version: "11.x-dev as 11.3.9", experimental: true }
33-
34- services :
35- redis :
36- image : redis
37- ports :
38- - 63379:6379
39- mariadb :
40- image : " ${{ matrix.database }}"
41- ports :
42- - 33006:3306
43- env :
44- MYSQL_ALLOW_EMPTY_PASSWORD : yes
45-
18+ setup-matrix :
19+ runs-on : ubuntu-latest
20+ outputs :
21+ php_versions : ${{ steps.parse-php-versions.outputs.php_versions }}
22+ matrix : ${{ steps.set-matrix.outputs.matrix }}
23+ private_repo : ${{ env.PRIVATE_REPO }}
4624 steps :
47- - name : " Checkout code"
48- uses : " actions/checkout@v2"
49-
50- - name : " Install PHP"
51- uses : " shivammathur/setup-php@v2"
52- with :
53- coverage : " none"
54- extensions : imagick
55- ini-values : display_errors=On, display_startup_errors=On, error_reporting=32767
56- php-version : " ${{ matrix.php-version }}"
57-
58- - name : Verify MariaDB connection
59- run : |
60- cp .github/ci/files/.my.cnf ~/.my.cnf
61- while ! mysqladmin ping --silent; do
62- sleep 1
63- done
64-
65- - name : " Setup Pimcore environment"
66- env :
67- DEPENDENCIES : " ${{ matrix.dependencies }}"
68- run : |
69- mysql -e "CREATE DATABASE pimcore_test CHARSET=utf8mb4;"
70- .github/ci/scripts/setup-environment.sh
25+ - name : Checkout code
26+ uses : actions/checkout@v4
7127
72- - name : " Update Pimcore version"
73- env :
74- PIMCORE_VERSION : " ${{ matrix.pimcore_version }}"
75- run : |
76- if [ ! -z "$PIMCORE_VERSION" ]; then
77- composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
78- fi
79-
80- - name : " Install dependencies with Composer"
81- uses : " ramsey/composer-install@v2"
28+ - name : Checkout reusable workflow repo
29+ uses : actions/checkout@v4
8230 with :
83- dependency-versions : " ${{ matrix.dependencies }}"
31+ repository : pimcore/workflows-collection-public
32+ ref : main
33+ path : reusable-workflows
8434
85- - name : " Test environment infos"
35+ - name : Parse PHP versions from composer.json
36+ id : parse-php-versions
8637 run : |
87- mysql -e "SELECT VERSION();"
88- php -i
38+ if [ -f composer.json ]; then
39+ php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//')
40+ if [ -z "$php_versions" ]; then
41+ echo "No PHP versions found in composer.json"
42+ echo "Setting default PHP value"
43+ echo "php_versions=default" >> $GITHUB_OUTPUT
44+ else
45+ echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
46+ echo "#### php versions #### : $php_versions"
47+ fi
48+ else
49+ echo "composer.json not found"
50+ exit 1
51+ fi
8952
90- - name : " Sync Metadata Storage"
53+ - name : Set up matrix
54+ id : set-matrix
9155 run : |
92- bin/console doctrine:migrations:sync-metadata-storage -vvv
56+ php_versions="${{ steps.parse-php-versions.outputs.php_versions }}"
57+
58+ MATRIX_JSON=$(cat reusable-workflows/codeception-tests-configuration/matrix-config.json)
59+
60+ IFS=',' read -ra VERSIONS_ARRAY <<< "$php_versions"
61+
62+ FILTERED_MATRIX_JSON=$(echo $MATRIX_JSON | jq --arg php_versions "$php_versions" '
63+ {
64+ matrix: [
65+ .configs[] |
66+ select(.php_version == $php_versions) |
67+ .matrix[]
68+ ]
69+ }')
70+
71+ ENCODED_MATRIX_JSON=$(echo $FILTERED_MATRIX_JSON | jq -c .)
72+
73+ echo "matrix=${ENCODED_MATRIX_JSON}" >> $GITHUB_OUTPUT
9374
94- - name : " Run Codeception"
95- run : " vendor/bin/codecept run -c . -vvv --xml"
75+ codeception-tests :
76+ needs : setup-matrix
77+ strategy :
78+ matrix : ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
79+ uses : pimcore/workflows-collection-public/.github/workflows/reusable-codeception-tests-centralized.yaml@main
80+ with :
81+ APP_ENV : test
82+ PIMCORE_TEST : 1
83+ PRIVATE_REPO : ${{ needs.setup-matrix.outputs.private_repo}}
84+ PHP_VERSION : ${{ matrix.matrix.php-version }}
85+ DATABASE : ${{ matrix.matrix.database }}
86+ SERVER_VERSION : ${{ matrix.matrix.server_version }}
87+ DEPENDENCIES : ${{ matrix.matrix.dependencies }}
88+ EXPERIMENTAL : ${{ matrix.matrix.experimental }}
89+ PIMCORE_VERSION : ${{ matrix.matrix.pimcore_version }}
90+ secrets :
91+ SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER : ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
92+ COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN : ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
0 commit comments