Skip to content

Commit 6e25ba3

Browse files
authored
Merge pull request #116 from perplorm/develop
Release 2.7.0
2 parents d5b3ee9 + df4e56c commit 6e25ba3

File tree

510 files changed

+8411
-5693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

510 files changed

+8411
-5693
lines changed

.github/actions/setup-php/action.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ runs:
3838
${{ runner.os }}-composer-php:${{ inputs.php-version }}-
3939
${{ runner.os }}-composer-
4040
41-
- name: Composer validate
42-
run: composer validate
43-
shell: bash
44-
45-
- name: Composer install
46-
run: composer install --prefer-dist --no-interaction
41+
- name: Composer update
42+
run: COMPOSER=tests/composer/composer-symfony${{ inputs.symfony-version }}.json composer update --prefer-dist --no-interaction
4743
shell: bash

.github/workflows/ci.yml

Lines changed: 76 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -8,94 +8,74 @@ on:
88
pull_request:
99
workflow_dispatch:
1010

11+
env:
12+
DB_NAME: 'perpl_tests'
13+
DB_USER: 'perpl'
14+
DB_PW: 'perpl'
15+
1116
jobs:
1217
testsuite:
1318
name: "Test Suite"
1419
runs-on: ubuntu-24.04
1520
strategy:
1621
fail-fast: false
1722
matrix:
18-
php-version: [ '8.1', '8.4' ]
23+
php-version: [ '8.1', '8.5' ]
1924
db-type: [ sqlite, mysql, pgsql, agnostic ]
20-
symfony-version: [ '5-min', '5-max', '6-min', '6-max', '7-min', '7-max']
25+
symfony-version: [ '6-min', '6-max', '7-min', '7-max', '8-min', '8-max']
2126
exclude:
22-
- symfony-version: '6-min'
23-
php-version: '8.1'
24-
- symfony-version: '6-max'
25-
php-version: '8.1'
2627
- symfony-version: '7-min'
2728
php-version: '8.1'
2829
- symfony-version: '7-max'
2930
php-version: '8.1'
30-
env:
31-
DB_NAME: 'propel_tests'
32-
DB_USER: 'propel'
33-
DB_PW: 'propel'
34-
steps:
35-
- name: Install PostgreSQL latest
36-
if: matrix.db-type == 'pgsql' && matrix.php-version != '8.1'
37-
uses: CasperWA/postgresql-action@v1.2
38-
with:
39-
postgresql db: $DB_NAME
40-
postgresql user: $DB_USER
41-
postgresql password: $DB_PW
42-
43-
- name: Install PostgreSQL min
44-
if: matrix.db-type == 'pgsql' && matrix.php-version == '8.1'
45-
uses: CasperWA/postgresql-action@v1.2
46-
with:
47-
postgresql version: 9
48-
postgresql db: $DB_NAME
49-
postgresql user: $DB_USER
50-
postgresql password: $DB_PW
51-
52-
- name: Install MySQL latest
53-
if: matrix.db-type == 'mysql' && matrix.php-version != '8.1'
54-
uses: mirromutth/mysql-action@v1.1
55-
with:
56-
mysql root password: $DB_PW
57-
58-
- name: Install MariaDb min
59-
if: matrix.db-type == 'mysql' && matrix.php-version == '8.1'
60-
uses: getong/mariadb-action@v1.1
61-
with:
62-
mariadb version: '10.2'
63-
mysql root password: $DB_PW
31+
- symfony-version: '8-min'
32+
php-version: '8.1'
33+
- symfony-version: '8-max'
34+
php-version: '8.1'
35+
services:
36+
postgres:
37+
image: ${{ matrix.db-type != 'pgsql' && '' || (matrix.php-version == '8.1' && 'postgres:9' || 'postgres:latest') }}
38+
env:
39+
POSTGRES_DB: ${{ env.DB_NAME }}
40+
POSTGRES_USER: ${{ env.DB_USER }}
41+
POSTGRES_PASSWORD: ${{ env.DB_PW }}
42+
ports:
43+
- 5432:5432
44+
options: >-
45+
--health-cmd pg_isready
46+
--health-interval 10s
47+
--health-timeout 5s
48+
--health-retries 5
49+
mysql:
50+
image: ${{ matrix.db-type != 'mysql' && '' || (matrix.php-version == '8.1' && 'mariadb:10.2' || 'mysql:latest') }}
51+
env:
52+
MYSQL_ROOT_PASSWORD: ${{ env.DB_PW }}
53+
MYSQL_DATABASE: ${{ env.DB_NAME }}
54+
MYSQL_USER: ${{ env.DB_USER }}
55+
MYSQL_PASSWORD: ${{ env.DB_PW }}
56+
ports:
57+
- 3306:3306
58+
options: >-
59+
--health-cmd="mysqladmin ping"
60+
--health-interval=10s
61+
--health-timeout=5s
62+
--health-retries=3
6463
64+
steps:
6565
- uses: actions/checkout@v3
6666

67-
- name: Move specific composer.json (Symfony version ${{ matrix.symfony-version }})
68-
run: mv tests/composer/composer-symfony${{ matrix.symfony-version }}.json composer.json
69-
7067
- id: build-container
7168
uses: ./.github/actions/setup-php
7269
with:
7370
php-version: ${{ matrix.php-version }}
7471
symfony-version: ${{ matrix.symfony-version }}
7572
cache-key-suffix: ${{ matrix.db-type}}
7673

77-
- name: Wait for MySQL server to load
78-
if: matrix.db-type == 'mysql'
79-
run: |
80-
bash -c "
81-
for i in {1..10}; do
82-
mysqladmin -h 127.0.0.1 -u root status >/dev/null 2>&1 && exit 0 || sleep 6
83-
echo 'trying again'
84-
done;
85-
echo 'could not establish connection after 10 tries'
86-
exit 1
87-
"
88-
env:
89-
MYSQL_PWD: ${{ env.DB_PW }}
90-
91-
- name: Create MySQL Propel user
74+
- name: Grant MySQL privileges to DB user
9275
if: matrix.db-type == 'mysql'
9376
run: |
9477
mysql -h 127.0.0.1 -u root -e "
95-
CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PW';
96-
CREATE USER '$DB_USER'@'%' IDENTIFIED BY '$DB_PW';
97-
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'localhost';
98-
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'%';
78+
GRANT ALL PRIVILEGES ON *.* TO '${{ env.DB_USER }}'@'%';
9979
FLUSH PRIVILEGES;
10080
"
10181
env:
@@ -106,9 +86,9 @@ jobs:
10686
run: tests/bin/setup.${{ matrix.db-type }}.sh
10787

10888
- name: Run tests
109-
shell: 'script -q -e -c "bash {0}"'
89+
shell: bash
11090
run: |
111-
if [[ ${{ matrix.php-version }} == '8.1' && ${{ matrix.symfony-version }} == '5-max' ]]; then
91+
if [[ ${{ matrix.php-version }} == '8.1' && ${{ matrix.symfony-version }} == '6-max' ]]; then
11292
export CODECOVERAGE=1 && vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml --verbose --coverage-clover=tests/coverage.xml
11393
else
11494
vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml
@@ -117,21 +97,30 @@ jobs:
11797
SYMFONY_VERSION: ${{ matrix.symfony-version }}
11898

11999
- name: Code Coverage Report
120-
if: success() && matrix.php-version == '8.1' && matrix.symfony-version == '5-max'
100+
if: success() && matrix.php-version == '8.1' && matrix.symfony-version == '6-max'
121101
uses: codecov/codecov-action@v1
122102
with:
123103
flags: ${{ matrix.php-version }}, ${{ matrix.db-type }}, ${{ matrix.symfony-version }}
124104
file: tests/coverage.xml
125105

126106
static-analysis:
107+
name: 'Stan & Psalm'
127108
runs-on: ubuntu-24.04
109+
strategy:
110+
fail-fast: false
111+
matrix:
112+
include:
113+
- php-version: '8.1'
114+
symfony-version: '6-max'
115+
- php-version: '8.5'
116+
symfony-version: '8-max'
128117
steps:
129118
- uses: actions/checkout@v3
130119
- id: build-container
131120
uses: ./.github/actions/setup-php
132121
with:
133-
php-version: 8.1
134-
symfony-version: 6-max
122+
php-version: ${{ matrix.php-version }}
123+
symfony-version: ${{ matrix.symfony-version }}
135124
cache-key-suffix: sa
136125
- name: PHPStan
137126
env:
@@ -141,6 +130,7 @@ jobs:
141130
run: composer psalm -- --php-version=${{ steps.build-container.outputs.php-version }}
142131

143132
code-style:
133+
name: 'Code Style (PHPCS)'
144134
runs-on: ubuntu-24.04
145135
steps:
146136
- uses: actions/checkout@v3
@@ -153,53 +143,23 @@ jobs:
153143
- name: Code Style
154144
run: composer cs-check
155145

156-
model-code-style:
157-
runs-on: ubuntu-24.04
158-
steps:
159-
- uses: actions/checkout@v3
160-
- id: build-container
161-
uses: ./.github/actions/setup-php
162-
with:
163-
php-version: 8.4
164-
symfony-version: 6-max
165-
cache-key-suffix: cs
166-
- name: Lint Model Code
167-
run: |
168-
bin/propel test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
169-
&& composer cs-check tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/*[^Query].php
170-
171-
model-static-analysis:
172-
runs-on: ubuntu-24.04
173-
steps:
174-
- uses: actions/checkout@v3
175-
- id: build-container
176-
uses: ./.github/actions/setup-php
177-
with:
178-
php-version: 8.4
179-
symfony-version: 6-max
180-
cache-key-suffix: cs
181-
- name: Analyze Model Code
182-
run: |
183-
bin/propel test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
184-
&& composer stan -- -a autoload.php.dist tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/*[^Query].php
185-
186-
query-code-style:
187-
runs-on: ubuntu-24.04
188-
steps:
189-
- uses: actions/checkout@v3
190-
- id: build-container
191-
uses: ./.github/actions/setup-php
192-
with:
193-
php-version: 8.4
194-
symfony-version: 6-max
195-
cache-key-suffix: cs
196-
- name: Lint Query Code
197-
run: |
198-
bin/propel test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
199-
&& composer cs-check tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/*Query.php
200-
201-
query-static-analysis:
146+
generated-code-style:
202147
runs-on: ubuntu-24.04
148+
strategy:
149+
fail-fast: false
150+
matrix:
151+
type: ['query', 'model']
152+
check: ['PHPCS', 'Stan']
153+
include:
154+
- check: PHPCS
155+
command: 'cs-check -- --exclude=SlevomatCodingStandard.TypeHints.DeclareStrictTypes'
156+
- check: Stan
157+
command: 'stan -- -a autoload.php.dist'
158+
- type: query
159+
file-pattern: '*Query.php'
160+
- type: model
161+
file-pattern: '*[^Query].php'
162+
name: '${{ matrix.check }} on ${{ matrix.type }} code'
203163
steps:
204164
- uses: actions/checkout@v3
205165
- id: build-container
@@ -208,7 +168,7 @@ jobs:
208168
php-version: 8.4
209169
symfony-version: 6-max
210170
cache-key-suffix: cs
211-
- name: Analyze Query Code
171+
- name: Run checks on generated code
212172
run: |
213-
bin/propel test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
214-
&& composer stan -- -a autoload.php.dist tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/*Query.php
173+
bin/perpl test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
174+
&& composer ${{ matrix.command }} tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/${{ matrix.file-pattern }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
vendor/
44
composer.phar
55
/composer.lock
6+
/tests/composer/*.lock
67
autoload.php
78
phpunit.xml
89
.phpunit.result.cache

.license

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
/**
2-
* MIT License. This file is part of the Propel package.
3-
* For the full copyright and license information, please view the LICENSE
4-
* file that was distributed with this source code.
5-
*/

bin/perpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require(__DIR__ . '/perpl.php');

bin/perpl.bat

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@echo off
2+
3+
if "%PHPBIN%" == "" set PHPBIN=php
4+
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
5+
GOTO RUN
6+
:USE_PEAR_PATH
7+
set PHPBIN=%PHP_PEAR_PHP_BIN%
8+
:RUN
9+
"%PHPBIN%" "bin\perpl" %*

bin/perpl.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
if (!class_exists(\Symfony\Component\Console\Application::class)) {
4+
$autoloadFileCandidates = [
5+
__DIR__ . '/../../../autoload.php',
6+
__DIR__ . '/../autoload.php',
7+
__DIR__ . '/../autoload.php.dist',
8+
];
9+
foreach ($autoloadFileCandidates as $file) {
10+
if (file_exists($file)) {
11+
require_once $file;
12+
13+
break;
14+
}
15+
}
16+
}
17+
18+
use Propel\Generator\Application;
19+
use Propel\Runtime\Propel;
20+
use Symfony\Component\Console\Command\Command;
21+
use Symfony\Component\Finder\Finder;
22+
23+
$finder = new Finder();
24+
$finder->files()->name('*.php')->in(__DIR__ . '/../src/Propel/Generator/Command')->depth(0);
25+
26+
$app = new Application('Perpl', Propel::VERSION);
27+
28+
$ns = '\\Propel\\Generator\\Command\\';
29+
30+
foreach ($finder as $file) {
31+
$r = new \ReflectionClass($ns . $file->getBasename('.php'));
32+
if ($r->isSubclassOf(Command::class) && !$r->isAbstract()) {
33+
$app->addCommands([$r->newInstance()]); // Using addCommands for BC with Symfony <8.0
34+
}
35+
}
36+
37+
$app->run();

bin/propel.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ GOTO RUN
66
:USE_PEAR_PATH
77
set PHPBIN=%PHP_PEAR_PHP_BIN%
88
:RUN
9-
"%PHPBIN%" "bin\propel" %*
9+
"%PHPBIN%" "bin\perpl" %*

bin/propel.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,3 @@
11
<?php
22

3-
if (!class_exists(\Symfony\Component\Console\Application::class)) {
4-
$autoloadFileCandidates = [
5-
__DIR__ . '/../../../autoload.php',
6-
__DIR__ . '/../autoload.php',
7-
__DIR__ . '/../autoload.php.dist',
8-
];
9-
foreach ($autoloadFileCandidates as $file) {
10-
if (file_exists($file)) {
11-
require_once $file;
12-
13-
break;
14-
}
15-
}
16-
}
17-
18-
use Propel\Generator\Application;
19-
use Propel\Runtime\Propel;
20-
use Symfony\Component\Console\Command\Command;
21-
use Symfony\Component\Finder\Finder;
22-
23-
$finder = new Finder();
24-
$finder->files()->name('*.php')->in(__DIR__ . '/../src/Propel/Generator/Command')->depth(0);
25-
26-
$app = new Application('Propel', Propel::VERSION);
27-
28-
$ns = '\\Propel\\Generator\\Command\\';
29-
30-
foreach ($finder as $file) {
31-
$r = new \ReflectionClass($ns . $file->getBasename('.php'));
32-
if ($r->isSubclassOf(Command::class) && !$r->isAbstract()) {
33-
$app->add($r->newInstance());
34-
}
35-
}
36-
37-
$app->run();
3+
require(__DIR__ . '/perpl.php');

0 commit comments

Comments
 (0)