Skip to content
Merged
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
64 changes: 64 additions & 0 deletions app/GraphQL/Scalars/Time.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace App\GraphQL\Scalars;

use Carbon\Exceptions\InvalidFormatException;
use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\ValueNode;
use GraphQL\Type\Definition\ScalarType;
use Illuminate\Support\Carbon;

final class Time extends ScalarType
{
public function serialize(mixed $value): string
{
return $value;
}

/**
* @throws InvariantViolation
*/
public function parseValue(mixed $value): string
{
if (!$this->validateTime($value)) {
throw new InvariantViolation("The value $value is not a valid Time format (H:i:s).");
}

return $value;
}

/**
* @param ValueNode&Node $valueNode
* @param array<string, mixed>|null $variables
*
* @throws InvariantViolation
*/
public function parseLiteral(Node $valueNode, ?array $variables = null): string
{
if (!property_exists($valueNode, 'value')) {
throw new InvariantViolation('Time must be a string.');
}

if (!$this->validateTime($valueNode->value)) {
throw new InvariantViolation("The value {$valueNode->value} is not a valid Time.");
}

return $valueNode->value;
}

private function validateTime(string $time): bool
{
// Simple regex for HH:MM:SS* format to make sure it's actually a time, not a datetime.
if (preg_match('/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/', $time) !== 1) {
return false;
}

try {
Carbon::parse($time);
return true;
} catch (InvalidFormatException) {
return false;
}
}
}
18 changes: 9 additions & 9 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
/**
* @property int $id
* @property string $name
* @property string $description
* @property string $homeurl
* @property string $cvsurl
* @property string $bugtrackerurl
* @property string $bugtrackernewissueurl
* @property string $bugtrackertype
* @property string $documentationurl
* @property ?string $description
* @property ?string $homeurl
* @property ?string $cvsurl
* @property ?string $bugtrackerurl
* @property ?string $bugtrackernewissueurl
* @property ?string $bugtrackertype
* @property ?string $documentationurl
* @property int $imageid
* @property int $public
* @property int $coveragethreshold
* @property string $testingdataurl
* @property ?string $testingdataurl
* @property string $nightlytime
* @property bool $emaillowcoverage
* @property bool $emailtesttimingchanged
* @property bool $emailbrokensubmission
* @property bool $emailredundantfailures
* @property string $cvsviewertype
* @property ?string $cvsviewertype
* @property int $testtimestd
* @property int $testtimestdthreshold
* @property bool $showtesttime
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/app/Lib/Repository/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ public function getRepository(): string

protected function getRepositoryInformation(): void
{
$url = str_replace('//', '', $this->project->CvsUrl);
$url = str_replace('//', '', $this->project->CvsUrl ?? '');
$parts = explode('/', $url);
if (isset($parts[1])) {
$this->owner = $parts[1];
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/app/Model/BuildError.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function marshal(array $data, Project $project, $revision): array
'logline' => (int) $data['logline'],
'cvsurl' => RepositoryUtils::get_diff_url($project->Id, $project->CvsUrl, $sourceFile['directory'], $sourceFile['file'], $revision),
'precontext' => '',
'text' => RepositoryUtils::linkify_compiler_output($project->CvsUrl, $source_dir, $revision, $data['stdoutput']),
'text' => RepositoryUtils::linkify_compiler_output($project->CvsUrl ?? '', $source_dir, $revision, $data['stdoutput']),
'postcontext' => '',
'sourcefile' => $data['sourcefile'],
'sourceline' => $data['sourceline'],
Expand Down
6 changes: 3 additions & 3 deletions app/cdash/app/Model/BuildFailure.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public static function marshal($data, Project $project, $revision, $linkifyOutpu
$file = basename($data['sourcefile']);
$directory = dirname($data['sourcefile']);

$source_dir = RepositoryUtils::get_source_dir($project->Id, $project->CvsUrl, $directory);
$source_dir = RepositoryUtils::get_source_dir($project->Id, $project->CvsUrl ?? '', $directory);
if (str_starts_with($directory, $source_dir)) {
$directory = substr($directory, strlen($source_dir));
}
Expand All @@ -267,9 +267,9 @@ public static function marshal($data, Project $project, $revision, $linkifyOutpu
$revision);

if ($source_dir !== null && $linkifyOutput) {
$marshaled['stderror'] = RepositoryUtils::linkify_compiler_output($project->CvsUrl, $source_dir,
$marshaled['stderror'] = RepositoryUtils::linkify_compiler_output($project->CvsUrl ?? '', $source_dir,
$revision, $data['stderror']);
$marshaled['stdoutput'] = RepositoryUtils::linkify_compiler_output($project->CvsUrl, $source_dir,
$marshaled['stdoutput'] = RepositoryUtils::linkify_compiler_output($project->CvsUrl ?? '', $source_dir,
$revision, $data['stdoutput']);
}
}
Expand Down
34 changes: 17 additions & 17 deletions app/cdash/app/Model/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ class Project
{
public $Name;
public $Id;
public $Description;
public $HomeUrl;
public $CvsUrl;
public $DocumentationUrl;
public $BugTrackerUrl;
public $BugTrackerNewIssueUrl;
public $BugTrackerType;
public ?string $Description = null;
public ?string $HomeUrl = null;
public ?string $CvsUrl = null;
public ?string $DocumentationUrl = null;
public ?string $BugTrackerUrl = null;
public ?string $BugTrackerNewIssueUrl = null;
public ?string $BugTrackerType = null;
public ?int $ImageId = null;
public $Public;
public $CoverageThreshold;
public $TestingDataUrl;
public ?string $TestingDataUrl = null;
public $NightlyTime;
public $NightlyDateTime;
public $NightlyTimezone;
public $EmailLowCoverage = 0;
public $EmailTestTimingChanged = 0;
public $EmailBrokenSubmission = 0;
public $EmailRedundantFailures = 0;
public $CvsViewerType;
public ?string $CvsViewerType = null;
public $TestTimeStd;
public $TestTimeStdThreshold;
public $ShowTestTime = 0;
Expand Down Expand Up @@ -115,15 +115,15 @@ public function Save(): bool
$project->fill([
'name' => $this->Name ?? '',
'description' => $this->Description,
'homeurl' => $this->HomeUrl ?? '',
'cvsurl' => $this->CvsUrl ?? '',
'documentationurl' => $this->DocumentationUrl ?? '',
'bugtrackerurl' => $this->BugTrackerUrl ?? '',
'bugtrackernewissueurl' => $this->BugTrackerNewIssueUrl ?? '',
'bugtrackertype' => $this->BugTrackerType ?? '',
'homeurl' => $this->HomeUrl,
'cvsurl' => $this->CvsUrl,
'documentationurl' => $this->DocumentationUrl,
'bugtrackerurl' => $this->BugTrackerUrl,
'bugtrackernewissueurl' => $this->BugTrackerNewIssueUrl,
'bugtrackertype' => $this->BugTrackerType,
'public' => (int) $this->Public,
'coveragethreshold' => (int) $this->CoverageThreshold,
'testingdataurl' => $this->TestingDataUrl ?? '',
'testingdataurl' => $this->TestingDataUrl,
'nightlytime' => $this->NightlyTime ?? '',
'emaillowcoverage' => (bool) $this->EmailLowCoverage,
'emailtesttimingchanged' => (bool) $this->EmailTestTimingChanged,
Expand All @@ -137,7 +137,7 @@ public function Save(): bool
'autoremovetimeframe' => (int) $this->AutoremoveTimeframe,
'autoremovemaxbuilds' => (int) $this->AutoremoveMaxBuilds,
'uploadquota' => (int) $this->UploadQuota,
'cvsviewertype' => $this->CvsViewerType ?? '',
'cvsviewertype' => $this->CvsViewerType,
'testtimestd' => (int) $this->TestTimeStd,
'testtimestdthreshold' => (int) $this->TestTimeStdThreshold,
'showtesttime' => (bool) $this->ShowTestTime,
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/app/Model/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected static function getRepositoryService(Project $project): ?RepositorySer

public static function getRepositoryInterface(Project $project): RepositoryInterface
{
switch (strtolower($project->CvsViewerType)) {
switch (strtolower($project->CvsViewerType ?? '')) {
case strtolower(self::VIEWER_GITHUB):
$service = new GitHub($project);
break;
Expand Down
8 changes: 4 additions & 4 deletions app/cdash/include/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,10 @@ function get_dashboard_JSON($projectname, $date, &$response): void
$project->FindByName($projectname);

$project_array = [];
$project_array['cvsurl'] = $project->Id ? $project->CvsUrl : 'unknown';
$project_array['bugtrackerurl'] = $project->Id ? $project->BugTrackerUrl : 'unknown';
$project_array['documentationurl'] = $project->Id ? $project->DocumentationUrl : 'unknown';
$project_array['homeurl'] = $project->Id ? $project->HomeUrl : 'unknown';
$project_array['cvsurl'] = $project->CvsUrl ?? '';
$project_array['bugtrackerurl'] = $project->BugTrackerUrl ?? '';
$project_array['documentationurl'] = $project->DocumentationUrl ?? '';
$project_array['homeurl'] = $project->HomeUrl ?? '';
$project_array['name'] = $projectname;
$project_array['nightlytime'] = $project->Id ? $project->NightlyTime : '00:00:00';

Expand Down
2 changes: 1 addition & 1 deletion app/cdash/tests/test_builddetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct()

$this->createProject([
'Name' => 'BuildDetails',
'CvsViewerType' => 'viewcvs',
'CvsViewerType' => null,
]);

foreach ($this->testDataFiles as $testDataFile) {
Expand Down
100 changes: 100 additions & 0 deletions database/migrations/2026_01_30_045544_project_column_types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration {
public function up(): void
{
DB::statement('ALTER TABLE project ALTER COLUMN homeurl DROP NOT NULL');
DB::statement('ALTER TABLE project ALTER COLUMN homeurl DROP DEFAULT');
DB::statement('ALTER TABLE project ALTER COLUMN homeurl TYPE text');
DB::update("UPDATE project SET homeurl = NULL WHERE homeurl = ''");

DB::statement('ALTER TABLE project ALTER COLUMN cvsurl DROP NOT NULL');
DB::statement('ALTER TABLE project ALTER COLUMN cvsurl DROP DEFAULT');
DB::statement('ALTER TABLE project ALTER COLUMN cvsurl TYPE text');
DB::update("UPDATE project SET cvsurl = NULL WHERE cvsurl = ''");

DB::statement('ALTER TABLE project ALTER COLUMN bugtrackerurl DROP NOT NULL');
DB::statement('ALTER TABLE project ALTER COLUMN bugtrackerurl DROP DEFAULT');
DB::statement('ALTER TABLE project ALTER COLUMN bugtrackerurl TYPE text');
DB::update("UPDATE project SET bugtrackerurl = NULL WHERE bugtrackerurl = ''");

DB::statement('ALTER TABLE project ALTER COLUMN bugtrackernewissueurl DROP NOT NULL');
DB::statement('ALTER TABLE project ALTER COLUMN bugtrackernewissueurl DROP DEFAULT');
DB::statement('ALTER TABLE project ALTER COLUMN bugtrackernewissueurl TYPE text');
DB::update("UPDATE project SET bugtrackernewissueurl = NULL WHERE bugtrackernewissueurl = ''");

DB::statement('ALTER TABLE project ALTER COLUMN documentationurl DROP NOT NULL');
DB::statement('ALTER TABLE project ALTER COLUMN documentationurl DROP DEFAULT');
DB::statement('ALTER TABLE project ALTER COLUMN documentationurl TYPE text');
DB::update("UPDATE project SET documentationurl = NULL WHERE documentationurl = ''");

DB::statement('ALTER TABLE project ALTER COLUMN testingdataurl DROP NOT NULL');
DB::statement('ALTER TABLE project ALTER COLUMN testingdataurl DROP DEFAULT');
DB::statement('ALTER TABLE project ALTER COLUMN testingdataurl TYPE text');
DB::update("UPDATE project SET testingdataurl = NULL WHERE testingdataurl = ''");

DB::update('UPDATE project SET testtimestd = 4 WHERE testtimestd IS NULL');
DB::statement('ALTER TABLE project ALTER COLUMN testtimestd SET NOT NULL');

DB::update('UPDATE project SET testtimestdthreshold = 1 WHERE testtimestdthreshold IS NULL');
DB::statement('ALTER TABLE project ALTER COLUMN testtimestdthreshold SET NOT NULL');

DB::update('UPDATE project SET testtimemaxstatus = 3 WHERE testtimemaxstatus IS NULL');
DB::statement('ALTER TABLE project ALTER COLUMN testtimemaxstatus SET NOT NULL');

DB::update('UPDATE project SET emailmaxitems = 5 WHERE emailmaxitems IS NULL');
DB::statement('ALTER TABLE project ALTER COLUMN emailmaxitems SET NOT NULL');

DB::update('UPDATE project SET emailmaxchars = 255 WHERE emailmaxchars IS NULL');
DB::statement('ALTER TABLE project ALTER COLUMN emailmaxchars SET NOT NULL');

DB::update('UPDATE project SET autoremovetimeframe = 0 WHERE autoremovetimeframe IS NULL');
DB::statement('ALTER TABLE project ALTER COLUMN autoremovetimeframe SET NOT NULL');

DB::update('UPDATE project SET autoremovemaxbuilds = 300 WHERE autoremovemaxbuilds IS NULL');
DB::statement('ALTER TABLE project ALTER COLUMN autoremovemaxbuilds SET NOT NULL');

DB::update('UPDATE project SET uploadquota = 0 WHERE uploadquota IS NULL');
DB::statement('ALTER TABLE project ALTER COLUMN uploadquota SET NOT NULL');

DB::statement('ALTER TABLE project ALTER COLUMN ldapfilter TYPE text');

DB::statement('ALTER TABLE project ALTER COLUMN banner TYPE text');

// We drop the type first in case the database has been truncated previously.
DB::statement('DROP TYPE IF EXISTS cvsviewertype');
DB::statement("CREATE TYPE cvsviewertype AS ENUM ('github', 'gitlab')");
DB::statement("
ALTER TABLE project
ALTER COLUMN cvsviewertype
TYPE cvsviewertype USING
CASE
WHEN cvsviewertype = 'github' THEN 'github'::cvsviewertype
WHEN cvsviewertype = 'gitlab' THEN 'gitlab'::cvsviewertype
ELSE NULL
END
");

// We drop the type first in case the database has been truncated previously.
DB::statement('DROP TYPE IF EXISTS bugtrackertype');
DB::statement("CREATE TYPE bugtrackertype AS ENUM ('GitHub', 'Buganizer', 'JIRA')");
DB::statement("
ALTER TABLE project
ALTER COLUMN bugtrackertype
TYPE bugtrackertype USING
CASE
WHEN bugtrackertype = 'GitHub' THEN 'GitHub'::bugtrackertype
WHEN bugtrackertype = 'Buganizer' THEN 'Buganizer'::bugtrackertype
WHEN bugtrackertype = 'JIRA' THEN 'JIRA'::bugtrackertype
ELSE NULL
END
");
}

public function down(): void
{
}
};
Loading