Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ jobs:
git diff --exit-code src/ || (echo '::error::Run "php .github/sync-translations.php" to fix XLIFF files.' && exit 1)
- name: Run tests
run: ./phpunit --group integration -v
run: ./phpunit --group integration
env:
INTEGRATION_FTP_URL: 'ftp://test:test@localhost'
REDIS_HOST: 'localhost:16379'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
export COMPOSER_ROOT_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+').x-dev
composer remove --dev --no-update --no-interaction symfony/phpunit-bridge
composer require --no-progress --ansi --no-plugins psalm/phar:@stable phpunit/phpunit:^9.6 php-http/discovery psr/event-dispatcher mongodb/mongodb jetbrains/phpstorm-stubs
composer require --no-progress --ansi --no-plugins psalm/phar:@stable phpunit/phpunit:^11.5 php-http/discovery psr/event-dispatcher mongodb/mongodb jetbrains/phpstorm-stubs
- name: Generate Psalm baseline
run: |
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"

echo COLUMNS=120 >> $GITHUB_ENV
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data,integration,transient" >> $GITHUB_ENV
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group integration --exclude-group transient" >> $GITHUB_ENV
echo COMPOSER_UP='composer update --no-progress --ansi'$([[ "${{ matrix.mode }}" != low-deps ]] && echo ' --ignore-platform-req=php+') >> $GITHUB_ENV

SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V)
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
fi

# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
Copy link
Member

Choose a reason for hiding this comment

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

should this be removed ? You removed the legacy group so this will probably not work anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. For now this would work as the group is present in the 6.4 branch (see also #58370 (comment)). We need to decide which approach we do want to take.

Copy link
Member Author

Choose a reason for hiding this comment

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

see also #58370 (comment)

[[ "${{ matrix.mode }}" = high-deps && $SYMFONY_VERSION = *.4 ]] && echo LEGACY=,legacy >> $GITHUB_ENV || true
[[ "${{ matrix.mode }}" = high-deps && $SYMFONY_VERSION = *.4 ]] && echo LEGACY=" --exclude-group legacy" >> $GITHUB_ENV || true

echo SYMFONY_VERSION=$SYMFONY_VERSION >> $GITHUB_ENV
echo COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev >> $GITHUB_ENV
Expand Down Expand Up @@ -197,13 +197,13 @@ jobs:
fi

if [[ "${{ matrix.mode }}" = low-deps ]]; then
echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT'"
echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT --do-not-fail-on-deprecation'"

exit 0
fi

# matrix.mode = high-deps
echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP && $PHPUNIT$LEGACY --do-not-fail-on-deprecation'" || X=1

# get a list of the patched components (relies on .github/build-packages.php being called in the previous step)
PATCHED_COMPONENTS=$(git diff --name-only src/ | grep composer.json || true)
Expand All @@ -222,7 +222,7 @@ jobs:
echo "::group::install phpunit"
./phpunit install
echo "::endgroup::"
echo "$PATCHED_COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
echo "$PATCHED_COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT --exclude-group tty,benchmark,intl-data,integration,transient,legacy'" || X=1
Copy link
Member

Choose a reason for hiding this comment

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

no repeated --exclude-group here?

Copy link
Member Author

Choose a reason for hiding this comment

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

this job uses the PhpUnitBridge from the 6.4 branch which will use PHPUnit 9.6 where we need to pass groups like this: https://github.com/symfony/symfony/actions/runs/16643576218/job/47099900084?pr=58370#step:9:14680

Copy link
Member Author

Choose a reason for hiding this comment

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

which also means that we need to update this line for the 8.x lifecycle after merging up

fi
fi

Expand Down Expand Up @@ -250,12 +250,12 @@ jobs:

mkdir -p /opt/php/lib
echo memory_limit=-1 > /opt/php/lib/php.ini
./build/php/bin/php ./phpunit --colors=always src/Symfony/Component/Process
./phpunit install
./build/php/bin/php ./phpunit src/Symfony/Component/Process

- name: Run PhpUnitBridge tests with PHPUnit 11
- name: Run PhpUnitBridge tests with PHPUnit 9.6
if: '! matrix.mode'
run: |
./phpunit src/Symfony/Bridge/PhpUnit
env:
SYMFONY_PHPUNIT_VERSION: '11.3'
SYMFONY_DEPRECATIONS_HELPER: 'disabled'
SYMFONY_PHPUNIT_VERSION: '9.6'
149 changes: 102 additions & 47 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
contents: read

jobs:
windows:
windows-minimal-exts:
name: x86 / minimal-exts / lowest-php

defaults:
Expand All @@ -23,7 +23,83 @@ jobs:

env:
COMPOSER_NO_INTERACTION: '1'
SYMFONY_DEPRECATIONS_HELPER: 'strict'
ANSICON: '121x90 (121x90)'
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: '1'

steps:
- name: Setup Git
run: |
git config --global core.autocrlf false
git config --global user.email ""
git config --global user.name "Symfony"

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup PHP
run: |
$env:Path = 'c:\php;' + $env:Path
mkdir c:\php && cd c:\php
iwr -outf php.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.2.0-Win32-vs16-x86.zip
7z x php.zip -y >nul
Copy php.ini-development php.ini
"memory_limit=-1" >> php.ini
"serialize_precision=-1" >> php.ini
"max_execution_time=1200" >> php.ini
"post_max_size=2047M" >> php.ini
"upload_max_filesize=2047M" >> php.ini
"date.timezone=`"America/Los_Angeles`"" >> php.ini
"extension_dir=ext" >> php.ini
"extension=php_xsl.dll" >> php.ini
"extension=php_mbstring.dll" >> php.ini
"extension=php_openssl.dll" >> php.ini
cd ${{ github.workspace }}
iwr -outf composer.phar https://getcomposer.org/download/latest-stable/composer.phar

- name: Install dependencies
id: setup
run: |
$env:Path = 'c:\php;' + $env:Path
mkdir $env:APPDATA\Composer && Copy .github\composer-config.json $env:APPDATA\Composer\config.json

$env:SYMFONY_VERSION=(Select-String -CaseSensitive -Pattern " VERSION =" -SimpleMatch -Path src/Symfony/Component/HttpKernel/Kernel.php | Select Line | Select-String -Pattern "([0-9][0-9]*\.[0-9])").Matches.Value
$env:COMPOSER_ROOT_VERSION=$env:SYMFONY_VERSION + ".x-dev"

php .github/build-packages.php HEAD^ $env:SYMFONY_VERSION src\Symfony\Bridge\PhpUnit
php composer.phar update --no-progress --ansi

- name: Install PHPUnit
run: |
$env:Path = 'c:\php;' + $env:Path

php phpunit install

- name: Run tests
run: |
$env:Path = 'c:\php;' + $env:Path
$x = 0

Remove-Item -Path src\Symfony\Bridge\PhpUnit -Recurse
mv src\Symfony\Component\HttpClient\phpunit.xml.dist src\Symfony\Component\HttpClient\phpunit.xml
php phpunit src\Symfony --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group network --exclude-group transient-on-windows || ($x = 1)
# HttpClient tests need to run separately, they block when run with other components' tests concurrently
php phpunit src\Symfony\Component\HttpClient || ($x = 1)

exit $x

windows-all-extensions:
Copy link
Member

Choose a reason for hiding this comment

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

To make things easier to maintain, would it be worth backporting this split of the Windows jobs ? what do you think @nicolas-grekas ?

Copy link
Member Author

@xabbuh xabbuh Apr 22, 2025

Choose a reason for hiding this comment

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

we talked about that in #58721 but decided to not split the two test runs as we would otherwise run many of the tests twice since the phpunit.skipped would not be shared

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any discussion about that in the PR you linked

Copy link
Member Author

Choose a reason for hiding this comment

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

hm, maybe @nicolas-grekas and me talked about that on Slack directly 🤔

name: x86 / all extensions / lowest-php

defaults:
run:
shell: pwsh

runs-on: windows-2022

env:
COMPOSER_NO_INTERACTION: '1'
ANSICON: '121x90 (121x90)'
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: '1'

Expand Down Expand Up @@ -53,30 +129,28 @@ jobs:
iwr -outf php_redis.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-6.2.0-8.2-ts-vs16-x86.zip
7z x php_redis.zip -y >nul
cd ..
Copy php.ini-development php.ini-min
"memory_limit=-1" >> php.ini-min
"serialize_precision=-1" >> php.ini-min
"max_execution_time=1200" >> php.ini-min
"post_max_size=2047M" >> php.ini-min
"upload_max_filesize=2047M" >> php.ini-min
"date.timezone=`"America/Los_Angeles`"" >> php.ini-min
"extension_dir=ext" >> php.ini-min
"extension=php_xsl.dll" >> php.ini-min
"extension=php_mbstring.dll" >> php.ini-min
Copy php.ini-min php.ini-max
"zend_extension=php_opcache.dll" >> php.ini-max
"opcache.enable_cli=1" >> php.ini-max
"extension=php_openssl.dll" >> php.ini-max
"extension=php_apcu.dll" >> php.ini-max
"extension=php_igbinary.dll" >> php.ini-max
"extension=php_redis.dll" >> php.ini-max
"apc.enable_cli=1" >> php.ini-max
"extension=php_intl.dll" >> php.ini-max
"extension=php_fileinfo.dll" >> php.ini-max
"extension=php_pdo_sqlite.dll" >> php.ini-max
"extension=php_curl.dll" >> php.ini-max
"extension=php_sodium.dll" >> php.ini-max
Copy php.ini-max php.ini
Copy php.ini-development php.ini
"memory_limit=-1" >> php.ini
"serialize_precision=-1" >> php.ini
"max_execution_time=1200" >> php.ini
"post_max_size=2047M" >> php.ini
"upload_max_filesize=2047M" >> php.ini
"date.timezone=`"America/Los_Angeles`"" >> php.ini
"extension_dir=ext" >> php.ini
"extension=php_xsl.dll" >> php.ini
"extension=php_mbstring.dll" >> php.ini
"zend_extension=php_opcache.dll" >> php.ini
"opcache.enable_cli=1" >> php.ini
"extension=php_openssl.dll" >> php.ini
"extension=php_apcu.dll" >> php.ini
"extension=php_igbinary.dll" >> php.ini
"extension=php_redis.dll" >> php.ini
"apc.enable_cli=1" >> php.ini
"extension=php_intl.dll" >> php.ini
"extension=php_fileinfo.dll" >> php.ini
"extension=php_pdo_sqlite.dll" >> php.ini
"extension=php_curl.dll" >> php.ini
"extension=php_sodium.dll" >> php.ini
cd ${{ github.workspace }}
iwr -outf composer.phar https://getcomposer.org/download/latest-stable/composer.phar

Expand All @@ -102,32 +176,13 @@ jobs:
run: |
choco install --no-progress memurai-developer

- name: Run tests (minimal extensions)
if: always() && steps.setup.outcome == 'success'
run: |
$env:Path = 'c:\php;' + $env:Path
$env:SYMFONY_PHPUNIT_SKIPPED_TESTS = 'phpunit.skipped'
$x = 0

Copy c:\php\php.ini-min c:\php\php.ini
Remove-Item -Path src\Symfony\Bridge\PhpUnit -Recurse
mv src\Symfony\Component\HttpClient\phpunit.xml.dist src\Symfony\Component\HttpClient\phpunit.xml
php phpunit src\Symfony --exclude-group tty,benchmark,intl-data,network,transient-on-windows || ($x = 1)
# HttpClient tests need to run separately, they block when run with other components' tests concurrently
php phpunit src\Symfony\Component\HttpClient || ($x = 1)

exit $x

- name: Run tests
if: always() && steps.setup.outcome == 'success'
run: |
$env:Path = 'c:\php;' + $env:Path
$env:SYMFONY_PHPUNIT_SKIPPED_TESTS = 'phpunit.skipped'
$x = 0

Copy c:\php\php.ini-max c:\php\php.ini
php phpunit src\Symfony --exclude-group tty,benchmark,intl-data,network,transient-on-windows || ($x = 1)
php phpunit src\Symfony --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group network --exclude-group transient-on-windows --requires-php-extension apcu --requires-php-extension curl --requires-php-extension fileinfo --requires-php-extension igbinary --requires-php-extension intl --requires-php-extension openssl --requires-php-extension pdo_sqlite --requires-php-extension redis --requires-php-extension sodium || ($x = 1)
# HttpClient tests need to run separately, they block when run with other components' tests concurrently
php phpunit src\Symfony\Component\HttpClient || ($x = 1)
php phpunit src\Symfony\Component\HttpClient --requires-php-extension curl --requires-php-extension openssl || ($x = 1)

exit $x
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ composer.lock
phpunit.xml
.php-cs-fixer.cache
.php-cs-fixer.php
.phpunit.cache
.phpunit.result.cache
composer.phar
package.tar
Expand Down
2 changes: 1 addition & 1 deletion phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
exit(1);
}
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=9.6');
putenv('SYMFONY_PHPUNIT_VERSION=11.5');
}
if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=deprecations=1');
Expand Down
34 changes: 9 additions & 25 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnDeprecation="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down Expand Up @@ -46,7 +47,7 @@
</exclude>
</groups>

<coverage>
<source ignoreSuppressionOfDeprecations="true">
<include>
<directory>./src/Symfony/</directory>
</include>
Expand All @@ -65,28 +66,11 @@
<directory>./src/Symfony/Component/*/*/vendor</directory>
<directory>./src/Symfony/Contracts/*/vendor</directory>
</exclude>
</coverage>
</source>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
<arguments>
<array>
<element key="time-sensitive">
<array>
<element key="0"><string>Cache\IntegrationTests</string></element>
<element key="1"><string>Symfony\Bridge\Doctrine\Middleware\Debug</string></element>
<element key="2"><string>Symfony\Bridge\Doctrine\Middleware\IdleConnection</string></element>
<element key="3"><string>Symfony\Component\Cache</string></element>
<element key="4"><string>Symfony\Component\Cache\Tests\Fixtures</string></element>
<element key="5"><string>Symfony\Component\Cache\Tests\Traits</string></element>
<element key="6"><string>Symfony\Component\Cache\Traits</string></element>
<element key="7"><string>Symfony\Component\Console</string></element>
<element key="8"><string>Symfony\Component\HttpFoundation</string></element>
<element key="9"><string>Symfony\Component\Uid</string></element>
</array>
</element>
</array>
</arguments>
</listener>
</listeners>
<extensions>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension">
<parameter name="clock-mock-namespaces" value="Cache\IntegrationTests,Symfony\Bridge\Doctrine\Middleware\Debug,Symfony\Bridge\Doctrine\Middleware\IdleConnection,Symfony\Component\Cache,Symfony\Component\Cache\Tests\Fixtures,Symfony\Component\Cache\Tests\Traits,Symfony\Component\Cache\Traits,Symfony\Component\Console,Symfony\Component\HttpFoundation,Symfony\Component\Uid" />
</bootstrap>
</extensions>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectRepository;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
Expand Down Expand Up @@ -64,9 +66,8 @@ public function testResolveWithoutManager()
$this->assertSame([], $resolver->resolve($request, $argument));
}

/**
* @group legacy
*/
#[IgnoreDeprecations]
#[Group('legacy')]
public function testResolveWithNoIdAndDataOptional()
{
$manager = $this->createMock(ObjectManager::class);
Expand Down Expand Up @@ -251,9 +252,8 @@ public static function idsProvider(): iterable
yield ['foo'];
}

/**
* @group legacy
Copy link
Member

Choose a reason for hiding this comment

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

should we keep a legacy group for our tests covering deprecated behaviors ? Our deps=high job is excluding this group when running tests for a version that is not part of the last major version (as the dependencies could be installed at the next major version already):

# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
[[ "${{ matrix.mode }}" = high-deps && $SYMFONY_VERSION = *.4 ]] && echo LEGACY=,legacy >> $GITHUB_ENV || true

Copy link
Member

Choose a reason for hiding this comment

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

thinking about this again, I think this option was overkill and was leading to not testing some parts of the code in CI in our LTS branches. Many legacy tests we have are about testing deprecations of their own component, which does not need such exclusion. Tests relying on cross-package deprecations could be responsible for skipping themselves when needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to make a decision here. There’s two options:

  1. Don’t skip the legacy groups on the high deps job. This would require to update some of the tests in the 6.4 (all the tests that are currently failing as I have removed the exclusion for now).
  2. Keep the current CI config but then we need to keep the legacy group at lese for cross-component tests.

Copy link
Member

Choose a reason for hiding this comment

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

I suggest updating the test in 6.4 to skip them when they rely on cross-package deprecated APIs and the other component is installed in a version with the BC layer removed.

Skipping all legacy tests skips much more tests than necessary. Most of our legacy tests are about testing the BC layer of the package itself.

Copy link
Member

Choose a reason for hiding this comment

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

I was chatting with @xabbuh about this yesterday and I think it'd be better to keep the existing policy of always using the legacy group when also skipping the deprecations. This worked really nice for years, and the code that is "overskipped" is still run on other matric lines, so the coverage it still as good as desired.
The issue with your proposal @stof is that it would require us to think about each test case, which means increasing the maintenance overhead. Using a simple rule that doesn't need any advanced thoughts makes automation possible for example, and things easy to explain to contributors (a bot can do it).

*/
#[IgnoreDeprecations]
#[Group('legacy')]
public function testResolveGuessOptional()
{
$manager = $this->createMock(ObjectManager::class);
Expand Down
Loading