1
0
Fork 0
mirror of synced 2024-06-14 08:44:49 +12:00

Merge pull request #4418 from appwrite/feat-deployment-buildtime

Add build time to deployments
This commit is contained in:
Torsten Dittmann 2022-10-26 18:42:53 +02:00 committed by GitHub
commit eb31bfb78e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 0 deletions

View file

@ -832,6 +832,7 @@ App::get('/v1/functions/:functionId/deployments')
$result->setAttribute('status', $build->getAttribute('status', 'processing'));
$result->setAttribute('buildStderr', $build->getAttribute('stderr', ''));
$result->setAttribute('buildStdout', $build->getAttribute('stdout', ''));
$result->setAttribute('buildTime', $build->getAttribute('duration', 0));
}
$response->dynamic(new Document([

View file

@ -181,6 +181,10 @@ class BuildsV1 extends Worker
$build->setAttribute('stderr', $response['stderr']);
$build->setAttribute('stdout', $response['response']);
/* Also update the deployment buildTime */
$deployment->setAttribute('buildTime', $response['duration']);
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
Console::success("Build id: $buildId created");
/** Set auto deploy */

View file

@ -82,6 +82,12 @@ class Deployment extends Model
'default' => '',
'example' => 'enabled',
])
->addRule('buildTime', [
'type' => self::TYPE_INTEGER,
'description' => 'The current build time in seconds.',
'default' => 0,
'example' => 128,
])
;
}

View file

@ -550,6 +550,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertIsArray($function['body']['deployments']);
$this->assertCount(2, $function['body']['deployments']);
$this->assertEquals($function['body']['deployments'][0]['$id'], $data['deploymentId']);
$this->assertGreaterThanOrEqual(2, $function['body']['deployments'][0]['buildTime']);
return $data;
}
@ -568,6 +569,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals(200, $function['headers']['status-code']);
$this->assertEquals(0, $function['body']['buildTime']);
/**
* Test for FAILURE