Exemplo n.º 1
0
/** Add a new build */
function add_build($build, $clientscheduleid = 0)
{
    require_once 'models/buildgroup.php';
    if (!is_numeric($build->ProjectId) || !is_numeric($build->SiteId)) {
        return;
    }
    //add_log('subprojectname: '.$build->SubProjectName, 'add_build');
    $buildid = $build->GetIdFromName($build->SubProjectName);
    if ($buildid > 0 && !$build->Append) {
        remove_build($buildid);
    }
    // Move this into a Build::SetAppend($append, $buildid) method:
    //
    if (!$build->Exists() && $build->Append && empty($build->Id)) {
        $build->Id = $buildid;
    }
    // Find the groupid
    $buildGroup = new BuildGroup();
    $build->GroupId = $buildGroup->GetGroupIdFromRule($build);
    $build->Save();
    // If the build is part of a subproject we link the update file
    if (isset($build->SubProjectName) && $build->SubProjectName != '') {
        require_once 'models/buildupdate.php';
        $BuildUpdate = new BuildUpdate();
        $BuildUpdate->BuildId = $build->Id;
        $BuildUpdate->AssociateBuild($build->SiteId, $build->Name, $build->GetStamp());
    }
    if ($clientscheduleid != 0) {
        require_once 'models/clientjobschedule.php';
        $ClientJobSchedule = new ClientJobSchedule();
        $ClientJobSchedule->Id = $clientscheduleid;
        $ClientJobSchedule->AssociateBuild($build->Id);
    }
    return $build->Id;
}
Exemplo n.º 2
0
 private static function GetBuildListBy($colony, $IDrangeFrom, $IDrangeTo, $readyToBeBuilt = false, $table = "production")
 {
     // Get building list
     $colonyID = $colony->ID();
     $query = "SELECT * FROM {$table} WHERE colonyID = {$colonyID} AND resource_type_being_built BETWEEN {$IDrangeFrom} AND {$IDrangeTo}";
     if ($readyToBeBuilt) {
         $time = time();
         $query .= " AND {$time} > scheduled_time";
     }
     $query .= " ORDER BY build_list_position ASC;";
     $buildData = Database::Instance()->ExecuteQuery($query, "SELECT");
     // BuildGroup always expects an array of arrays, so if we get NULL or a single array, we need to make an array of arrays
     if ($buildData === NULL) {
         $buildData = array();
     }
     if (isset($buildData["colonyID"])) {
         $buildData = array($buildData);
     }
     if ($table === "production_building") {
         $buildGroup = BuildingBuildGroup::FromDatabase($buildData, $colony);
     } else {
         $buildGroup = BuildGroup::FromDatabase($buildData, $colony);
     }
     return new ResourceBuilder($buildGroup);
 }
 public static function FromList(array $resources, Colony $colony, array $listPositions = NULL, $forDeletion = false)
 {
     $members = array();
     $positionCounter = 0;
     $positionInList = 0;
     // Determine the list positions.
     if ($listPositions == NULL) {
         $positionInList += BuildingBuildGroup::GetLastBuildListPosition($colony);
         $positionInList++;
         // If there are other constructions preceding this, offset by 1.
     } else {
         // We DID receive an overriding array, let's use those numbers instead!
         $positionInList = $listPositions[0];
     }
     // Construct list of members
     foreach ($resources as $itemName) {
         $itemObject = clone ResourceParser::Instance()->GetItemByName($itemName);
         $itemObject->Amount(1);
         if ($listPositions != NULL) {
             // Override the list position with the given array.
             $positionInList = $listPositions[$positionCounter];
             $positionCounter++;
         }
         $members[$positionInList] =& BuildingBuildItem::FromIDResource($itemObject, $positionInList, $positionInList, 0, 1, NULL);
         $positionInList++;
     }
     $bg = new BuildingBuildGroup($members, $colony);
     BuildGroup::LinkMembersToGroup($bg);
     // If this BuildGroup is being built up so we can deduct it from another BuildGroup,
     // we don't calculate all the build times, because they won't be used.
     if (!$forDeletion) {
         $bg->FillItemsInDatabase();
         // Pretty damn crucial for correct calculation of buildLevels!
         $bg->UpdateLevels();
         $bg->UpdateBuildTimes();
     }
     return $bg;
 }
Exemplo n.º 4
0
/** Main function to send email if necessary */
function sendemail($handler, $projectid)
{
    include 'config/config.php';
    include_once 'include/common.php';
    require_once 'include/pdo.php';
    require_once 'models/build.php';
    require_once 'models/project.php';
    require_once 'models/buildgroup.php';
    $Project = new Project();
    $Project->Id = $projectid;
    $Project->Fill();
    $sendEmail = null;
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) {
        include_once 'local/sendemail.php';
        $sendEmail = new SendEmail();
        $sendEmail->SetProjectId($projectid);
    }
    // If we shouldn't sent any emails we stop
    if ($Project->EmailBrokenSubmission == 0) {
        return;
    }
    // If the handler has a buildid (it should), we use it
    if (isset($handler->BuildId) && $handler->BuildId > 0) {
        $buildid = $handler->BuildId;
    } else {
        // Get the build id
        $name = $handler->getBuildName();
        $stamp = $handler->getBuildStamp();
        $sitename = $handler->getSiteName();
        $buildid = get_build_id($name, $stamp, $projectid, $sitename);
    }
    if ($buildid < 0) {
        return;
    }
    //add_log("Buildid ".$buildid,"sendemail ".$Project->Name,LOG_INFO);
    //  Check if the group as no email
    $Build = new Build();
    $Build->Id = $buildid;
    $groupid = $Build->GetGroup();
    $BuildGroup = new BuildGroup();
    $BuildGroup->SetId($groupid);
    // If we specified no email we stop here
    if ($BuildGroup->GetSummaryEmail() == 2) {
        return;
    }
    $emailCommitters = $BuildGroup->GetEmailCommitters();
    $errors = check_email_errors($buildid, $Project->EmailTestTimingChanged, $Project->TestTimeMaxStatus, !$Project->EmailRedundantFailures);
    // We have some fixes
    if ($errors['hasfixes']) {
        $Build->FillFromId($Build->Id);
        // Get the list of person who should get the email
        $lookup_result = lookup_emails_to_send($errors, $buildid, $projectid, $Build->Type, true, $emailCommitters);
        $userids = $lookup_result['userids'];
        foreach ($userids as $userid) {
            $emailtext = array();
            $emailtext['nfixes'] = 0;
            // Check if an email has been sent already for this user
            foreach ($errors['fixes'] as $fixkey => $nfixes) {
                if ($nfixes == 0) {
                    continue;
                }
                if (!check_email_sent($userid, $buildid, $fixkey)) {
                    $emailtext['category'][$fixkey] = $nfixes;
                    $emailtext['nfixes'] = 1;
                }
            }
            // Send the email
            if ($emailtext['nfixes'] == 1) {
                send_email_fix_to_user($userid, $emailtext, $Build, $Project);
            }
        }
    }
    // No error we return
    if (!$errors['errors']) {
        return;
    }
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) {
        $sendEmail->BuildId = $Build->Id;
        $sendEmail->Errors = $errors;
    }
    // If we should send a summary email
    if ($BuildGroup->GetSummaryEmail() == 1) {
        // Send the summary email
        sendsummaryemail($projectid, $groupid, $errors, $buildid);
        if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) {
            $sendEmail->SendSummary();
        }
        return;
    }
    $Build->FillFromId($Build->Id);
    // Send build error
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) {
        $sendEmail->SendBuildError();
    }
    // Lookup the list of people who should get the email, both registered
    // users *and* committers:
    //
    $lookup_result = lookup_emails_to_send($errors, $buildid, $projectid, $Build->Type, false, $emailCommitters);
    // Loop through the *registered* users:
    //
    $userids = $lookup_result['userids'];
    foreach ($userids as $userid) {
        send_error_email($userid, '', $sendEmail, $errors, $Build, $Project);
    }
    // Loop through "other" users, if necessary:
    //
    // ...people who committed code, but are *not* registered CDash users, but
    // only if the 'emailcommitters' field is on for this build group.
    //
    if ($emailCommitters) {
        $committeremails = $lookup_result['committeremails'];
        foreach ($committeremails as $committeremail) {
            send_error_email(0, $committeremail, $sendEmail, $errors, $Build, $Project, getHandlerErrorKeyPrefix($handler));
        }
    }
}
Exemplo n.º 5
0
 /** Get the build groups */
 function GetBuildGroups()
 {
     $buildgroups = array();
     $query = pdo_query("\n       SELECT id FROM buildgroup\n       WHERE projectid=" . qnum($this->Id) . " AND\n             endtime='1980-01-01 00:00:00'");
     add_last_sql_error("Project GetBuildGroups", $this->Id);
     while ($row = pdo_fetch_array($query)) {
         $buildgroup = new BuildGroup();
         $buildgroup->SetId($row['id']);
         $buildgroups[] = $buildgroup;
     }
     return $buildgroups;
 }
Exemplo n.º 6
0
function rest_put()
{
    global $projectid;
    if (isset($_GET['buildgroup'])) {
        // Modify an existing buildgroup.
        $buildgroup = json_decode($_GET['buildgroup'], true);
        // Deal with the fact that unchecked checkboxes will not be included
        // in the above array.
        if (!array_key_exists('emailcommitters', $buildgroup)) {
            $buildgroup['emailcommitters'] = 0;
        }
        if (!array_key_exists('includesubprojecttotal', $buildgroup)) {
            $buildgroup['includesubprojecttotal'] = 0;
        }
        $BuildGroup = new BuildGroup();
        $BuildGroup->SetId(pdo_real_escape_numeric($buildgroup['id']));
        $BuildGroup->SetName(pdo_real_escape_string($buildgroup['name']));
        $BuildGroup->SetDescription(pdo_real_escape_string($buildgroup['description']));
        $BuildGroup->SetSummaryEmail(pdo_real_escape_numeric($buildgroup['summaryemail']));
        $BuildGroup->SetEmailCommitters(pdo_real_escape_numeric($buildgroup['emailcommitters']));
        $BuildGroup->SetIncludeSubProjectTotal(pdo_real_escape_numeric($buildgroup['includesubprojecttotal']));
        $BuildGroup->SetAutoRemoveTimeFrame(pdo_real_escape_numeric($buildgroup['autoremovetimeframe']));
        if (!$BuildGroup->Save()) {
            echo_error('Failed to save BuildGroup');
        }
        return;
    }
}
Exemplo n.º 7
0
 public function testBuildRemovalWorksAsExpected()
 {
     require_once 'include/common.php';
     require_once 'include/pdo.php';
     require_once 'models/build.php';
     require_once 'models/buildconfigure.php';
     require_once 'models/builderror.php';
     require_once 'models/buildfailure.php';
     require_once 'models/buildgroup.php';
     require_once 'models/buildnote.php';
     require_once 'models/buildupdate.php';
     require_once 'models/coverage.php';
     require_once 'models/dynamicanalysis.php';
     require_once 'models/dynamicanalysissummary.php';
     require_once 'models/image.php';
     require_once 'models/label.php';
     require_once 'models/test.php';
     require_once 'models/uploadfile.php';
     $time = gmdate(FMT_DATETIME);
     // Find an existing site.
     $row = pdo_single_row_query('SELECT id FROM site LIMIT 1');
     $siteid = $row['id'];
     // Label
     $label = new Label();
     $label->SetText('remove me');
     // Build
     $build = new Build();
     $build->Name = 'RemovalWorksAsExpected';
     $build->SetStamp('20160822-1810-Experimental');
     $build->ProjectId = 1;
     $build->InsertErrors = true;
     $build->SiteId = $siteid;
     $build->StartTime = $time;
     $build->EndTime = $time;
     $build->SubmitTime = $time;
     $build->AddLabel($label);
     $buildgroup = new BuildGroup();
     $build->GroupId = $buildgroup->GetGroupIdFromRule($build);
     $info = new BuildInformation();
     $info->SetValue('OSNAME', 'Windows');
     $build->Information = $info;
     // BuildError
     $error = new BuildError();
     $error->Text = 'error: asdf';
     $build->AddError($error);
     // BuildFailure
     $failure = new BuildFailure();
     $failure->StdError = 'failure: asdf';
     $failure->AddArgument('arg1');
     $failure->AddLabel($label);
     $build->AddError($failure);
     $build->Save();
     // Create another build to test shared resources.
     $existing_build = new Build();
     $existing_build->Id = $build->Id;
     $existing_build->FillFromId($build->Id);
     $existing_build->SetStamp('20160822-1811-Experimental');
     $existing_build->SubmitTime = $time;
     $existing_build->InsertErrors = true;
     $existing_build->AddError($failure);
     $existing_build->Id = null;
     $existing_build->Save();
     // BuildConfigure
     $configure = new BuildConfigure();
     $configure->BuildId = $build->Id;
     $configure->StartTime = $time;
     $configure->EndTime = $time;
     $configure->Command = 'cmake';
     $configure->Log = "precontext\nWARNING: bar\npostcontext";
     $configure->Status = 5;
     $configure->AddLabel($label);
     $configure->Insert();
     $configure->ComputeWarnings();
     $configure->ComputeErrors();
     // BuildNote
     $note = new BuildNote();
     $note->Name = 'my note';
     $note->Text = 'note text';
     $note->Time = $time;
     $note->BuildId = $build->Id;
     $note->Insert();
     $shared_note = new BuildNote();
     $shared_note->Name = 'my shared note';
     $shared_note->Text = 'shared note text';
     $shared_note->Time = $time;
     $shared_note->BuildId = $build->Id;
     $shared_note->Insert();
     $shared_note->BuildId = $existing_build->Id;
     $shared_note->Insert();
     // buildtesttime
     $build->SaveTotalTestsTime(8);
     // BuildUpdate
     $updatefile = new BuildUpdateFile();
     $updatefile->Author = 'My Self';
     $updatefile->Committer = 'My Self';
     $updatefile->Email = '*****@*****.**';
     $updatefile->CommitterEmail = '*****@*****.**';
     $updatefile->Revision = 2;
     $updatefile->PriorRevision = 1;
     $updatefile->Filename = 'foo.cpp';
     $updatefile->Status = 'MODIFIED';
     $update = new BuildUpdate();
     $update->AddFile($updatefile);
     $update->BuildId = $build->Id;
     $update->StartTime = $time;
     $update->EndTime = $time;
     $update->Command = 'git fetch';
     $update->Insert();
     pdo_query("INSERT INTO build2update (buildid, updateid)\n            VALUES ({$existing_build->Id}, {$update->UpdateId})");
     // Coverage
     $file1 = new CoverageFile();
     $file1->FullPath = '/path/to/unshared.php';
     $file1->File .= "this unshared line gets covered<br>";
     $file1->File .= "this unshared line does not<br>";
     $coverage1 = new Coverage();
     $coverage1->Covered = 1;
     $coverage1->CoverageFile = $file1;
     $coverage1->LocTested = 1;
     $coverage1->LocUntested = 1;
     $coverage1->AddLabel($label);
     $file2 = new CoverageFile();
     $file2->FullPath = '/path/to/shared.php';
     $file2->File .= "this shared line gets covered<br>";
     $file2->File .= "this shared line does not<br>";
     $coverage2 = new Coverage();
     $coverage2->Covered = 1;
     $coverage2->CoverageFile = $file2;
     $coverage2->LocTested = 1;
     $coverage2->LocUntested = 1;
     $coverage2->AddLabel($label);
     $summary = new CoverageSummary();
     $summary->BuildId = $build->Id;
     $summary->AddCoverage($coverage1);
     $summary->AddCoverage($coverage2);
     $summary->Insert(true);
     $file1->TrimLastNewline();
     $file1->Update($build->Id);
     $log1 = new CoverageFileLog();
     $log1->AddLine(1, 1);
     $log1->BuildId = $build->Id;
     $log1->FileId = $file1->Id;
     $log1->Insert(true);
     $file2->TrimLastNewline();
     $file2->Update($build->Id);
     $log2 = new CoverageFileLog();
     $log2->AddLine(1, 1);
     $log2->BuildId = $build->Id;
     $log2->FileId = $file2->Id;
     $log2->Insert(true);
     // Also add coverage to existing build to test that shared files
     // do not get deleted.
     $existing_cov = new Coverage();
     $existing_cov->Covered = 1;
     $existing_cov->CoverageFile = $file2;
     $existing_cov->LocTested = 1;
     $existing_cov->LocUntested = 1;
     $existing_cov->AddLabel($label);
     $existing_summary = new CoverageSummary();
     $existing_summary->BuildId = $existing_build->Id;
     $existing_summary->AddCoverage($existing_cov);
     $existing_summary->Insert(true);
     $file2->Update($existing_build->Id);
     $existing_log = new CoverageFileLog();
     $existing_log->AddLine(1, 1);
     $existing_log->BuildId = $existing_build->Id;
     $existing_log->FileId = $file2->Id;
     $existing_log->Insert(true);
     // DynamicAnalysis
     $DA_defect = new DynamicAnalysisDefect();
     $DA_defect->Type = 'Potential Memory Leak';
     $DA_defect->Value = 5;
     $DA = new DynamicAnalysis();
     $DA->BuildId = $build->Id;
     $DA->Checker = 'Valgrind';
     $DA->FullCommandLine = 'php DA_removebuilds.php';
     $DA->Log = 'build removed successfully';
     $DA->Name = 'removal test';
     $DA->Path = '/path/to/removal/DA';
     $DA->Status = 'failed';
     $DA->AddDefect($DA_defect);
     $DA->AddLabel($label);
     $DA->Insert();
     $DA_summary = new DynamicAnalysisSummary();
     $DA_summary->BuildId = $build->Id;
     $DA_summary->Checker = 'Valgrind';
     $DA_summary->AddDefects($DA_defect->Value);
     $DA_summary->Insert();
     // Test
     $test = new Test();
     $test->ProjectId = 1;
     $test->CompressedOutput = false;
     $test->Details = 'Completed';
     $test->Name = 'removal test';
     $test->Path = '/path/to/removal/test';
     $test->Command = 'php test_removebuilds.php';
     $test->Output = 'build removed successfully';
     $measurement = new TestMeasurement();
     $measurement->Name = 'Exit Value';
     $measurement->Type = 'text/string';
     $measurement->Value = 5;
     $test->AddMeasurement($measurement);
     $image = new Image();
     $image->Extension = 'image/png';
     $image->Data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl' . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr' . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r' . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
     $image->Name = 'remove_me.png';
     $test->AddImage($image);
     $test->Insert();
     $buildtest = new BuildTest();
     $buildtest->BuildId = $build->Id;
     $buildtest->TestId = $test->Id;
     $buildtest->Status = 'passed';
     $buildtest->Insert();
     $test->AddLabel($label);
     $test->InsertLabelAssociations($build->Id);
     $test2 = new Test();
     $test2->ProjectId = 1;
     $test2->CompressedOutput = false;
     $test2->Details = 'Completed';
     $test2->Name = 'shared test';
     $test2->Path = '/path/to/shared/test';
     $test2->Command = 'php test_sharedtest.php';
     $test2->Output = 'test shared successfully';
     $measurement2 = new TestMeasurement();
     $measurement2->Name = 'Exit Value';
     $measurement2->Type = 'text/string';
     $measurement2->Value = 0;
     $test2->AddMeasurement($measurement2);
     $image2 = new Image();
     $image2->Extension = 'image/gif';
     $image2->Name = 'smile.gif';
     $image2->Data = base64_encode(file_get_contents(dirname(__FILE__) . '/data/smile.gif'));
     $test2->AddImage($image2);
     $test2->Insert();
     $buildtest2 = new BuildTest();
     $buildtest2->BuildId = $build->Id;
     $buildtest2->TestId = $test2->Id;
     $buildtest2->Status = 'passed';
     $buildtest2->Insert();
     $buildtest2->BuildId = $existing_build->Id;
     $buildtest2->Insert();
     $test2->AddLabel($label);
     $test2->InsertLabelAssociations($build->Id);
     // UploadFile
     $filename = dirname(__FILE__) . '/data/smile.gif';
     $upload1 = new UploadFile();
     $upload1->Filename = $filename;
     $upload1->IsUrl = false;
     $upload1->BuildId = $build->Id;
     $upload1->Sha1Sum = sha1_file($filename);
     $upload1->Filesize = filesize($filename);
     $upload1->Insert();
     $filename = dirname(__FILE__) . '/data/smile2.gif';
     $upload2 = new UploadFile();
     $upload2->Filename = $filename;
     $upload2->IsUrl = false;
     $upload2->BuildId = $build->Id;
     $upload2->Sha1Sum = sha1_file($filename);
     $upload2->Filesize = filesize($filename);
     $upload2->Insert();
     $upload2->BuildId = $existing_build->Id;
     $upload2->Insert();
     // Various tables that are too hard to spoof with models so we resort
     // to direct insertion.
     pdo_query("INSERT INTO buildemail (userid, buildid, category)\n            VALUES (1, {$build->Id}, 0)");
     pdo_query("INSERT INTO builderrordiff\n            (buildid, type, difference_positive, difference_negative)\n            VALUES ({$build->Id}, 0, 1, 1)");
     pdo_query("INSERT INTO configureerrordiff (buildid, type, difference)\n            VALUES ({$build->Id}, 0, 1)");
     pdo_query("INSERT INTO coveragesummarydiff (buildid, loctested, locuntested)\n            VALUES ({$build->Id}, 1, 1)");
     pdo_query("INSERT INTO summaryemail (buildid, date, groupid)\n            VALUES ({$build->Id}, '{$time}', 1)");
     pdo_query("INSERT INTO subproject2build (subprojectid, buildid)\n            VALUES (1, {$build->Id})");
     pdo_query("INSERT INTO testdiff\n            (buildid, type, difference_positive, difference_negative)\n            VALUES ({$build->Id}, 0, 1, 1)");
     // Check that everything was created successfully.
     $this->verify('build', 'id', '=', $build->Id, 1);
     $this->verify('build2group', 'buildid', '=', $build->Id, 1);
     $this->verify('buildemail', 'buildid', '=', $build->Id, 1);
     $this->verify('builderror', 'buildid', '=', $build->Id, 1);
     $this->verify('builderrordiff', 'buildid', '=', $build->Id, 1);
     $this->verify('buildinformation', 'buildid', '=', $build->Id, 1);
     $this->verify('buildtesttime', 'buildid', '=', $build->Id, 1);
     $this->verify('configure', 'buildid', '=', $build->Id, 1);
     $this->verify('configureerror', 'buildid', '=', $build->Id, 1);
     $this->verify('configureerrordiff', 'buildid', '=', $build->Id, 1);
     $this->verify('coveragesummary', 'buildid', '=', $build->Id, 1);
     $this->verify('coveragesummarydiff', 'buildid', '=', $build->Id, 1);
     $this->verify('coveragefilelog', 'buildid', '=', $build->Id, 2);
     $this->verify('dynamicanalysissummary', 'buildid', '=', $build->Id, 1);
     $this->verify('summaryemail', 'buildid', '=', $build->Id, 1);
     $this->verify('subproject2build', 'buildid', '=', $build->Id, 1);
     $this->verify('testdiff', 'buildid', '=', $build->Id, 1);
     list($buildfailureid, $detailsid) = $this->verify_get_columns('buildfailure', ['id', 'detailsid'], 'buildid', '=', $build->Id, 1);
     $this->verify('buildfailure2argument', 'buildfailureid', '=', $buildfailureid, 1);
     $this->verify('buildfailuredetails', 'id', '=', $detailsid, 1);
     $noteids = $this->verify_get_rows('build2note', 'noteid', 'buildid', '=', $build->Id, 2);
     $this->verify('note', 'id', 'IN', $noteids, 2);
     $coveragefileids = $this->verify_get_rows('coverage', 'fileid', 'buildid', '=', $build->Id, 2);
     $this->verify('coveragefile', 'id', 'IN', $coveragefileids, 2);
     $dynamicanalysisid = $this->verify_get_rows('dynamicanalysis', 'id', 'buildid', '=', $build->Id, 1);
     $this->verify('dynamicanalysisdefect', 'dynamicanalysisid', '=', $dynamicanalysisid, 1);
     $testids = $this->verify_get_rows('build2test', 'testid', 'buildid', '=', $build->Id, 2);
     $this->verify('test', 'id', 'IN', $testids, 2);
     $this->verify('testmeasurement', 'testid', 'IN', $testids, 2);
     $imgids = $this->verify_get_rows('test2image', 'imgid', 'testid', 'IN', $testids, 2);
     $this->verify('image', 'id', 'IN', $imgids, 2);
     $updateid = $this->verify_get_rows('build2update', 'updateid', 'buildid', '=', $build->Id, 1);
     $this->verify('buildupdate', 'id', '=', $updateid, 1);
     $this->verify('updatefile', 'updateid', '=', $updateid, 1);
     $uploadfileids = $this->verify_get_rows('build2uploadfile', 'fileid', 'buildid', '=', $build->Id, 2);
     $this->verify('uploadfile', 'id', 'IN', $uploadfileids, 2);
     $labelid = $this->verify_get_rows('label2build', 'labelid', 'buildid', '=', $build->Id, 1);
     $this->verify('label', 'id', '=', $labelid, 1);
     $this->verify('label2buildfailure', 'labelid', '=', $labelid, 2);
     $this->verify('label2coveragefile', 'labelid', '=', $labelid, 3);
     $this->verify('label2dynamicanalysis', 'labelid', '=', $labelid, 1);
     $this->verify('label2test', 'labelid', '=', $labelid, 2);
     // Remove the build.
     remove_build($build->Id);
     // Check that everything was deleted properly.
     $this->verify('build', 'id', '=', $build->Id, 0, true);
     $this->verify('build2group', 'buildid', '=', $build->Id, 0, true);
     $this->verify('build2note', 'buildid', '=', $build->Id, 0, true);
     $this->verify('build2test', 'buildid', '=', $build->Id, 0, true);
     $this->verify('build2update', 'buildid', '=', $build->Id, 0, true);
     $this->verify('build2uploadfile', 'buildid', '=', $build->Id, 0, true);
     $this->verify('buildemail', 'buildid', '=', $build->Id, 0, true);
     $this->verify('builderror', 'buildid', '=', $build->Id, 0, true);
     $this->verify('builderrordiff', 'buildid', '=', $build->Id, 0, true);
     $this->verify('buildfailure', 'buildid', '=', $build->Id, 0, true);
     $this->verify('buildfailure2argument', 'buildfailureid', '=', $buildfailureid, 0, true);
     $this->verify('buildfailuredetails', 'id', '=', $detailsid, 1, true);
     $this->verify('buildinformation', 'buildid', '=', $build->Id, 0, true);
     $this->verify('buildtesttime', 'buildid', '=', $build->Id, 0, true);
     $this->verify('buildupdate', 'id', '=', $updateid, 1, true);
     $this->verify('configure', 'buildid', '=', $build->Id, 0, true);
     $this->verify('configureerror', 'buildid', '=', $build->Id, 0, true);
     $this->verify('configureerrordiff', 'buildid', '=', $build->Id, 0, true);
     $this->verify('coverage', 'buildid', '=', $build->Id, 0, true);
     $this->verify('coveragefile', 'id', 'IN', $coveragefileids, 1, true);
     $this->verify('coveragefilelog', 'buildid', '=', $build->Id, 0, true);
     $this->verify('coveragesummary', 'buildid', '=', $build->Id, 0, true);
     $this->verify('coveragesummarydiff', 'buildid', '=', $build->Id, 0, true);
     $this->verify('dynamicanalysis', 'buildid', '=', $build->Id, 0, true);
     $this->verify('dynamicanalysissummary', 'buildid', '=', $build->Id, 0, true);
     $this->verify('dynamicanalysisdefect', 'dynamicanalysisid', '=', $dynamicanalysisid, 0, true);
     $this->verify('image', 'id', 'IN', $imgids, 1, true);
     $this->verify('label2build', 'buildid', '=', $build->Id, 0, true);
     $this->verify('label2buildfailure', 'labelid', '=', $labelid, 1, true);
     $this->verify('label2coveragefile', 'labelid', '=', $labelid, 1, true);
     $this->verify('label2dynamicanalysis', 'labelid', '=', $labelid, 0, true);
     $this->verify('label2test', 'labelid', '=', $labelid, 0, true);
     $this->verify('note', 'id', 'IN', $noteids, 1, true);
     $this->verify('summaryemail', 'buildid', '=', $build->Id, 0, true);
     $this->verify('subproject2build', 'buildid', '=', $build->Id, 0, true);
     $this->verify('test', 'id', 'IN', $testids, 1, true);
     $this->verify('test2image', 'testid', 'IN', $testids, 1, true);
     $this->verify('testdiff', 'buildid', '=', $build->Id, 0, true);
     $this->verify('testmeasurement', 'testid', 'IN', $testids, 1, true);
     $this->verify('updatefile', 'updateid', '=', $updateid, 1, true);
     $this->verify('uploadfile', 'id', 'IN', $uploadfileids, 1, true);
 }
Exemplo n.º 8
0
 public static function LinkMembersToGroup(BuildGroup $bg)
 {
     foreach ($bg->Members() as $unit) {
         $unit->BuildGroup($bg);
     }
 }
Exemplo n.º 9
0
 /**
  * Called once when the project is initially created.
  */
 public function InitialSetup()
 {
     if (!$this->Id) {
         return false;
     }
     // Add the default groups.
     $BuildGroup = new BuildGroup();
     $BuildGroup->SetName('Nightly');
     $BuildGroup->SetDescription('Nightly builds');
     $BuildGroup->SetSummaryEmail(0);
     $this->AddBuildGroup($BuildGroup);
     $BuildGroup = new BuildGroup();
     $BuildGroup->SetName('Continuous');
     $BuildGroup->SetDescription('Continuous builds');
     $BuildGroup->SetSummaryEmail(0);
     $this->AddBuildGroup($BuildGroup);
     $BuildGroup = new BuildGroup();
     $BuildGroup->SetName('Experimental');
     $BuildGroup->SetDescription('Experimental builds');
     // default to "No Email" for the Experimental group
     $BuildGroup->SetSummaryEmail(2);
     $this->AddBuildGroup($BuildGroup);
     // Set up overview page to initially contain just the "Nightly" group.
     $groups = $this->GetBuildGroups();
     foreach ($groups as $group) {
         if ($group->GetName() == 'Nightly') {
             $buildgroupid = $group->GetId();
             $query = "INSERT INTO overview_components (projectid, buildgroupid, position, type)\n                    VALUES ('{$this->Id}', '{$buildgroupid}', '1', 'build')";
             pdo_query($query);
             add_last_sql_error('CreateProject :: DefaultOverview', $this->Id);
             break;
         }
     }
     // Add administrator to the project.
     $User = new User();
     $UserProject = new UserProject();
     $UserProject->Role = 2;
     $UserProject->EmailType = 3;
     // receive all emails
     $UserProject->ProjectId = $this->Id;
     $User->Id = 1;
     // administrator
     $User->AddProject($UserProject);
 }
Exemplo n.º 10
0
     $xml .= "<project_created>1</project_created>";
 } else {
     return;
 }
 // Add the default groups
 $BuildGroup = new BuildGroup();
 $BuildGroup->SetName('Nightly');
 $BuildGroup->SetDescription('Nightly builds');
 $BuildGroup->SetSummaryEmail(0);
 $Project->AddBuildGroup($BuildGroup);
 $BuildGroup = new BuildGroup();
 $BuildGroup->SetName('Continuous');
 $BuildGroup->SetDescription('Continuous builds');
 $BuildGroup->SetSummaryEmail(0);
 $Project->AddBuildGroup($BuildGroup);
 $BuildGroup = new BuildGroup();
 $BuildGroup->SetName('Experimental');
 $BuildGroup->SetDescription('Experimental builds');
 // default to "No Email" for the Experimental group
 $BuildGroup->SetSummaryEmail(2);
 $Project->AddBuildGroup($BuildGroup);
 // Set up overview page to initially contain just the "Nightly" group
 $groups = $Project->GetBuildGroups();
 foreach ($groups as $group) {
     if ($group->GetName() == "Nightly") {
         $buildgroupid = $group->GetId();
         $query = "INSERT INTO overview_components (projectid, buildgroupid, position, type)\n           VALUES ('{$projectid}', '{$buildgroupid}', '1', 'build')";
         pdo_query($query);
         add_last_sql_error("CreateProject :: DefaultOverview", $projectid);
         break;
     }
Exemplo n.º 11
0
 public function CancelUnits(array $resources, array $amounts, array $positions, $type)
 {
     $c = $this->User()->CurrentColony();
     $buildGroup = BuildGroup::FromList($resources, $amounts, $c, $positions);
     switch ($type) {
         case "SHIP":
             $rb = ResourceBuilder::GetShipListOfColony($c);
             break;
         case "DEFENSE":
             $rb = ResourceBuilder::GetDefenseListOfColony($c);
             break;
         case "MISSILE":
             $rb = ResourceBuilder::GetMissileListOfColony($c);
             break;
         case "BUILDING":
             return $this->CancelBuildings($resources, $positions);
             break;
     }
     foreach ($buildGroup->Members() as $item) {
         if (!$rb->BuildList()->ContainsBuildItem($item)) {
             throw new Exception("This item has already been deleted!");
         }
     }
     // Reimburse costs
     $reimbursedCosts = $buildGroup->ReimbursedCosts();
     $c->CurrentResources()->AddCost($reimbursedCosts);
     $c->UpdateResources();
     // Deduct the units
     $rb->BuildList()->DeductUnits($buildGroup);
     // Update Build times
     $rb->BuildList()->UpdateBuildTimes();
     // Update the database
     $rb->UpdateDatabase();
 }