Skip to content

[Turbo] Fix Turbo CI (PHPStan & Functional tests) #2766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 15 additions & 4 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,27 @@ jobs:
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.php-packages-matrix.outputs.packages) }}
php-version: [ '8.1', '8.2', '8.3', '8.4']
dependency-version: ['']
symfony-version: ['']
minimum-stability: ['stable']
include:
# lowest deps
- php-version: '8.1'
dependency-version: 'lowest'
# LTS version of Symfony
- php-version: '8.1'
symfony-version: '6.4.*'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure environment
run: |
echo COLUMNS=120 >> $GITHUB_ENV
echo COMPOSER_MIN_STAB='composer config minimum-stability stable --ansi' >> $GITHUB_ENV
echo COMPOSER_UP='composer update --no-progress --no-interaction --ansi' >> $GITHUB_ENV
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability || 'stable' }} --ansi' >> $GITHUB_ENV
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
echo PHPUNIT_INSTALL='vendor/bin/simple-phpunit install' >> $GITHUB_ENV
echo PHPSTAN='vendor/bin/phpstan' >> $GITHUB_ENV

# TODO: Only Turbo has PHPStan configuration, let's improve this later :)
Expand All @@ -69,4 +80,4 @@ jobs:
run: |
source .github/workflows/.utils.sh

echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPSTAN)'"
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT_INSTALL && $PHPSTAN)'"
4 changes: 3 additions & 1 deletion .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ name: Functional Tests
on:
push:
paths:
- '.github/workflows/functional-tests.yml'
- 'src/Turbo/**'
pull_request:
paths:
- '.github/workflows/functional-tests.yml'
- 'src/Turbo/**'

jobs:
Expand All @@ -30,7 +32,7 @@ jobs:
symfony-version: '6.4.*'

env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=5.4' }}
services:
mercure:
image: dunglas/mercure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
symfony-version: '6.4.*'

env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=5.4' }}
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion src/Turbo/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/.git* export-ignore
/.symfony.bundle.yaml export-ignore
/phpunit.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpstan.dist.neon export-ignore
/assets/src export-ignore
/assets/test export-ignore
/assets/vitest.config.js export-ignore
Expand Down
7 changes: 4 additions & 3 deletions src/Turbo/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
"require-dev": {
"doctrine/doctrine-bundle": "^2.4.3",
"doctrine/orm": "^2.8 | 3.0",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan": "^2.1.17",
"symfony/asset-mapper": "^6.4|^7.0",
"symfony/debug-bundle": "^5.4|^6.0|^7.0",
"symfony/form": "^5.4|^6.0|^7.0",
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/mercure-bundle": "^0.3.7",
"symfony/messenger": "^5.4|^6.0|^7.0",
"symfony/panther": "^2.1",
"symfony/panther": "^2.2",
"symfony/phpunit-bridge": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|6.3.*|^7.0",
"symfony/property-access": "^5.4|^6.0|^7.0",
Expand All @@ -57,7 +57,8 @@
"symfony/twig-bundle": "^6.4|^7.0",
"symfony/web-profiler-bundle": "^5.4|^6.0|^7.0",
"symfony/expression-language": "^5.4|^6.0|^7.0",
"dbrekelmans/bdi": "dev-main"
"dbrekelmans/bdi": "dev-main",
"php-webdriver/webdriver": "^1.15"
},
"conflict": {
"symfony/flex": "<1.13"
Expand Down
12 changes: 2 additions & 10 deletions src/Turbo/phpstan.neon.dist → src/Turbo/phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ parameters:
- tests/app/var/*
# The Symfony Configuration API isn't good enough to be analysed
- src/DependencyInjection/Configuration.php
# to allow installing with various phsptan versions without reporting old errors here
reportUnmatchedIgnoredErrors: false
inferPrivatePropertyTypeFromConstructor: true
bootstrapFiles:
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
Expand Down Expand Up @@ -36,16 +38,6 @@ parameters:
count: 1
path: src/Bridge/Mercure/TurboStreamListenRenderer.php

-
message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Event\\\\OnFlushEventArgs\\:\\:getEntityManager\\(\\)\\.$#"
count: 1
path: src/Doctrine/BroadcastListener.php

-
message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Event\\\\PostFlushEventArgs\\:\\:getEntityManager\\(\\)\\.$#"
count: 1
path: src/Doctrine/BroadcastListener.php

-
message: "#^Method Symfony\\\\UX\\\\Turbo\\\\TurboStreamResponse::__construct\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
1 change: 1 addition & 0 deletions src/Turbo/src/Attribute/Broadcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ final class Broadcast
*/
public function __construct(...$options)
{
// @phpstan-ignore function.alreadyNarrowedType
if ([0] === array_keys($options) && \is_array($options[0]) && \is_string(key($options[0]))) {
$options = $options[0];
}
Expand Down
5 changes: 0 additions & 5 deletions src/Turbo/src/Bridge/Mercure/Broadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ public function broadcast(object $entity, string $action, array $options): void
$topics = [];

foreach ((array) ($options['topics'] ?? []) as $topic) {
if (!\is_string($topic)) {
$topics[] = $topic;
continue;
}
Comment on lines -71 to -74
Copy link
Member Author

Choose a reason for hiding this comment

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

I and PHPStan does not see how $topic can not be a string at this point.

Copy link
Member Author

Choose a reason for hiding this comment

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

friendly ping @rskuipers, by any chance :)


if (!str_starts_with($topic, '@=')) {
$topics[] = $topic;
continue;
Expand Down
2 changes: 2 additions & 0 deletions src/Turbo/src/Doctrine/BroadcastListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function onFlush(EventArgs $eventArgs): void
return;
}

// @phpstan-ignore function.alreadyNarrowedType, method.notFound (`getEntityManager()` has been removed in Doctrine 3.0)
$em = method_exists($eventArgs, 'getObjectManager') ? $eventArgs->getObjectManager() : $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityInsertions() as $entity) {
Expand All @@ -85,6 +86,7 @@ public function postFlush(EventArgs $eventArgs): void
return;
}

// @phpstan-ignore function.alreadyNarrowedType, method.notFound (`getEntityManager()` has been removed in Doctrine 3.0)
$em = method_exists($eventArgs, 'getObjectManager') ? $eventArgs->getObjectManager() : $eventArgs->getEntityManager();

try {
Expand Down
Loading