Skip to content

Commit

Permalink
Add more fields to GraphQL Build type
Browse files Browse the repository at this point in the history
  • Loading branch information
williamjallen committed Mar 22, 2024
1 parent 14ac22b commit d2deb87
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/cdash/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ set_tests_properties(/Feature/GraphQL/ProjectTypeTest PROPERTIES DEPENDS /CDash/
add_laravel_test(/Feature/GraphQL/SiteTypeTest)
set_tests_properties(/Feature/GraphQL/SiteTypeTest PROPERTIES DEPENDS /Feature/GraphQL/ProjectTypeTest)

add_laravel_test(/Feature/GraphQL/BuildTypeTest)
set_tests_properties(/Feature/GraphQL/BuildTypeTest PROPERTIES DEPENDS /Feature/GraphQL/SiteTypeTest)

add_laravel_test(/Feature/PurgeUnusedProjectsCommand)
set_tests_properties(/Feature/PurgeUnusedProjectsCommand PROPERTIES DEPENDS /Feature/GraphQL/SiteTypeTest)
set_tests_properties(/Feature/PurgeUnusedProjectsCommand PROPERTIES DEPENDS /Feature/GraphQL/BuildTypeTest)

add_laravel_test(/Feature/TestSchemaMigration)
set_tests_properties(/Feature/TestSchemaMigration PROPERTIES DEPENDS /Feature/PurgeUnusedProjectsCommand)
Expand Down
60 changes: 58 additions & 2 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,66 @@ type Build {
name: String!

"Start time."
starttime: DateTime!
startTime: DateTime! @rename(attribute: "starttime")

"End time."
endtime: DateTime!
endTime: DateTime! @rename(attribute: "endtime")

"Submission time."
submissionTime: DateTime! @rename(attribute: "submittime")

"Stamp. Example: 20091218-1414-Experimental"
stamp: String!

# TODO: Create a designated UUID GraphQL type
"UUID."
uuid: String!

# TODO: Determine if there are more specific values we can use for this
"Type."
buildType: String! @rename(attribute: "type")

"Generator. Example: ctest-2.9.20091218"
generator: String!

"Command."
command: String!

"Log."
log: String!

"The number of errors generated during the configuration step."
configureErrorsCount: Int @rename(attribute: "configureerrors")

"The number of warnings generated during the configuration step."
configureWarningsCount: Int @rename(attribute: "configurewarnings")

"The duration of the configure step in seconds."
configureDuration: Int! @rename(attribute: "configureduration")

"The number of errors generated during the build step."
buildErrorsCount: Int @rename(attribute: "builderrors")

"The number of warnings generated during the build step."
buildWarningsCount: Int @rename(attribute: "buildwarnings")

"The duration of the build step in seconds."
buildDuration: Int! @rename(attribute: "buildduration")

"The number of failed tests."
failedTestsCount: Int @rename(attribute: "testfailed")

"The number of tests which failed the time status."
timeStatusFailedTestsCount: Int @rename(attribute: "testtimestatusfailed")

"The number of passed tests."
passedTestsCount: Int @rename(attribute: "testpassed")

"The number of tests not run for this build."
notRunTestsCount: Int @rename(attribute: "testnotrun")

"The duration of the test step in seconds."
testDuration: Int! @rename(attribute: "testduration")

"The site associated with this build."
site: Site! @belongsTo
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -29477,7 +29477,7 @@ parameters:
-
message: "#^Dynamic call to static method Illuminate\\\\Testing\\\\TestResponse\\:\\:assertGraphQLErrorMessage\\(\\)\\.$#"
count: 3
path: tests/Feature/GraphQL/ProjectTest.php
path: tests/Feature/GraphQL/ProjectTypeTest.php

-
message: "#^Call to an undefined method Mockery\\\\Expectation\\:\\:shouldReceive\\(\\)\\.$#"
Expand Down
125 changes: 125 additions & 0 deletions tests/Feature/GraphQL/BuildTypeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php

namespace Tests\Feature\GraphQL;

use App\Models\Project;
use Illuminate\Support\Str;
use Tests\TestCase;
use Tests\Traits\CreatesProjects;
use Tests\Traits\CreatesUsers;

class BuildTypeTest extends TestCase
{
use CreatesUsers;
use CreatesProjects;

private Project $project;

protected function setUp(): void
{
parent::setUp();

$this->project = Project::findOrFail((int) $this->makePublicProject()->Id);
}

protected function tearDown(): void
{
// Deleting the project will delete all corresponding builds
$this->project->delete();

parent::tearDown();
}

/**
* A basic test to ensure that each of the fields works
*/
public function testBasicFieldAccess(): void
{
$uuid = Str::uuid()->toString();
$this->project->builds()->create([
'stamp' => 'abcdefg',
'name' => 'build1',
'type' => 'Continuous',
'generator' => 'ctest-2.9.20091218',
'starttime' => '2011-07-22 15:11:41',
'endtime' => '2011-07-22 15:29:30',
'submittime' => '2024-03-21 20:30:51',
'command' => 'foo bar',
'log' => 'abc',
'configureerrors' => 1,
'configurewarnings' => 2,
'configureduration' => 10,
'builderrors' => 3,
'buildwarnings' => 4,
'buildduration' => 20,
'testnotrun' => 5,
'testfailed' => 6,
'testpassed' => 7,
'testtimestatusfailed' => 8,
'testduration' => 30,
'uuid' => $uuid,
]);

$this->graphQL('
query project($id: ID) {
project(id: $id) {
builds {
stamp
name
buildType
generator
startTime
endTime
submissionTime
command
log
configureErrorsCount
configureWarningsCount
configureDuration
buildErrorsCount
buildWarningsCount
buildDuration
notRunTestsCount
failedTestsCount
passedTestsCount
timeStatusFailedTestsCount
testDuration
uuid
}
}
}
', [
'id' => $this->project->id,
])->assertJson([
'data' => [
'project' => [
'builds' => [
[
'stamp' => 'abcdefg',
'name' => 'build1',
'buildType' => 'Continuous',
'generator' => 'ctest-2.9.20091218',
'startTime' => '2011-07-22 15:11:41',
'endTime' => '2011-07-22 15:29:30',
'submissionTime' => '2024-03-21 20:30:51',
'command' => 'foo bar',
'log' => 'abc',
'configureErrorsCount' => 1,
'configureWarningsCount' => 2,
'configureDuration' => 10,
'buildErrorsCount' => 3,
'buildWarningsCount' => 4,
'buildDuration' => 20,
'notRunTestsCount' => 5,
'failedTestsCount' => 6,
'passedTestsCount' => 7,
'timeStatusFailedTestsCount' => 8,
'testDuration' => 30,
'uuid' => $uuid,
],
],
],
],
], true);
}
}

0 comments on commit d2deb87

Please sign in to comment.