mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge branch '1.9.x' into fix/vcs-adapter-detection
This commit is contained in:
14 files changed
+193
-43
No files matched your search
@@ -429,7 +429,7 @@ jobs:
|
||||
- name: Wait for Open Runtimes
|
||||
timeout-minutes: 3
|
||||
run: |
|
||||
while ! docker compose logs openruntimes-executor | grep -q "Executor is ready."; do
|
||||
while ! docker logs exc1 | grep -q "Executor is ready."; do
|
||||
echo "Waiting for Executor to come online"
|
||||
sleep 1
|
||||
done
|
||||
@@ -525,7 +525,7 @@ jobs:
|
||||
- name: Wait for Open Runtimes
|
||||
timeout-minutes: 3
|
||||
run: |
|
||||
while ! docker compose logs openruntimes-executor | grep -q "Executor is ready."; do
|
||||
while ! docker logs exc1 | grep -q "Executor is ready."; do
|
||||
echo "Waiting for Executor to come online"
|
||||
sleep 1
|
||||
done
|
||||
@@ -678,7 +678,7 @@ jobs:
|
||||
- name: Wait for Open Runtimes
|
||||
timeout-minutes: 3
|
||||
run: |
|
||||
while ! docker compose logs openruntimes-executor | grep -q "Executor is ready."; do
|
||||
while ! docker logs exc1 | grep -q "Executor is ready."; do
|
||||
echo "Waiting for Executor to come online"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
+41
-16
@@ -699,8 +699,15 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Restore authorization after subscribe
|
||||
if ($authorization !== null) {
|
||||
// meta can be empty as well as the channels are not required query param to connect
|
||||
// channels and queries can be sent via message later on
|
||||
// so if meta is empty we are not subscribing above to the projectId
|
||||
if (!isset($realtime->connections[$connection])) {
|
||||
$realtime->subscribe($projectId, $connection, '', $roles, [], [], $userId);
|
||||
}
|
||||
if ($authorization !== null && isset($realtime->connections[$connection])) {
|
||||
$realtime->connections[$connection]['authorization'] = $authorization;
|
||||
}
|
||||
|
||||
@@ -915,7 +922,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
$channels = Realtime::convertChannels($request->getQuery('channels', []), $user->getId());
|
||||
$channelCount = \count($channels);
|
||||
|
||||
$updateStats = static function (string $projectId, ?string $teamId, string $payloadJson) use ($register, $stats): void {
|
||||
$updateStats = static function (string $projectId, ?string $teamId) use ($register, $stats): void {
|
||||
$register->get('telemetry.connectionCounter')->add(1);
|
||||
$register->get('telemetry.workerClientCounter')->add(1, $register->get('telemetry.workerAttributes'));
|
||||
$register->get('telemetry.connectionCreatedCounter')->add(1);
|
||||
@@ -929,7 +936,6 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
|
||||
triggerStats([
|
||||
METRIC_REALTIME_CONNECTIONS => 1,
|
||||
METRIC_REALTIME_OUTBOUND => \strlen($payloadJson),
|
||||
], $projectId);
|
||||
};
|
||||
|
||||
@@ -950,9 +956,12 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
|
||||
$realtime->subscribe($project->getId(), $connection, '', $roles, [], [], $user->getId());
|
||||
$realtime->connections[$connection]['authorization'] = $authorization;
|
||||
$updateStats($project->getId(), $project->getAttribute('teamId'));
|
||||
$server->send([$connection], $connectedPayloadJson);
|
||||
$outboundBytes += \strlen($connectedPayloadJson);
|
||||
$updateStats($project->getId(), $project->getAttribute('teamId'), $connectedPayloadJson);
|
||||
triggerStats([
|
||||
METRIC_REALTIME_OUTBOUND => \strlen($connectedPayloadJson),
|
||||
], $project->getId());
|
||||
$subscriptionMode = 'message';
|
||||
$success = true;
|
||||
return;
|
||||
@@ -970,6 +979,8 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
throw new Exception(Exception::REALTIME_POLICY_VIOLATION, $e->getMessage());
|
||||
}
|
||||
|
||||
$sanitizedUser = empty($user->getId()) ? null : $response->output($user, Response::MODEL_ACCOUNT);
|
||||
|
||||
$mapping = [];
|
||||
foreach ($subscriptions as $index => $subscription) {
|
||||
$subscriptionId = ID::unique();
|
||||
@@ -986,27 +997,29 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
|
||||
$mapping[$index] = $subscriptionId;
|
||||
}
|
||||
|
||||
$realtime->connections[$connection]['authorization'] = $authorization;
|
||||
$updateStats($project->getId(), $project->getAttribute('teamId'));
|
||||
|
||||
$subscriptionCount = \count($subscriptions);
|
||||
if (!empty($subscriptions)) {
|
||||
$register->get('telemetry.workerSubscriptionCounter')->add(\count($subscriptions), $register->get('telemetry.workerAttributes'));
|
||||
}
|
||||
|
||||
$realtime->connections[$connection]['authorization'] = $authorization;
|
||||
|
||||
$user = empty($user->getId()) ? null : $response->output($user, Response::MODEL_ACCOUNT);
|
||||
|
||||
$connectedPayloadJson = json_encode([
|
||||
'type' => 'connected',
|
||||
'data' => [
|
||||
'channels' => $names,
|
||||
'subscriptions' => $mapping,
|
||||
'user' => $user
|
||||
'user' => $sanitizedUser
|
||||
]
|
||||
]);
|
||||
|
||||
$server->send([$connection], $connectedPayloadJson);
|
||||
$outboundBytes += \strlen($connectedPayloadJson);
|
||||
$updateStats($project->getId(), $project->getAttribute('teamId'), $connectedPayloadJson);
|
||||
triggerStats([
|
||||
METRIC_REALTIME_OUTBOUND => \strlen($connectedPayloadJson),
|
||||
], $project->getId());
|
||||
$success = true;
|
||||
|
||||
} catch (Throwable $th) {
|
||||
@@ -1209,7 +1222,10 @@ $server->onMessage(function (int $connection, string $message) use ($container,
|
||||
$outboundBytes += $bytes;
|
||||
|
||||
if ($project !== null && !$project->isEmpty()) {
|
||||
triggerStats([METRIC_REALTIME_OUTBOUND => $bytes], $project->getId());
|
||||
triggerStats([
|
||||
METRIC_REALTIME_OUTBOUND => $bytes,
|
||||
METRIC_REALTIME_CONNECTIONS_MESSAGES_SENT => 1,
|
||||
], $project->getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1281,20 +1297,27 @@ $server->onClose(function (int $connection) use ($realtime, $stats, $register, $
|
||||
|
||||
try {
|
||||
if (array_key_exists($connection, $realtime->connections)) {
|
||||
$stats->decr($realtime->connections[$connection]['projectId'], 'connectionsTotal');
|
||||
// These decrements are symmetric with the increments in updateStats (onOpen),
|
||||
// which run when the connection enters $realtime->connections — the same gate as the
|
||||
// array_key_exists check above. The connectionsTotal stat is keyed by project, so it's
|
||||
// additionally guarded: a connection can exist without a stored projectId (e.g. only an
|
||||
// authorization entry left after an orphaning re-subscribe).
|
||||
$register->get('telemetry.connectionCounter')->add(-1);
|
||||
$register->get('telemetry.workerClientCounter')->add(-1, $register->get('telemetry.workerAttributes'));
|
||||
if (!empty($projectId)) {
|
||||
$stats->decr($projectId, 'connectionsTotal');
|
||||
}
|
||||
$subscriptionsBeforeClose = \count($realtime->getSubscriptionMetadata($connection));
|
||||
if ($subscriptionsBeforeClose > 0) {
|
||||
$register->get('telemetry.workerSubscriptionCounter')->add(-$subscriptionsBeforeClose, $register->get('telemetry.workerAttributes'));
|
||||
}
|
||||
|
||||
$projectId = $realtime->connections[$connection]['projectId'];
|
||||
/** @var array<string, Document> $presencesById */
|
||||
$presencesById = $realtime->connections[$connection]['presences'] ?? [];
|
||||
|
||||
if (
|
||||
!empty($presencesById)
|
||||
&& !empty($projectId)
|
||||
&& $projectId !== 'console'
|
||||
) {
|
||||
go(function () use ($presencesById, $projectId, $userId, $container, $presenceState): void {
|
||||
@@ -1385,9 +1408,11 @@ $server->onClose(function (int $connection) use ($realtime, $stats, $register, $
|
||||
});
|
||||
}
|
||||
|
||||
triggerStats([
|
||||
METRIC_REALTIME_CONNECTIONS => -1,
|
||||
], $projectId);
|
||||
if (!empty($projectId)) {
|
||||
triggerStats([
|
||||
METRIC_REALTIME_CONNECTIONS => -1,
|
||||
], $projectId);
|
||||
}
|
||||
}
|
||||
$success = true;
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
@@ -983,12 +983,12 @@ $hostPath = rtrim($this->getParam('hostPath', ''), '/');
|
||||
- appwrite
|
||||
|
||||
openruntimes-executor:
|
||||
container_name: openruntimes-executor
|
||||
container_name: exc1
|
||||
hostname: exc1
|
||||
<<: *x-logging
|
||||
restart: unless-stopped
|
||||
stop_signal: SIGINT
|
||||
image: openruntimes/executor:0.11.4
|
||||
image: openruntimes/executor:0.24.1
|
||||
networks:
|
||||
- appwrite
|
||||
- runtimes
|
||||
@@ -1001,6 +1001,8 @@ $hostPath = rtrim($this->getParam('hostPath', ''), '/');
|
||||
# It's not possible to share mount file between 2 containers without host mount (copying is too slow)
|
||||
- /tmp:/tmp:rw
|
||||
environment:
|
||||
- OPR_EXECUTOR_CONNECTION_STORAGE=local://localhost
|
||||
- OPR_EXECUTOR_CONNECTION_BUILD_CACHE_STORAGE=
|
||||
- OPR_EXECUTOR_INACTIVE_TRESHOLD=$_APP_COMPUTE_INACTIVE_THRESHOLD
|
||||
- OPR_EXECUTOR_MAINTENANCE_INTERVAL=$_APP_COMPUTE_MAINTENANCE_INTERVAL
|
||||
- OPR_EXECUTOR_NETWORK=$_APP_COMPUTE_RUNTIMES_NETWORK
|
||||
@@ -1209,3 +1211,4 @@ volumes:
|
||||
appwrite-sites:
|
||||
appwrite-builds:
|
||||
appwrite-config:
|
||||
openruntimes-node-modules-cache:
|
||||
Generated
+6
-6
@@ -3682,16 +3682,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "5.9.0",
|
||||
"version": "5.9.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "477bae83e27631f78c159f45b0441c0c7dc69050"
|
||||
"reference": "698952455dd645ff41057621c90a4cea977fb1bf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/477bae83e27631f78c159f45b0441c0c7dc69050",
|
||||
"reference": "477bae83e27631f78c159f45b0441c0c7dc69050",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/698952455dd645ff41057621c90a4cea977fb1bf",
|
||||
"reference": "698952455dd645ff41057621c90a4cea977fb1bf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3736,9 +3736,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/5.9.0"
|
||||
"source": "https://github.com/utopia-php/database/tree/5.9.2"
|
||||
},
|
||||
"time": "2026-05-17T15:57:21+00:00"
|
||||
"time": "2026-06-12T08:33:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
|
||||
+5
-2
@@ -1245,11 +1245,11 @@ services:
|
||||
- appwrite
|
||||
|
||||
openruntimes-executor:
|
||||
container_name: openruntimes-executor
|
||||
container_name: exc1
|
||||
hostname: exc1
|
||||
<<: *x-logging
|
||||
stop_signal: SIGINT
|
||||
image: openruntimes/executor:0.11.4
|
||||
image: openruntimes/executor:0.24.1
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- appwrite
|
||||
@@ -1263,6 +1263,8 @@ services:
|
||||
# It's not possible to share mount file between 2 containers without host mount (copying is too slow)
|
||||
- /tmp:/tmp:rw
|
||||
environment:
|
||||
- OPR_EXECUTOR_CONNECTION_STORAGE=local://localhost
|
||||
- OPR_EXECUTOR_CONNECTION_BUILD_CACHE_STORAGE=
|
||||
- OPR_EXECUTOR_IMAGE_PULL=enabled
|
||||
- OPR_EXECUTOR_INACTIVE_TRESHOLD=$_APP_COMPUTE_INACTIVE_THRESHOLD
|
||||
- OPR_EXECUTOR_MAINTENANCE_INTERVAL=$_APP_COMPUTE_MAINTENANCE_INTERVAL
|
||||
@@ -1525,3 +1527,4 @@ volumes:
|
||||
appwrite-builds:
|
||||
appwrite-config:
|
||||
appwrite-models:
|
||||
openruntimes-node-modules-cache:
|
||||
@@ -103,6 +103,15 @@ class Create extends Action
|
||||
// Map aggregate permissions into the multiple permissions they represent.
|
||||
$permissions = Permission::aggregate($permissions) ?? [];
|
||||
|
||||
// Resolve the data-plane database BEFORE writing the metadata row. For a
|
||||
// dedicated product database this throws while provisioning (no DSN yet);
|
||||
// writing the row first would leave an orphaned collection with no backing
|
||||
// collection, which lists fine but fails every document operation.
|
||||
/**
|
||||
* @var Database $dbForDatabases
|
||||
*/
|
||||
$dbForDatabases = $getDatabasesDB($database);
|
||||
|
||||
try {
|
||||
$collection = $dbForProject->createDocument('database_' . $database->getSequence(), new Document([
|
||||
'$id' => $collectionId,
|
||||
@@ -122,11 +131,6 @@ class Create extends Action
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Database $dbForDatabases
|
||||
*/
|
||||
$dbForDatabases = $getDatabasesDB($database);
|
||||
|
||||
$collectionKey = 'database_' . $database->getSequence() . '_collection_' . $collection->getSequence();
|
||||
$databaseKey = 'database_' . $database->getSequence();
|
||||
|
||||
|
||||
@@ -94,6 +94,13 @@ class Create extends CollectionAction
|
||||
// Map aggregate permissions into the multiple permissions they represent.
|
||||
$permissions = Permission::aggregate($permissions) ?? [];
|
||||
|
||||
// Resolve the data-plane database BEFORE writing the metadata row. For a
|
||||
// dedicated product database this throws while provisioning (no DSN yet);
|
||||
// writing the row first would leave an orphaned collection with no backing
|
||||
// collection, which lists fine but fails every document operation.
|
||||
/** @var Database $dbForDatabases */
|
||||
$dbForDatabases = $getDatabasesDB($database);
|
||||
|
||||
try {
|
||||
$collection = $dbForProject->createDocument('database_' . $database->getSequence(), new Document([
|
||||
'$id' => $collectionId,
|
||||
@@ -114,8 +121,6 @@ class Create extends CollectionAction
|
||||
} catch (NotFoundException) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND);
|
||||
}
|
||||
/** @var Database $dbForDatabases */
|
||||
$dbForDatabases = $getDatabasesDB($database);
|
||||
|
||||
$attributes = [];
|
||||
$indexes = [];
|
||||
|
||||
@@ -182,6 +182,17 @@ class Update extends Base
|
||||
|
||||
$isConnected = !empty($function->getAttribute('providerRepositoryId', ''));
|
||||
|
||||
// Omitted providerRepositoryId (null) on a connected function — preserve existing VCS values
|
||||
if ($isConnected && $providerRepositoryId === null) {
|
||||
$providerRepositoryId = $function->getAttribute('providerRepositoryId', '');
|
||||
$installationId = $function->getAttribute('installationId', '');
|
||||
$providerBranch = $providerBranch ?: $function->getAttribute('providerBranch', '');
|
||||
$providerRootDirectory = $providerRootDirectory ?: $function->getAttribute('providerRootDirectory', '');
|
||||
$repositoryId = $function->getAttribute('repositoryId', '');
|
||||
$repositoryInternalId = $function->getAttribute('repositoryInternalId', '');
|
||||
$installation = $dbForPlatform->getDocument('installations', $installationId);
|
||||
}
|
||||
|
||||
// Git disconnect logic. Disconnecting only when providerRepositoryId is empty, allowing for continue updates without disconnecting git
|
||||
if ($isConnected && ($providerRepositoryId !== null && empty($providerRepositoryId))) {
|
||||
$repositories = $dbForPlatform->find('repositories', [
|
||||
|
||||
@@ -686,6 +686,11 @@ class Builds extends Action
|
||||
deployment: $deployment
|
||||
);
|
||||
|
||||
$cacheKey = $this->getNodeModulesCacheKey($project, $resource, $runtime, $version, $command);
|
||||
|
||||
Span::add('build.node_modules_cache.enabled', $cacheKey !== '');
|
||||
Span::add('build.node_modules_cache.key', $cacheKey);
|
||||
|
||||
$response = null;
|
||||
$err = null;
|
||||
|
||||
@@ -699,7 +704,7 @@ class Builds extends Action
|
||||
$span = Span::current();
|
||||
|
||||
Co::join([
|
||||
Co\go(function () use ($executor, &$response, $project, $deployment, $source, $resource, $runtime, $vars, $command, $cpus, $memory, $timeout, &$err, $version, $span) {
|
||||
Co\go(function () use ($executor, &$response, $project, $deployment, $source, $resource, $runtime, $vars, $command, $cacheKey, $cpus, $memory, $timeout, &$err, $version, $span) {
|
||||
try {
|
||||
if ($version === 'v2') {
|
||||
$command = 'tar -zxf /tmp/code.tar.gz -C /usr/code && cd /usr/local/src/ && ./build.sh';
|
||||
@@ -726,7 +731,8 @@ class Builds extends Action
|
||||
destination: APP_STORAGE_BUILDS . "/app-{$project->getId()}",
|
||||
variables: $vars,
|
||||
command: $command,
|
||||
outputDirectory: $outputDirectory ?? ''
|
||||
outputDirectory: $outputDirectory ?? '',
|
||||
cacheKey: $cacheKey
|
||||
);
|
||||
|
||||
} catch (ExecutorTimeout $error) {
|
||||
@@ -1315,6 +1321,23 @@ class Builds extends Action
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function getNodeModulesCacheKey(Document $project, Document $resource, array $runtime, string $version, string $command): string
|
||||
{
|
||||
if ($version !== 'v5' || $command === '' || $command === '0') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$hashContext = [
|
||||
'version' => 'v1',
|
||||
'projectId' => $project->getId(),
|
||||
'resourceType' => $resource->getCollection(),
|
||||
'resourceId' => $resource->getId(),
|
||||
'runtime' => $runtime['image'] ?? '',
|
||||
];
|
||||
|
||||
return \substr(\hash('sha256', \json_encode($hashContext, JSON_THROW_ON_ERROR)), 0, 48);
|
||||
}
|
||||
|
||||
protected function prepareSiteBuildCommand(string $command, string $outputDirectory): string
|
||||
{
|
||||
$listFilesCommand = 'echo "{APPWRITE_DETECTION_SEPARATOR_START}" && cd /usr/local/build';
|
||||
|
||||
@@ -182,6 +182,17 @@ class Update extends Base
|
||||
|
||||
$isConnected = !empty($site->getAttribute('providerRepositoryId', ''));
|
||||
|
||||
// Omitted providerRepositoryId (null) on a connected site — preserve existing VCS values
|
||||
if ($isConnected && $providerRepositoryId === null) {
|
||||
$providerRepositoryId = $site->getAttribute('providerRepositoryId', '');
|
||||
$installationId = $site->getAttribute('installationId', '');
|
||||
$providerBranch = $providerBranch ?: $site->getAttribute('providerBranch', '');
|
||||
$providerRootDirectory = $providerRootDirectory ?: $site->getAttribute('providerRootDirectory', '');
|
||||
$repositoryId = $site->getAttribute('repositoryId', '');
|
||||
$repositoryInternalId = $site->getAttribute('repositoryInternalId', '');
|
||||
$installation = $dbForPlatform->getDocument('installations', $installationId);
|
||||
}
|
||||
|
||||
// Git disconnect logic. Disconnecting only when providerRepositoryId is empty, allowing for continue updates without disconnecting git
|
||||
if ($isConnected && ($providerRepositoryId !== null && empty($providerRepositoryId))) {
|
||||
$repositories = $dbForPlatform->find('repositories', [
|
||||
|
||||
@@ -71,7 +71,8 @@ class Executor
|
||||
array $variables = [],
|
||||
?string $command = null,
|
||||
string $outputDirectory = '',
|
||||
string $runtimeEntrypoint = ''
|
||||
string $runtimeEntrypoint = '',
|
||||
string $cacheKey = ''
|
||||
) {
|
||||
$runtimeId = "$projectId-$deploymentId-build";
|
||||
$route = "/runtimes";
|
||||
@@ -95,7 +96,8 @@ class Executor
|
||||
'version' => $version,
|
||||
'timeout' => $timeout,
|
||||
'outputDirectory' => $outputDirectory,
|
||||
'runtimeEntrypoint' => $runtimeEntrypoint
|
||||
'runtimeEntrypoint' => $runtimeEntrypoint,
|
||||
'cacheKey' => $cacheKey
|
||||
];
|
||||
|
||||
|
||||
|
||||
@@ -3311,4 +3311,5 @@ final class FunctionsCustomServerTest extends Scope
|
||||
$this->cleanupFunction($functionId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,11 +72,11 @@ trait SitesBase
|
||||
throw new Critical('Deployment failed: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
Console::execute("docker inspect openruntimes-executor --format='{{.State.ExitCode}}'", '', $this->stdout, $this->stderr);
|
||||
if (\trim($this->stdout) !== '0') {
|
||||
$code = Console::execute("docker inspect exc1 --format='{{.State.ExitCode}}'", '', $this->stdout, $this->stderr);
|
||||
if ($code === 0 && \trim($this->stdout) !== '' && \trim($this->stdout) !== '0') {
|
||||
$msg = 'Executor has a problem: ' . $this->stderr . ' (' . $this->stdout . '), current status: ';
|
||||
|
||||
Console::execute("docker compose logs openruntimes-executor", '', $this->stdout, $this->stderr);
|
||||
Console::execute("docker logs exc1", '', $this->stdout, $this->stderr);
|
||||
$msg .= $this->stdout . ' (' . $this->stderr . ')';
|
||||
|
||||
throw new Critical($msg . json_encode($deployment['body'], JSON_PRETTY_PRINT));
|
||||
|
||||
@@ -672,6 +672,68 @@ final class VCSConsoleClientTest extends Scope
|
||||
$this->assertEquals('main', $function['body']['providerBranch']);
|
||||
}
|
||||
|
||||
public function testUpdateFunctionOmitProviderRepositoryIdPreservesVcs(): void
|
||||
{
|
||||
$data = $this->setupFunctionUsingVCS();
|
||||
|
||||
// Omit providerRepositoryId entirely — should preserve VCS connection, not clear it
|
||||
$function = $this->client->call(Client::METHOD_PUT, '/functions/' . $data['functionId'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'name' => 'Test',
|
||||
'runtime' => 'php-8.0',
|
||||
'entrypoint' => 'index.php',
|
||||
'timeout' => 10,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $function['headers']['status-code']);
|
||||
$this->assertNotEmpty($function['body']['providerRepositoryId']);
|
||||
$this->assertNotEmpty($function['body']['installationId']);
|
||||
$this->assertNotEmpty($function['body']['providerBranch']);
|
||||
}
|
||||
|
||||
public function testUpdateSiteOmitProviderRepositoryIdPreservesVcs(): void
|
||||
{
|
||||
$installationId = $this->setupInstallation();
|
||||
|
||||
$site = $this->client->call(Client::METHOD_POST, '/sites', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'siteId' => ID::unique(),
|
||||
'name' => 'Test Site VCS',
|
||||
'framework' => 'other',
|
||||
'buildRuntime' => 'node-22',
|
||||
'installationId' => $installationId,
|
||||
'providerRepositoryId' => $this->providerRepositoryId3,
|
||||
'providerBranch' => 'main',
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $site['headers']['status-code']);
|
||||
$siteId = $site['body']['$id'];
|
||||
|
||||
// Omit providerRepositoryId — should preserve VCS connection, not clear it
|
||||
$updated = $this->client->call(Client::METHOD_PUT, '/sites/' . $siteId, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'name' => 'Test Site VCS',
|
||||
'framework' => 'other',
|
||||
'buildRuntime' => 'node-22',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $updated['headers']['status-code']);
|
||||
$this->assertNotEmpty($updated['body']['providerRepositoryId']);
|
||||
$this->assertNotEmpty($updated['body']['installationId']);
|
||||
$this->assertNotEmpty($updated['body']['providerBranch']);
|
||||
|
||||
$this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
}
|
||||
|
||||
public function testCreateRepository(): void
|
||||
{
|
||||
$installationId = $this->setupInstallation();
|
||||
|
||||
Reference in new issue
Block a user