Skip to content

Commit ef13875

Browse files
authored
[Task] Update workflows (#564)
* Update workflows * Rename bash script
1 parent 74fafa1 commit ef13875

File tree

3 files changed

+154
-132
lines changed

3 files changed

+154
-132
lines changed

.github/workflows/codeception.yml

Lines changed: 75 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,92 @@
1-
2-
name: "Codeception Tests"
1+
name: "Codeception Tests centralised"
32

43
on:
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

1513
env:
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

2217
jobs:
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 }}
Lines changed: 79 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,95 @@
1-
name: "Static Analysis"
1+
name: "Static analysis centralised"
22

33
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:
87
push:
98
branches:
109
- "[0-9]+.[0-9]+"
1110
- "[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 }}
1219

1320
jobs:
14-
static-analysis-phpstan:
15-
name: "Static Analysis with PHPStan"
16-
runs-on: "ubuntu-20.04"
17-
continue-on-error: ${{ matrix.experimental }}
18-
strategy:
19-
matrix:
20-
include:
21-
- { php-version: "8.1", dependencies: "lowest", experimental: false }
22-
- { php-version: "8.2", dependencies: "highest", experimental: false }
23-
- { php-version: "8.3", dependencies: "highest", pimcore_version: "11.x-dev as 11.3.9", experimental: 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 }}
2427
steps:
25-
- name: "Checkout code"
26-
uses: "actions/checkout@v4"
28+
- name: Checkout code
29+
uses: actions/checkout@v4
2730

28-
- name: "Install PHP"
29-
uses: shivammathur/setup-php@v2
31+
- name: Checkout reusable workflow repo
32+
uses: actions/checkout@v4
3033
with:
31-
coverage: "none"
32-
php-version: "${{ matrix.php-version }}"
34+
repository: pimcore/workflows-collection-public
35+
ref: main
36+
path: reusable-workflows
3337

34-
- name: "Setup Pimcore environment"
35-
env:
36-
DEPENDENCIES: "${{ matrix.dependencies }}"
38+
- name: Parse PHP versions from composer.json
39+
id: parse-php-versions
3740
run: |
38-
.github/ci/scripts/setup-environment.sh
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
54+
fi
3955
40-
- name: "Update Pimcore version"
41-
env:
42-
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
56+
- name: Set up matrix
57+
id: set-matrix
4358
run: |
44-
if [ ! -z "$PIMCORE_VERSION" ]; then
45-
composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
46-
fi
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
4777
48-
- name: "Install dependencies with Composer"
49-
uses: ramsey/composer-install@v3
50-
with:
51-
dependency-versions: "${{ matrix.dependencies }}"
52-
53-
- name: "Run a static analysis with phpstan/phpstan (highest)"
54-
if: ${{ matrix.dependencies == 'highest' }}
55-
run: "vendor/bin/phpstan analyse --memory-limit=-1"
56-
57-
- name: "Run a static analysis with phpstan/phpstan (lowest)"
58-
if: ${{ matrix.dependencies == 'lowest' }}
59-
run: "vendor/bin/phpstan analyse --memory-limit=-1 -c phpstan-lowest.neon"
60-
61-
- name: "Generate baseline file"
62-
if: ${{ failure() }}
63-
run: "vendor/bin/phpstan analyse --memory-limit=-1 --generate-baseline"
64-
65-
- name: "Upload baseline file"
66-
if: ${{ failure() }}
67-
uses: actions/upload-artifact@v4
68-
with:
69-
name: phpstan-baseline.neon
70-
path: phpstan-baseline.neon
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

Comments
 (0)