Skip to content

Commit

Permalink
chore: make CI working again (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal authored Dec 25, 2021
1 parent ca20d06 commit f4bef8a
Show file tree
Hide file tree
Showing 19 changed files with 2,512 additions and 158 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ bin/ export-ignore
fixtures/ export-ignore
spec/ export-ignore
tests/ export-ignore
tools/ export-ignore
.eslintignore export-ignore
.eslintrc.js export-ignore
.php-cs-fixer.php export-ignore
Expand All @@ -12,5 +13,6 @@ behat.yml.dist export-ignore
cypress.json export-ignore
list-staged.config.js export-ignore
phpstan.neon export-ignore
phpstan-baseline.neon export-ignore
phpunit.xml.dist export-ignore
yarn.lock export-ignore
25 changes: 9 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
PHPUNIT_FLAGS: -v
COMPOSER_MEMORY_LIMIT: -1

PHP_VERSION_DEFAULT: 7.3
PHP_VERSION_DEFAULT: 8.0
NODE_VERSION: 14.x

jobs:
Expand All @@ -24,7 +24,6 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION_DEFAULT }}
ini-values: memory_limit=-1, session.gc_probability=0, opcache.enable=1, opcache.enable_cli=1, opcache.memory_consumption=256, opcache.max_accelerated_files=20000, opcache.validate_timestamps=0, realpath_cache_size=4096K, realpath_cache_ttl=600

- name: Install Node.js
uses: actions/setup-node@v2
Expand All @@ -50,11 +49,10 @@ jobs:
matrix:
config:
# Minimum supported dependencies with the latest and oldest PHP version
- PHP_VERSION: 7.3
- PHP_VERSION: 7.4
COMPOSER_FLAGS: --prefer-stable --prefer-lowest

# Test the latest stable release
- PHP_VERSION: 7.3
- PHP_VERSION: 7.4
- PHP_VERSION: 8.0
COVERAGE: true
Expand All @@ -68,7 +66,9 @@ jobs:
- PHP_VERSION: 8.0
SYMFONY_VERSION: 4.4.* # Last 4.x version
- PHP_VERSION: 8.0
SYMFONY_VERSION: 5.* # Last 5.x version
SYMFONY_VERSION: 5.4.* # Last 5.4.x version
- PHP_VERSION: 8.0
SYMFONY_VERSION: 6.0.* # Last 6.1.x version
- PHP_VERSION: 8.0
STABILITY: dev
SYMFONY_VERSION: 6.* # Last 6.x version
Expand All @@ -81,10 +81,9 @@ jobs:
with:
php-version: ${{ matrix.config.PHP_VERSION }}
coverage: ${{ matrix.config.COVERAGE }}
ini-values: memory_limit=-1, session.gc_probability=0, opcache.enable=1, opcache.enable_cli=1, opcache.memory_consumption=256, opcache.max_accelerated_files=20000, opcache.validate_timestamps=0, realpath_cache_size=4096K, realpath_cache_ttl=600

- name: Install globally Symfony Flex
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-main
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex

- name: Configure Composer minimum stability
if: matrix.config.STABILITY
Expand All @@ -106,9 +105,6 @@ jobs:
- name: Run PHPUnit
run: composer phpunit -- ${{ matrix.config.PHPUNIT_FLAGS }}

- name: Run phpspec
run: composer phpspec run

- name: Run Behat
run: composer behat

Expand All @@ -124,18 +120,15 @@ jobs:
php-version: ${{ env.PHP_VERSION_DEFAULT }}
coverage: none
extensions: ctype, iconv, intl
ini-values: memory_limit=-1, session.gc_probability=0, opcache.enable=1, opcache.enable_cli=1, opcache.memory_consumption=256, opcache.max_accelerated_files=20000, opcache.validate_timestamps=0, realpath_cache_size=4096K, realpath_cache_ttl=600

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader

- run: composer server-start
- run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run Cypress
uses: cypress-io/github-action@v2

- run: composer server-stop
with:
start: composer server-start
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,37 @@
"sort-packages": true
},
"scripts": {
"bin": "echo 'bin not installed'",
"phpstan": "phpstan analyze --ansi",
"php-cs-fixer": "php-cs-fixer fix -v",
"php-cs-fixer@ci": "php-cs-fixer fix -v --diff --dry-run",
"phpunit": "phpunit",
"phpspec": "phpspec --ansi",
"behat": "behat --colors",
"server-start": "APP_ENV=test ./bin/symfony server:start --no-tls --dir fixtures/applications/Symfony --daemon",
"server-stop": "APP_ENV=test ./bin/symfony server:stop --dir fixtures/applications/Symfony",
"auto": [
"cd fixtures/applications/Symfony && APP_ENV=test bin/console cache:clear"
],
"post-install-cmd": [
"@composer bin all install --ansi",
"@auto"
],
"post-update-cmd": [
"@composer bin all update --ansi",
"@auto"
]
},
"require": {
"php": "^7.3 || ^8.0",
"php": "^7.4 || ^8.0",
"ext-json": "*",
"phpunit/phpunit": "^8.5 || ^9.0",
"symfony/console": "^4.4 || ^5.0 || ^6.0",
"symfony/mailer": "^4.4 || ^5.0 || ^6.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
"behat/behat": "^3.6",
"friends-of-behat/symfony-extension": "^2.2",
"friendsofphp/php-cs-fixer": "^3.0",
"phpspec/phpspec": "^6.1",
"phpstan/phpstan": "^0.12.23",
"phpstan/phpstan-phpunit": "^0.12.8",
"phpstan/phpstan-strict-rules": "^0.12.2",
"phpstan/phpstan-symfony": "^0.12.6",
"phpstan/phpstan-webmozart-assert": "^0.12.4",
"symfony/framework-bundle": "^4.4.14 || ^5.0 || ^6.0",
"symfony/psr7-pack": "^1.0"
},
Expand All @@ -57,12 +53,16 @@
},
"autoload-dev": {
"psr-4": {
"spec\\": "spec/",
"Kocal\\SymfonyMailerTesting\\Tests\\": "tests/",
"Kocal\\SymfonyMailerTesting\\Tests\\Bridge\\Behat\\": "tests/Bridge/Behat/bootstrap/",
"Kocal\\SymfonyMailerTesting\\Fixtures\\": "fixtures/",
"Kocal\\SymfonyMailerTesting\\Fixtures\\Applications\\": "fixtures/applications/",
"Kocal\\SymfonyMailerTesting\\Fixtures\\Applications\\Symfony\\App\\": "fixtures/applications/Symfony/src/"
}
},
"extra": {
"bamarni-bin": {
"target-directory": "tools"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
test: true
session:
storage_factory_id: session.storage.factory.mock_file
12 changes: 5 additions & 7 deletions fixtures/applications/Symfony/config/routes/annotations.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
controllers:
resource: '../../src/Controller/'
type: annotation

kernel:
resource: ../../src/Kernel.php
type: annotation
send_basic_email:
path: /send-basic-email
controller: Kocal\SymfonyMailerTesting\Fixtures\Applications\Symfony\App\Controller\EmailController::sendBasicEmail
methods: [POST]
format: json
10 changes: 3 additions & 7 deletions fixtures/applications/Symfony/src/Controller/EmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,20 @@
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route;

class EmailController extends AbstractController
{
/**
* @Route("/send-basic-email", methods={"POST"}, defaults={"format": "json"})
*/
public function sendBasicEmail(Request $request, MailerInterface $mailer): Response
{
$email = (new Email())
->from(Address::fromString($request->request->get('from', '[email protected]')))
->to(Address::fromString($request->request->get('to', '[email protected]')))
->from(Address::create($request->request->get('from', '[email protected]')))
->to(Address::create($request->request->get('to', '[email protected]')))
->subject($request->request->get('subject', 'Email sent from a Symfony application!'))
->text($request->request->get('text', 'Hello world!'))
->html($request->request->get('html', '<b>Hello world!</b>'))
;

foreach ($request->request->get('attachments', []) as $attachment) {
foreach ($request->request->all('attachments') as $attachment) {
$email->attach($attachment['body'], $attachment['name'] ?? null, $attachment['contentType'] ?? null);
}

Expand Down
54 changes: 40 additions & 14 deletions fixtures/applications/Symfony/src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,48 @@
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;

class Kernel extends BaseKernel
{
use MicroKernelTrait;
if (BaseKernel::MAJOR_VERSION >= 6) {
abstract class AbstractKernel extends BaseKernel
{
use MicroKernelTrait;
protected const CONFIG_EXTS = '.{php,xml,yaml,yml}';

protected function configureContainerSpecificSymfonyVersion(ContainerBuilder $container, LoaderInterface $loader)
{
$confDir = $this->getProjectDir().'/config';

$loader->load($confDir.'/{packages_symfony6+}/*'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{packages_symfony6+}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob');
}
}
} else {
abstract class AbstractKernel extends BaseKernel
{
use MicroKernelTrait;
protected const CONFIG_EXTS = '.{php,xml,yaml,yml}';

public function configureRoutes(\Symfony\Component\Routing\RouteCollectionBuilder $routes)
{
$confDir = $this->getProjectDir().'/config';

$routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
}

private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
protected function configureContainerSpecificSymfonyVersion(ContainerBuilder $container, LoaderInterface $loader)
{
$confDir = $this->getProjectDir().'/config';

$loader->load($confDir.'/{packages_symfony5-}/*'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{packages_symfony5-}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob');
}
}
}

class Kernel extends AbstractKernel
{
public function registerBundles(): iterable
{
$contents = require $this->getProjectDir().'/config/bundles.php';
Expand All @@ -41,16 +75,8 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa

$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob');
$this->configureContainerSpecificSymfonyVersion($container, $loader);
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
}

protected function configureRoutes(RouteCollectionBuilder $routes): void
{
$confDir = $this->getProjectDir().'/config';

$routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
}
}
17 changes: 17 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
parameters:
ignoreErrors:
-
message: "#^Method Kocal\\\\SymfonyMailerTesting\\\\Tests\\\\Bridge\\\\Behat\\\\EmailContext\\:\\:iSendAnEmail\\(\\) has parameter \\$table with no value type specified in iterable type Behat\\\\Gherkin\\\\Node\\\\TableNode\\.$#"
count: 1
path: tests/Bridge/Behat/bootstrap/EmailContext.php

-
message: "#^Access to an undefined static property static\\(Kocal\\\\SymfonyMailerTesting\\\\Tests\\\\Bridge\\\\Symfony\\\\EventListener\\\\MailerLoggerListenerTest\\)\\:\\:\\$container\\.$#"
count: 2
path: tests/Bridge/Symfony/EventListener/MailerLoggerListenerTest.php

-
message: "#^Call to function method_exists\\(\\) with \\$this\\(Kocal\\\\SymfonyMailerTesting\\\\Tests\\\\Bridge\\\\Symfony\\\\EventListener\\\\MailerLoggerListenerTest\\) and 'getContainer' will always evaluate to true\\.$#"
count: 2
path: tests/Bridge/Symfony/EventListener/MailerLoggerListenerTest.php

19 changes: 8 additions & 11 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-symfony/rules.neon
- ./phpstan-baseline.neon
- tools/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon
- tools/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon
- tools/phpstan/vendor/phpstan/phpstan-phpunit/rules.neon
- tools/phpstan/vendor/phpstan/phpstan-webmozart-assert/extension.neon
- tools/phpstan/vendor/phpstan/phpstan-symfony/extension.neon
- tools/phpstan/vendor/phpstan/phpstan-symfony/rules.neon

parameters:
level: max

paths:
- src
- tests
# - spec wait for PHPStan 0.12 support (https://github.com/proget-hq/phpstan-phpspec)

excludes_analyse:
- fixtures/applications/Symfony
- spec # wait for PHPStan 0.12 support (https://github.com/proget-hq/phpstan-phpspec)

symfony:
container_xml_path: 'fixtures/applications/Symfony/var/cache/test/Kocal_SymfonyMailerTesting_Fixtures_Applications_Symfony_App_KernelTestDebugContainer.xml'

inferPrivatePropertyTypeFromConstructor: true

reportUnmatchedIgnoredErrors: false
ignoreErrors:
# Should be fixed by Symfony
- '#Property Kocal\\SymfonyMailerTesting\\Tests\\Bridge\\Symfony\\(.*?)::\$class has no typehint specified.#'

# Should be fixed by behat
- '#with no value type specified in iterable type Behat\\Gherkin\\Node\\TableNode.$#'

This file was deleted.

Loading

0 comments on commit f4bef8a

Please sign in to comment.