Skip to content

Commit

Permalink
Merge pull request #24 from spatie/php-and-symfony-support-updates
Browse files Browse the repository at this point in the history
PHP and Symfony version support updates
  • Loading branch information
amacrobert authored Dec 16, 2023
2 parents 20c4c03 + 791522f commit b3dd2bb
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 23 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
name: Tests

on: [push, pull_request]
on: pull_request

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.1, 8.0]
stability: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
os:
- ubuntu-latest
- windows-latest
php:
- '8.1'
- '8.2'
- '8.3'
symfony:
- '5.4.*'
- '6.3.*'
- '6.4.*'
- '7.0.*'
stability:
- prefer-lowest
- prefer-stable
exclude:
- { symfony: '7.0.*', php: '8.1' }
- { symfony: '7.0.*', php: '8.2' }

name: PHP ${{ matrix.php }} / Symfony ${{ matrix.symfony }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
Expand All @@ -30,6 +45,9 @@ jobs:
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Write Symfony requirement
run: echo "${{ matrix.symfony }}" > ${{ github.workspace }}/symfony-version.txt

- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction

Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM php:8.2
WORKDIR /var/task
RUN apt-get update -y && apt-get install -y git zip unzip
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"spatie/ignition": "^1.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.3 || ^7.0",
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
Expand Down Expand Up @@ -55,6 +55,6 @@
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
"minimum-stability": "stable",
"prefer-stable": true
}
9 changes: 9 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3'
services:
ignition-bundle-test-environment:
container_name: ignition-bundle
build: .
image: php:8.2
tty: true
volumes:
- .:/var/task
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('ignition');
$rootNode = $treeBuilder->getRootNode();
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/AppTemplate/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": ">=7.2.5",
"php": ">=8.1.0",
"ext-ctype": "*",
"ext-iconv": "*",
"spatie/symfony-ignition-bundle": "*",
Expand Down
13 changes: 6 additions & 7 deletions tests/Functional/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@ abstract public function testSymfonyworks(string $symfonyVersion): void;
*/
public function versionProvider()
{
return [
'Symfony 5.4' => ['5.4.*'],
'Symfony 6.0' => ['6.0.*'],
];
$symfonyVersion = trim(file_get_contents(__DIR__ . '/../../symfony-version.txt'));

return $symfonyVersion;
}

protected function installSymfony(string $symfonyRequirement = '6.0.*'): void
protected function installSymfony(string $symfonyVersion): void
{
// Create a fresh directory for the Symfony app using the template
$filesystem = new Filesystem();

// Windows was having trouble with Filesystem::remove, so rename instead
// $filesystem->remove(self::APP_DIRECTORY);
if (file_exists(self::APP_DIRECTORY)) {
$filesystem->rename(self::APP_DIRECTORY, self::APP_DIRECTORY . '~');
$filesystem->rename(self::APP_DIRECTORY, self::APP_DIRECTORY . '~', overwrite: true);
}
$filesystem->mirror(self::APP_TEMPLATE, self::APP_DIRECTORY);

Expand All @@ -51,7 +50,7 @@ protected function installSymfony(string $symfonyRequirement = '6.0.*'): void
'--optimize-autoloader',
],
self::APP_DIRECTORY,
['SYMFONY_REQUIRE' => $symfonyRequirement]
['SYMFONY_REQUIRE' => $symfonyVersion]
);

$composerInstall->mustRun();
Expand Down
10 changes: 5 additions & 5 deletions tests/Functional/InstallWithSymfonyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\Process\Process;

class InstallWithSymfony extends FunctionalTest
class InstallWithSymfonyTest extends FunctionalTest
{
/**
* Install a Symfony application. Verify its version with bin/console, then
* fake a HTTP request to the front controller. Assert the response is an
* fake an HTTP request to the front controller. Assert the response is an
* Ignition error page thrown in a Symfony controller.
*
* @dataProvider versionProvider
*/
public function testSymfonyWorks(string $symfonyRequirement): void
public function testSymfonyWorks(string $symfonyVersion): void
{
$this->installSymfony($symfonyRequirement);
$this->installSymfony($symfonyVersion);

// Assert the expected version of Symfony was installed
$getSymfonyVersion = new Process([
Expand All @@ -29,7 +29,7 @@ public function testSymfonyWorks(string $symfonyRequirement): void
$this->assertCommandIsSuccessful($getSymfonyVersion);

$versionOutput = $getSymfonyVersion->getOutput();
$majorDotMinorSymfonyRequirement = implode('.', explode('.', $symfonyRequirement, -1));
$majorDotMinorSymfonyRequirement = implode('.', explode('.', ltrim($symfonyVersion, '^>='), -1));
$expectedOutput = sprintf('Symfony %s', $majorDotMinorSymfonyRequirement);
$this->assertStringContainsString($expectedOutput, $versionOutput);

Expand Down

0 comments on commit b3dd2bb

Please sign in to comment.