Skip to content

Updated symfony components #47

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

Merged
merged 1 commit into from
Sep 10, 2019
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 50 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,79 @@ language: php
matrix:
fast_finish: true
include:
- php: 5.5
- php: 5.6
env:
- STORAGE=doctrine
- php: 5.5
env:
- STORAGE=array
- COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction"
- php: 5.6
env:
- STORAGE=doctrine
- CODE_COVERAGE=true
- php: 5.6
env:
- STORAGE=array
- php: 7.0
env:
- STORAGE=doctrine
- COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction"
- php: 7.0
env:
- STORAGE=doctrine
- php: 7.0
env:
- STORAGE=array
- php: 7.0
env:
- STORAGE=doctrine
- COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction"
- php: 7.0
env:
- STORAGE=doctrine
- php: 7.1
env:
- STORAGE=array
- php: 7.1
env:
- STORAGE=doctrine
- COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction"
- php: 7.1
Copy link
Member

Choose a reason for hiding this comment

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

we should test on 7.3

Copy link
Member Author

Choose a reason for hiding this comment

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

cannot :) we would have to update phpunit and then i cannot test 5.6 😂

Copy link
Member

@alexander-schranz alexander-schranz Sep 10, 2019

Choose a reason for hiding this comment

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

Other bundles are also tested from 5.5 to 7.3 so this should be no problem when allowing newer phpunit version:

"phpunit/phpunit": "^4.8 || ^5.0",

env:
- STORAGE=doctrine
- CODE_COVERAGE="--coverage-clover=coverage.clover"
- php: 7.2
env:
- STORAGE=array
- php: 7.2
env:
- STORAGE=doctrine
- COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction"
- php: 7.2
env:
- STORAGE=doctrine
- php: 7.3
env:
- STORAGE=array
- php: 7.3
env:
- STORAGE=doctrine

before_install:
- if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi
- phpenv config-add tests/travis.php.ini

install:
- composer self-update
- composer update
- composer update $COMPOSER_FLAGS
- composer info

before_script:
- STORAGE=doctrine tests/app/console doctrine:database:create
- STORAGE=doctrine tests/app/console doctrine:schema:create
- if [[ $STORAGE == 'doctrine' ]]; then tests/app/console doctrine:database:create ; fi
- if [[ $STORAGE == 'doctrine' ]]; then tests/app/console doctrine:schema:create ; fi

script:
- vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover
- vendor/bin/phpunit -c phpunit.xml.dist $CODE_COVERAGE

after_script:
- if [[ $CODE_COVERAGE == 'true' ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi
- if [[ $CODE_COVERAGE == 'true' ]]; then php ocular.phar code-coverage:upload --access-token="230ec5e01daf5bb3e46ea304fb20348b52d80de73463ec08ee9c96fcd1349e35" --format=php-clover coverage.clover ; fi
- if [[ -n $CODE_COVERAGE ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi
- if [[ -n $CODE_COVERAGE ]]; then php ocular.phar code-coverage:upload --access-token="230ec5e01daf5bb3e46ea304fb20348b52d80de73463ec08ee9c96fcd1349e35" --format=php-clover coverage.clover ; fi

cache:
directories:
Expand Down
25 changes: 14 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@
}
],
"require": {
"php": "~5.5 || ~7.0",
"php-task/php-task": "^1.2",
"symfony/http-kernel": "^2.6 || ^3.0",
"symfony/dependency-injection": "^2.6 || ^3.0",
"symfony/expression-language": "^2.6 || ^3.0",
"symfony/config": "^2.6 || ^3.0",
"symfony/console": "^2.6 || ^3.0",
"symfony/process": "^2.6 || ^3.0",
"php": "^5.6 || ^7.0",
"php-task/php-task": "^1.3",
"symfony/http-kernel": "^2.8 || ^3.4 || ^4.0",
"symfony/dependency-injection": "^2.8 || ^3.4 || ^4.0",
"symfony/expression-language": "^2.8 || ^3.4 || ^4.0",
"symfony/config": "^2.8 || ^3.4 || ^4.0",
"symfony/console": "^2.8 || ^3.4 || ^4.0",
"symfony/process": "^2.8 || ^3.4 || ^4.0",
"doctrine/orm": "^2.5"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"symfony/framework-bundle": "^2.6",
"symfony/finder": "^2.6",
"phpunit/phpunit": "^4.8 || ^5.0",
"sebastian/comparator": "^1.2.3",
"symfony/debug": "^2.8 || ^3.4 || ^4.0",
"symfony/framework-bundle": "^2.8 || ^3.4 || ^4.0",
"symfony/finder": "^2.8 || ^3.4 || ^4.0",
"symfony/yaml": "^2.8 || ^3.4 || ^4.0",
"doctrine/doctrine-bundle": "^1.5",
"doctrine/data-fixtures": "^1.1"
},
Expand Down
3 changes: 2 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php">
bootstrap="tests/bootstrap.php">
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_DIR" value="tests/app" />
<server name="KERNEL_CLASS" value="TestKernel" />
</php>

<testsuites>
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/TaskExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function loadDoctrineAdapter(array $config, ContainerBuilder $container)
*/
private function loadLockingComponent(array $config, ContainerBuilder $container, LoaderInterface $loader)
{
if (!$config['enabled']) {
if (!$config['enabled'] || 'null' === $config['storage']) {
return $loader->load('locking/null.xml');
}

Expand Down Expand Up @@ -135,7 +135,7 @@ private function getLockingStorageAliases(ContainerBuilder $container)
{
$taggedServices = $container->findTaggedServiceIds('task.lock.storage');

$result = [];
$result = ['null'];
foreach ($taggedServices as $id => $tags) {
foreach ($tags as $tag) {
$result[$tag['alias']] = $id;
Expand Down
9 changes: 3 additions & 6 deletions src/Executor/ExecutionProcessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Task\TaskBundle\Executor;

use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;

/**
* Factory for execution-process.
Expand Down Expand Up @@ -46,10 +45,8 @@ public function __construct($consolePath, $processTimeout, $environment)
*/
public function create($uuid)
{
return $process = ProcessBuilder::create(
[$this->consolePath, 'task:execute', $uuid, '--env=' . $this->environment]
)
->setTimeout($this->processTimeout)
->getProcess();
return $process = (new Process(
implode(' ', [$this->consolePath, 'task:execute', $uuid, '--env=' . $this->environment])
))->setTimeout($this->processTimeout);
}
}
10 changes: 5 additions & 5 deletions src/Resources/config/command.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.command.run" class="Task\TaskBundle\Command\RunCommand">
<service id="task.command.run" class="Task\TaskBundle\Command\RunCommand" public="true">
<argument type="string">task:run</argument>
<argument type="service" id="task.runner"/>
<argument type="service" id="task.scheduler"/>
Expand All @@ -12,30 +12,30 @@
<tag name="console.command"/>
</service>

<service id="task.command.run_handler" class="Task\TaskBundle\Command\RunHandlerCommand">
<service id="task.command.run_handler" class="Task\TaskBundle\Command\RunHandlerCommand" public="true">
<argument type="string">task:run:handler</argument>
<argument type="service" id="task.handler.factory"/>

<tag name="console.command"/>
</service>

<service id="task.command.executor" class="Task\TaskBundle\Command\ExecuteCommand">
<service id="task.command.executor" class="Task\TaskBundle\Command\ExecuteCommand" public="true">
<argument type="string">task:execute</argument>
<argument type="service" id="task.handler.factory"/>
<argument type="service" id="task.storage.task_execution"/>

<tag name="console.command"/>
</service>

<service id="task.command.schedule_task" class="Task\TaskBundle\Command\ScheduleTaskCommand">
<service id="task.command.schedule_task" class="Task\TaskBundle\Command\ScheduleTaskCommand" public="true">
<argument type="string">task:schedule</argument>
<argument type="service" id="task.scheduler"/>
<!-- add entity_manager if doctrine storage is enabled -->

<tag name="console.command"/>
</service>

<service id="task.command.debug_tasks" class="Task\TaskBundle\Command\DebugTasksCommand">
<service id="task.command.debug_tasks" class="Task\TaskBundle\Command\DebugTasksCommand" public="true">
<argument type="string">debug:tasks</argument>
<argument type="service" id="task.storage.task_execution"/>

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/executor/inside.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.executor.inside" class="Task\Executor\InsideProcessExecutor">
<service id="task.executor.inside" class="Task\Executor\InsideProcessExecutor" public="true">
<argument type="service" id="task.handler.factory"/>
</service>
</services>
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/executor/separate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.executor.separate" class="Task\TaskBundle\Executor\SeparateProcessExecutor">
<service id="task.executor.separate" class="Task\TaskBundle\Executor\SeparateProcessExecutor" public="true">
<argument type="service" id="task.handler.factory"/>
<argument type="service" id="task.storage.task_execution"/>
<argument type="service" id="task.executor.separate.process_factory"/>
</service>

<service id="task.executor.separate.process_factory" class="Task\TaskBundle\Executor\ExecutionProcessFactory">
<service id="task.executor.separate.process_factory" class="Task\TaskBundle\Executor\ExecutionProcessFactory" public="true">
<argument type="string">%task.executor.console_path%</argument>
<argument type="string">%task.executor.process_timeout%</argument>
<argument type="string">%kernel.environment%</argument>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/listener.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.event_listener.run" class="Task\TaskBundle\EventListener\RunListener">
<service id="task.event_listener.run" class="Task\TaskBundle\EventListener\RunListener" public="true">
<argument type="service" id="task.runner" />

<tag name="kernel.event_listener" event="kernel.terminate" method="run" />
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/locking/null.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.lock" class="Task\TaskBundle\Locking\NullLock"/>
<service id="task.lock" class="Task\TaskBundle\Locking\NullLock" public="true"/>
</services>
</container>
2 changes: 1 addition & 1 deletion src/Resources/config/locking/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.lock" class="Task\Lock\Lock">
<service id="task.lock" class="Task\Lock\Lock" public="true">
<argument type="service" id="task.lock.storage"/>
<argument>%task.lock.ttl%</argument>
</service>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/locking/storages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.lock.storage.file" class="Task\Lock\Storage\FileLockStorage">
<service id="task.lock.storage.file" class="Task\Lock\Storage\FileLockStorage" public="true">
<argument type="expression">parameter('task.lock.storages.file')['directory']</argument>

<tag name="task.lock.storage" alias="file"/>
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/config/scheduler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.builder_factory" class="Task\TaskBundle\Builder\TaskBuilderFactory"/>
<service id="task.builder_factory" class="Task\TaskBundle\Builder\TaskBuilderFactory" public="true"/>

<service id="task.scheduler" class="Task\Scheduler\TaskScheduler">
<service id="task.scheduler" class="Task\Scheduler\TaskScheduler" public="true">
<argument type="service" id="task.builder_factory"/>
<argument type="service" id="task.storage.task"/>
<argument type="service" id="task.storage.task_execution"/>
<argument type="service" id="event_dispatcher"/>
</service>

<service id="task.handler.factory" class="Task\TaskBundle\Handler\TaskHandlerFactory">
<service id="task.handler.factory" class="Task\TaskBundle\Handler\TaskHandlerFactory" public="true">
<argument type="collection"/>
</service>

<service id="task.runner.execution_finder" class="Task\Runner\PendingExecutionFinder">
<service id="task.runner.execution_finder" class="Task\Runner\PendingExecutionFinder" public="true">
<argument type="service" id="task.storage.task_execution"/>
<argument type="service" id="task.handler.factory"/>
<argument type="service" id="task.lock"/>
<argument type="service" id="logger" on-invalid="ignore"/>
</service>

<service id="task.runner" class="Task\Runner\TaskRunner">
<service id="task.runner" class="Task\Runner\TaskRunner" public="true">
<argument type="service" id="task.storage.task_execution"/>
<argument type="service" id="task.runner.execution_finder"/>
<argument type="service" id="task.executor"/>
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/storage/array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.storage.task" class="Task\Storage\ArrayStorage\ArrayTaskRepository"/>
<service id="task.storage.task_execution" class="Task\Storage\ArrayStorage\ArrayTaskExecutionRepository"/>
<service id="task.storage.task" class="Task\Storage\ArrayStorage\ArrayTaskRepository" public="true"/>
<service id="task.storage.task_execution" class="Task\Storage\ArrayStorage\ArrayTaskExecutionRepository" public="true"/>
</services>
</container>
10 changes: 5 additions & 5 deletions src/Resources/config/storage/doctrine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.repository.task" class="Task\TaskBundle\Entity\TaskRepository">
<service id="task.repository.task" class="Task\TaskBundle\Entity\TaskRepository" public="true">
<factory service="doctrine.orm.entity_manager" method="getRepository"/>

<argument type="string">TaskBundle:Task</argument>
</service>
<service id="task.storage.task" alias="task.repository.task"/>
<service id="task.storage.task" alias="task.repository.task" public="true"/>

<service id="task.repository.task_execution" class="Task\TaskBundle\Entity\TaskExecutionRepository">
<service id="task.repository.task_execution" class="Task\TaskBundle\Entity\TaskExecutionRepository" public="true">
<factory service="doctrine.orm.entity_manager" method="getRepository"/>

<argument type="string">TaskBundle:TaskExecution</argument>
</service>
<service id="task.storage.task_execution" alias="task.repository.task_execution"/>
<service id="task.storage.task_execution" alias="task.repository.task_execution" public="true"/>

<service id="task.command.schedule_system_tasks" class="Task\TaskBundle\Command\ScheduleSystemTasksCommand">
<service id="task.command.schedule_system_tasks" class="Task\TaskBundle\Command\ScheduleSystemTasksCommand" public="true">
<argument type="string">task:schedule:system-tasks</argument>
<argument>%task.system_tasks%</argument>
<argument type="service" id="task.scheduler"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Command/RunCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testExecute()
);

$execution = $this->taskExecutionRepository->findByUuid($executions[0]->getUuid());
$this->assertEquals(TaskStatus::COMPLETED, $execution->getStatus());
$this->assertEquals(TaskStatus::COMPLETED, $execution->getStatus(), $execution->getException());
$this->assertEquals(strrev('Test workload 1'), $execution->getResult());
$this->assertGreaterThan(0, $execution->getDuration());
$this->assertGreaterThanOrEqual($execution->getStartTime(), $execution->getEndTime());
Expand Down
Loading