Skip to content
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

[PHP] Update CI and tests #601

Merged
merged 9 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion .github/workflows/php.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: Download docker artifacts
if: ${{ inputs.docker-image-artifact-name }}
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ inputs.docker-image-artifact-name }}
path: /tmp/server-docker
Expand Down
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
Loading