Skip to content

Commit

Permalink
[PHP] Update CI and tests (#601)
Browse files Browse the repository at this point in the history
* Restore PHP workflows

* Use actions/download-artifact v4

* Enable logging for RR run command

* Fix workflow id in `continue as new` test

* Add debugging on date interval unmarshalling

* Start workflows with WorkflowIdReusePolicy as `AllowDuplicate`
Remove debug

* Update min PHP SDK version

* Increase RPC operations timeouts
  • Loading branch information
roxblnfk authored Feb 21, 2025
1 parent 45350c7 commit 1a033a7
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 4 deletions.
57 changes: 57 additions & 0 deletions features/continue_as_new/continue_as_same/feature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);

namespace Harness\Feature\ContinueAsNew\ContinueAsSame;

use Harness\Attribute\Check;
use Harness\Attribute\Stub;
use Temporal\Client\WorkflowStubInterface;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Webmozart\Assert\Assert;

\define('INPUT_DATA', 'InputData');
\define('MEMO_KEY', 'MemoKey');
\define('MEMO_VALUE', 'MemoValue');
\define('WORKFLOW_ID', 'PHP-ContinueAsNew-ContinueAsSame-TestID');

#[WorkflowInterface]
class FeatureWorkflow
{
#[WorkflowMethod('Workflow')]
public function run(string $input)
{
if (!empty(Workflow::getInfo()->continuedExecutionRunId)) {
return $input;
}

return yield Workflow::continueAsNew(
'Workflow',
args: [$input],
);
}
}

class FeatureChecker
{
#[Check]
public static function check(
#[Stub(
type: 'Workflow',
workflowId: WORKFLOW_ID,
args: [INPUT_DATA],
memo: [MEMO_KEY => MEMO_VALUE],
)]
WorkflowStubInterface $stub
): void {
Assert::same($stub->getResult(), INPUT_DATA);
# Workflow ID was not changed after continue as new
Assert::same($stub->getExecution()->getID(), WORKFLOW_ID);
# Memos do not change after continue as new
$description = $stub->describe();
Assert::same($description->info->memo->getValues(), [MEMO_KEY => MEMO_VALUE]);
}
}

1 change: 0 additions & 1 deletion features/schedule/basic/feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public static function check(
Feature $feature,
State $runtime,
): void {
throw new SkipTest('TODO: https://github.com/temporalio/features/issues/580');
$workflowId = Uuid::uuid4()->toString();
$scheduleId = Uuid::uuid4()->toString();
$interval = CarbonInterval::seconds(2);
Expand Down
2 changes: 1 addition & 1 deletion harness/php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"buggregator/trap": "^1.9",
"spiral/core": "^3.13",
"symfony/process": ">=6.4",
"temporal/sdk": "^2.12.3",
"temporal/sdk": "^2.13.2",
"webmozart/assert": "^1.11"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions harness/php/runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@
serviceClient: $serviceClient,
options: (new ClientOptions())->withNamespace($runtime->namespace),
converter: $converter,
)->withTimeout(5);
)->withTimeout(10);

$scheduleClient = ScheduleClient::create(
serviceClient: $serviceClient,
options: (new ClientOptions())->withNamespace($runtime->namespace),
converter: $converter,
)->withTimeout(5);
)->withTimeout(10);

$container = new Spiral\Core\Container();
$container->bindSingleton(State::class, $runtime);
Expand Down
2 changes: 2 additions & 0 deletions harness/php/src/Feature/WorkflowStubInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Spiral\Core\Container\InjectorInterface;
use Temporal\Client\WorkflowOptions;
use Temporal\Client\WorkflowStubInterface;
use Temporal\Common\IdReusePolicy;

/**
* @implements InjectorInterface<WorkflowStubInterface>
Expand Down Expand Up @@ -51,6 +52,7 @@ public function createInjection(
$feature = $this->container->get(Feature::class);
$options = WorkflowOptions::new()
->withTaskQueue($feature->taskQueue)
->withWorkflowIdReusePolicy(IdReusePolicy::AllowDuplicate)
->withEagerStart($attribute->eagerStart);

$attribute->workflowId === null or $options = $options->withWorkflowId($attribute->workflowId);
Expand Down

0 comments on commit 1a033a7

Please sign in to comment.