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

Add build instrumentation API #2612

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
11 changes: 11 additions & 0 deletions app/Enums/BuildCommandType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Enums;

enum BuildCommandType: string
{
case COMPILE = 'COMPILE';
case LINK = 'LINK';
case CUSTOM = 'CUSTOM';
case CMAKE_BUILD = 'CMAKE_BUILD';
}
8 changes: 0 additions & 8 deletions app/Enums/BuildMeasurementType.php

This file was deleted.

19 changes: 19 additions & 0 deletions app/Enums/TargetType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Enums;

/**
* See: https://cmake.org/cmake/help/latest/prop_tgt/TYPE.html
*
* We also include an "UNKNOWN" value in case CMake adds a new type before CDash does.
*/
enum TargetType: string
{
case UNKNOWN = 'UNKNOWN';
case STATIC_LIBRARY = 'STATIC_LIBRARY';
case MODULE_LIBRARY = 'MODULE_LIBRARY';
case SHARED_LIBRARY = 'SHARED_LIBRARY';
case OBJECT_LIBRARY = 'OBJECT_LIBRARY';
case INTERFACE_LIBRARY = 'INTERFACE_LIBRARY';
case EXECUTABLE = 'EXECUTABLE';
}
24 changes: 16 additions & 8 deletions app/Models/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,6 @@ public function buildGroups(): BelongsToMany
return $this->belongsToMany(BuildGroup::class, 'build2group', 'groupid', 'buildid');
}

/**
* @return HasMany<BuildMeasurement>
*/
public function measurements(): HasMany
{
return $this->hasMany(BuildMeasurement::class, 'buildid');
}

/**
* @return HasMany<Coverage>
*/
Expand All @@ -237,4 +229,20 @@ public function labels(): BelongsToMany
{
return $this->belongsToMany(Label::class, 'label2build', 'buildid', 'labelid');
}

/**
* @return HasMany<BuildCommand>
*/
public function commands(): HasMany
{
return $this->hasMany(BuildCommand::class, 'buildid');
}

/**
* @return HasMany<Target>
*/
public function targets(): HasMany
{
return $this->hasMany(Target::class, 'buildid');
}
}
80 changes: 80 additions & 0 deletions app/Models/BuildCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace App\Models;

use App\Enums\BuildCommandType;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* @property int $id
* @property int $buildid
* @property int $targetid
* @property BuildCommandType $type
* @property Carbon $starttime
* @property int $duration Command running time in ms.
* @property string $command
* @property string $result
* @property string $source
* @property string $language
* @property string $config
*
* @mixin Builder<BuildCommand>
*/
class BuildCommand extends Model
{
protected $table = 'buildcommands';

public $timestamps = false;

protected $fillable = [
'type',
'starttime',
'duration',
'command',
'result',
'source',
'language',
'config',
];

protected $casts = [
'id' => 'integer',
'buildid' => 'integer',
'targetid' => 'integer',
'type' => BuildCommandType::class,
'starttime' => 'datetime',
'duration' => 'integer',
];

/**
* @return BelongsTo<Build, self>
*/
public function build(): BelongsTo
{
return $this->belongsTo(Build::class, 'buildid');
}

/**
* @return HasMany<BuildMeasurement>
*/
public function measurements(): HasMany
{
return $this->hasMany(BuildMeasurement::class, 'buildcommandid');
}

/**
* Some types of commands are associated with a target.
*
* https://cmake.org/cmake/help/git-master/manual/cmake-instrumentation.7.html#v1-snippet-file
*
* @return BelongsTo<Target, self>
*/
public function target(): BelongsTo
{
return $this->belongsTo(Target::class, 'targetid');
}
}
19 changes: 3 additions & 16 deletions app/Models/BuildMeasurement.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

namespace App\Models;

use App\Enums\BuildMeasurementType;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;

/**
* @property int $id
* @property int $buildid
* @property int $buildcommandid
* @property string $name
* @property string $source
* @property BuildMeasurementType $type
* @property string $type
* @property string $value
*
* @mixin Builder<BuildMeasurement>
Expand All @@ -25,22 +22,12 @@ class BuildMeasurement extends Model

protected $fillable = [
'name',
'source',
'type',
'value',
];

protected $casts = [
'id' => 'integer',
'buildid' => 'integer',
'type' => BuildMeasurementType::class,
'buildcommandid' => 'integer',
];

/**
* @return HasOne<Build>
*/
public function build(): HasOne
{
return $this->hasOne(Build::class, 'id', 'buildid');
}
}
60 changes: 60 additions & 0 deletions app/Models/Target.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace App\Models;

use App\Enums\TargetType;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* @property int $id
* @property int $buildid
* @property string $name
* @property TargetType $type
*
* @mixin Builder<Target>
*/
class Target extends Model
{
protected $table = 'targets';

public $timestamps = false;

protected $fillable = [
'name',
'type',
];

protected $casts = [
'id' => 'integer',
'buildid' => 'integer',
'type' => TargetType::class,
];

/**
* @return BelongsTo<Build, self>
*/
public function build(): BelongsTo
{
return $this->belongsTo(Build::class, 'buildid');
}

/**
* @return BelongsToMany<Label>
*/
public function labels(): BelongsToMany
{
return $this->belongsToMany(Label::class, 'label2target', 'targetid', 'labelid');
}

/**
* @return HasMany<BuildCommand>
*/
public function commands(): HasMany
{
return $this->hasMany(BuildCommand::class, 'targetid');
}
}
10 changes: 4 additions & 6 deletions app/Providers/GraphQLServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

namespace App\Providers;

use App\Enums\BuildMeasurementType;
use GraphQL\Error\InvariantViolation;
use App\Enums\BuildCommandType;
use App\Enums\TargetType;
use GraphQL\Type\Definition\PhpEnumType;
use Illuminate\Support\ServiceProvider;
use Nuwave\Lighthouse\Schema\TypeRegistry;

final class GraphQLServiceProvider extends ServiceProvider
{
/**
* @throws InvariantViolation
*/
public function boot(TypeRegistry $typeRegistry): void
{
$typeRegistry->register(new PhpEnumType(BuildMeasurementType::class));
$typeRegistry->register(new PhpEnumType(TargetType::class));
$typeRegistry->register(new PhpEnumType(BuildCommandType::class));
}
}
16 changes: 12 additions & 4 deletions app/cdash/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,18 @@ set_tests_properties(/Feature/GraphQL/TestMeasurementTypeTest PROPERTIES DEPENDS
add_laravel_test(/Feature/GraphQL/NoteTypeTest)
set_tests_properties(/Feature/GraphQL/NoteTypeTest PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler)

add_laravel_test(/Feature/GraphQL/BuildMeasurementTypeTest)
set_tests_properties(/Feature/GraphQL/BuildMeasurementTypeTest PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler)

add_laravel_test(/Feature/GraphQL/CoverageTypeTest)
set_tests_properties(/Feature/GraphQL/CoverageTypeTest PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler)

add_laravel_test(/Feature/GraphQL/LabelTypeTest)
set_tests_properties(/Feature/GraphQL/LabelTypeTest PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler)

add_laravel_test(/Feature/GraphQL/TargetTypeTest)
set_tests_properties(/Feature/GraphQL/TargetTypeTest PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler)

add_laravel_test(/Feature/GraphQL/BuildCommandTypeTest)
set_tests_properties(/Feature/GraphQL/BuildCommandTypeTest PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler)

add_laravel_test(/Feature/RouteAccessTest)
set_tests_properties(/Feature/RouteAccessTest PROPERTIES DEPENDS /CDash/XmlHandler/UpdateHandler)

Expand Down Expand Up @@ -293,8 +299,10 @@ set_property(TEST install_3 PROPERTY DEPENDS
/Feature/GraphQL/TestTypeTest
/Feature/GraphQL/TestMeasurementTypeTest
/Feature/GraphQL/NoteTypeTest
/Feature/GraphQL/BuildMeasurementTypeTest
/Feature/GraphQL/CoverageTypeTest
/Feature/GraphQL/LabelTypeTest
/Feature/GraphQL/TargetTypeTest
/Feature/GraphQL/BuildCommandTypeTest
/Feature/RouteAccessTest
/Feature/Monitor
/Feature/PasswordRotation
Expand Down
Loading