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
5 changes: 2 additions & 3 deletions app/Http/Submission/Handlers/BuildHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

use App\Enums\BuildCommandType;
use App\Enums\TargetType;
use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Build as EloquentBuild;
use App\Models\BuildCommand;
use App\Models\BuildCommandOutput;
Expand All @@ -28,6 +27,7 @@
use App\Models\Site;
use App\Models\SiteInformation;
use App\Models\Target;
use App\Services\SiteService;
use App\Utils\SubmissionUtils;
use Carbon\Carbon;
use CDash\Collection\BuildCollection;
Expand All @@ -51,7 +51,6 @@
class BuildHandler extends AbstractXmlHandler implements ActionableBuildInterface, CommitAuthorHandlerInterface
{
use CommitAuthorHandlerTrait;
use UpdatesSiteInformation;

private int $StartTimeStamp = -1;
private int $EndTimeStamp = -1;
Expand Down Expand Up @@ -177,7 +176,7 @@ public function startElement($parser, $name, $attributes): void
$this->BuildName = '(empty)';
}

$this->updateSiteInfoIfChanged($this->Site, $siteInformation);
SiteService::updateSiteInfoIfChanged($this->Site, $siteInformation);
} elseif ($name === 'SUBPROJECT') {
$this->SubProjectName = $attributes['NAME'];
if (!array_key_exists($this->SubProjectName, $this->SubProjects)) {
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Submission/Handlers/ConfigureHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Site;
use App\Models\SiteInformation;
use App\Services\SiteService;
use App\Utils\SubmissionUtils;
use CDash\Collection\BuildCollection;
use CDash\Collection\SubscriptionBuilderCollection;
Expand All @@ -36,8 +36,6 @@

class ConfigureHandler extends AbstractXmlHandler implements ActionableBuildInterface
{
use UpdatesSiteInformation;

private int $StartTimeStamp = 0;
private int $EndTimeStamp = 0;
private array $Builds = [];
Expand Down Expand Up @@ -115,7 +113,7 @@ public function startElement($parser, $name, $attributes): void
$this->BuildName = '(empty)';
}

$this->updateSiteInfoIfChanged($this->Site, $siteInformation);
SiteService::updateSiteInfoIfChanged($this->Site, $siteInformation);
} elseif ($name === 'SUBPROJECT') {
$this->SubProjectName = $attributes['NAME'];
if (!array_key_exists($this->SubProjectName, $this->SubProjects)) {
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Submission/Handlers/CoverageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Site;
use App\Models\SiteInformation;
use App\Services\ProjectService;
use App\Services\SiteService;
use App\Utils\SubmissionUtils;
use CDash\Model\Build;
use CDash\Model\Coverage;
Expand All @@ -32,8 +32,6 @@

class CoverageHandler extends AbstractXmlHandler
{
use UpdatesSiteInformation;

private int $StartTimeStamp;
private int $EndTimeStamp;

Expand Down Expand Up @@ -86,7 +84,7 @@ public function startElement($parser, $name, $attributes): void
}
}

$this->updateSiteInfoIfChanged($this->Site, $siteInformation);
SiteService::updateSiteInfoIfChanged($this->Site, $siteInformation);

$this->Build->SiteId = $this->Site->id;
$this->Build->Name = $attributes['BUILDNAME'];
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Submission/Handlers/CoverageJUnitHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Site;
use App\Models\SiteInformation;
use App\Services\SiteService;
use App\Utils\SubmissionUtils;
use CDash\Model\Coverage;
use CDash\Model\CoverageFile;
Expand All @@ -29,8 +29,6 @@

class CoverageJUnitHandler extends AbstractXmlHandler
{
use UpdatesSiteInformation;

private int $StartTimeStamp;
private int $EndTimeStamp;

Expand Down Expand Up @@ -83,7 +81,7 @@ public function startElement($parser, $name, $attributes): void
}
}

$this->updateSiteInfoIfChanged($this->Site, $siteInformation);
SiteService::updateSiteInfoIfChanged($this->Site, $siteInformation);

$this->Build->SiteId = $this->Site->id;
$this->Build->Name = $attributes['BUILDNAME'];
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Submission/Handlers/DynamicAnalysisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\DynamicAnalysisDefect;
use App\Models\Site;
use App\Models\SiteInformation;
use App\Services\SiteService;
use App\Utils\SubmissionUtils;
use CDash\Collection\BuildCollection;
use CDash\Collection\SubscriptionBuilderCollection;
Expand All @@ -38,8 +38,6 @@

class DynamicAnalysisHandler extends AbstractXmlHandler implements ActionableBuildInterface
{
use UpdatesSiteInformation;

private int $StartTimeStamp;
private int $EndTimeStamp;
private string $Checker;
Expand Down Expand Up @@ -114,7 +112,7 @@ public function startElement($parser, $name, $attributes): void
if (empty($this->BuildName)) {
$this->BuildName = '(empty)';
}
$this->updateSiteInfoIfChanged($this->Site, $siteInformation);
SiteService::updateSiteInfoIfChanged($this->Site, $siteInformation);
} elseif ($name === 'SUBPROJECT') {
$this->SubProjectName = $attributes['NAME'];
if (!array_key_exists($this->SubProjectName, $this->SubProjects)) {
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Submission/Handlers/NoteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Site;
use App\Models\SiteInformation;
use App\Services\SiteService;
use App\Utils\NoteCreator;
use App\Utils\SubmissionUtils;
use CDash\Model\Project;
use Illuminate\Support\Facades\Log;

class NoteHandler extends AbstractXmlHandler
{
use UpdatesSiteInformation;

private bool $AdjustStartTime = false;
private NoteCreator $NoteCreator;
protected static ?string $schema_file = '/app/Validators/Schemas/Notes.xsd';
Expand Down Expand Up @@ -76,7 +74,7 @@ public function startElement($parser, $name, $attributes): void
}
}

$this->updateSiteInfoIfChanged($this->Site, $siteInformation);
SiteService::updateSiteInfoIfChanged($this->Site, $siteInformation);

$this->Build->SiteId = $this->Site->id;
$this->Build->Name = $attributes['BUILDNAME'];
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Submission/Handlers/TestingHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Http\Submission\Handlers;

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Site;
use App\Models\SiteInformation;
use App\Models\TestMeasurement;
use App\Services\SiteService;
use App\Utils\SubmissionUtils;
use App\Utils\TestCreator;
use Carbon\Carbon;
Expand All @@ -29,7 +29,6 @@
class TestingHandler extends AbstractXmlHandler implements ActionableBuildInterface, CommitAuthorHandlerInterface
{
use CommitAuthorHandlerTrait;
use UpdatesSiteInformation;

protected static ?string $schema_file = '/app/Validators/Schemas/Test.xsd';
private int $StartTimeStamp = 0;
Expand Down Expand Up @@ -122,7 +121,7 @@ public function startElement($parser, $name, $attributes): void
if (empty($this->BuildName)) {
$this->BuildName = '(empty)';
}
$this->updateSiteInfoIfChanged($this->Site, $siteInformation);
SiteService::updateSiteInfoIfChanged($this->Site, $siteInformation);
} elseif ($name === 'SUBPROJECT') {
$this->SubProjectName = $attributes['NAME'];
if (!array_key_exists($this->SubProjectName, $this->SubProjects)) {
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Submission/Handlers/TestingJUnitHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Site;
use App\Models\SiteInformation;
use App\Services\SiteService;
use App\Utils\SubmissionUtils;
use App\Utils\TestCreator;
use CDash\Model\Project;

class TestingJUnitHandler extends AbstractXmlHandler
{
use UpdatesSiteInformation;

private int $StartTimeStamp;
private int $EndTimeStamp;
// Should we update the end time of the build?
Expand Down Expand Up @@ -95,7 +93,7 @@ public function startElement($parser, $name, $attributes): void
}
}

$this->updateSiteInfoIfChanged($this->Site, $siteInformation);
SiteService::updateSiteInfoIfChanged($this->Site, $siteInformation);

$this->Build->SiteId = $this->Site->id;
$this->Build->Name = $attributes['BUILDNAME'];
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Submission/Handlers/UploadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Site;
use App\Models\SiteInformation;
use App\Models\UploadFile;
use App\Services\SiteService;
use App\Utils\SubmissionUtils;
use CDash\Model\Label;
use CDash\Model\Project;
Expand All @@ -45,8 +45,6 @@
*/
class UploadHandler extends AbstractXmlHandler
{
use UpdatesSiteInformation;

private UploadFile $UploadFile;
private string $TmpFilename = '';
private $Base64TmpFileWriteHandle = 0;
Expand Down Expand Up @@ -106,7 +104,7 @@ public function startElement($parser, $name, $attributes): void
}
}

$this->updateSiteInfoIfChanged($this->Site, $siteInformation);
SiteService::updateSiteInfoIfChanged($this->Site, $siteInformation);

$this->Build->SiteId = $this->Site->id;
$this->Build->Name = $attributes['BUILDNAME'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

namespace App\Http\Submission\Traits;
declare(strict_types=1);

namespace App\Services;

use App\Models\Site;
use App\Models\SiteInformation;

trait UpdatesSiteInformation
class SiteService extends AbstractService
{
/**
* Saves a new site information record if $newInformation is different from the most recent
* information recorded for the site.
*/
protected function updateSiteInfoIfChanged(Site $site, SiteInformation $newInformation): void
public static function updateSiteInfoIfChanged(Site $site, SiteInformation $newInformation): void
{
if ($site->information()->doesntExist()) {
// No existing information, so save whatever we're given, regardless of whether it's all null.
Expand Down
4 changes: 2 additions & 2 deletions app/cdash/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ add_feature_test_in_transaction(/Feature/GraphQL/Mutations/ChangeProjectRoleTest

add_feature_test_in_transaction(/Feature/GraphQL/Mutations/RemoveProjectUserTest)

add_feature_test_in_transaction(/Feature/Traits/UpdatesSiteInformationTest)

add_feature_test_in_transaction(/Feature/GraphQL/Mutations/ChangeGlobalRoleTest)

add_feature_test_in_transaction(/Feature/GraphQL/Mutations/JoinProjectTest)
Expand Down Expand Up @@ -322,6 +320,8 @@ add_feature_test_in_transaction(/Feature/Jobs/ComputeCoverageDifferenceTest)

add_feature_test_in_transaction(/Feature/Services/ProjectServiceTest)

add_feature_test_in_transaction(/Feature/Services/SiteServiceTest)

add_feature_test_in_transaction(/Feature/AutoRemoveBuildsCommand)

###################################################################################################
Expand Down
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -22998,12 +22998,6 @@ parameters:
count: 1
path: tests/Feature/RouteAccessTest.php

-
rawMessage: 'You should use assertSame() instead of assertEquals(), because both values are scalars of the same type'
identifier: phpunit.assertEquals
count: 6
path: tests/Feature/Traits/UpdatesSiteInformationTest.php

-
rawMessage: Cannot access property $admin on App\Models\User|null.
identifier: property.nonObject
Expand Down
5 changes: 2 additions & 3 deletions tests/Browser/Pages/BuildBuildPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Browser\Pages;

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Build;
use App\Models\BuildError;
use App\Models\BuildUpdate;
Expand All @@ -11,6 +10,7 @@
use App\Models\Site;
use App\Models\SiteInformation;
use App\Models\SubProject;
use App\Services\SiteService;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Laravel\Dusk\Browser;
Expand All @@ -23,7 +23,6 @@ class BuildBuildPageTest extends BrowserTestCase
{
use CreatesProjects;
use CreatesSites;
use UpdatesSiteInformation;

private Project $project;

Expand Down Expand Up @@ -59,7 +58,7 @@ public function setUp(): void
]);

$this->site = $this->makeSite();
$this->updateSiteInfoIfChanged($this->site, new SiteInformation([]));
SiteService::updateSiteInfoIfChanged($this->site, new SiteInformation([]));
}

public function tearDown(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/Browser/Pages/BuildCommentsPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Tests\Browser\Pages;

use App\Http\Submission\Traits\UpdatesSiteInformation;
use App\Models\Build;
use App\Models\Comment;
use App\Models\Project;
use App\Models\Site;
use App\Models\SiteInformation;
use App\Models\User;
use App\Services\SiteService;
use Illuminate\Support\Str;
use Laravel\Dusk\Browser;
use Tests\BrowserTestCase;
Expand All @@ -21,7 +21,6 @@ class BuildCommentsPageTest extends BrowserTestCase
use CreatesProjects;
use CreatesSites;
use CreatesUsers;
use UpdatesSiteInformation;

private Project $project;
private Site $site;
Expand All @@ -36,7 +35,7 @@ public function setUp(): void
$this->user = $this->makeNormalUser();

$this->site = $this->makeSite();
$this->updateSiteInfoIfChanged($this->site, new SiteInformation([]));
SiteService::updateSiteInfoIfChanged($this->site, new SiteInformation([]));
}

public function tearDown(): void
Expand Down
Loading