@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace Harbormaster "BuildItem" with Lint/Unit messages

Summary:
Ref T8095.

Harbormaster has a `BuildItem` class, but it has no table and is unused. This was an earlier idea about representing lint/unit results and some other possible types of messages, but I think we want to be more specific than this.

Remove `BuildItem` and add `Lint` and `Unit` storage. These tables roughly parallel how we store lint/unit messages today, with some guesses about how where they'll go in the future.

Test Plan: Ran `bin/storage upgrade` and got a clean adjust out of it.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: hach-que, epriestley

Maniphest Tasks: T8095

Differential Revision: https://secure.phabricator.com/D13329

+229 -118
+14
resources/sql/autopatches/20150617.harbor.1.lint.sql
··· 1 + CREATE TABLE {$NAMESPACE}_harbormaster.harbormaster_buildlintmessage ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + buildTargetPHID VARBINARY(64) NOT NULL, 4 + path LONGTEXT NOT NULL, 5 + line INT UNSIGNED, 6 + characterOffset INT UNSIGNED, 7 + code VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL, 8 + severity VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL, 9 + name VARCHAR(255) COLLATE {$COLLATE_TEXT} NOT NULL, 10 + properties LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 11 + dateCreated INT UNSIGNED NOT NULL, 12 + dateModified INT UNSIGNED NOT NULL, 13 + KEY `key_target` (buildTargetPHID) 14 + ) ENGINE=INNODB, COLLATE {$COLLATE_TEXT};
+13
resources/sql/autopatches/20150617.harbor.2.unit.sql
··· 1 + CREATE TABLE {$NAMESPACE}_harbormaster.harbormaster_buildunitmessage ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + buildTargetPHID VARBINARY(64) NOT NULL, 4 + engine VARCHAR(255) COLLATE {$COLLATE_TEXT} NOT NULL, 5 + namespace VARCHAR(255) COLLATE {$COLLATE_TEXT} NOT NULL, 6 + name VARCHAR(255) COLLATE {$COLLATE_TEXT} NOT NULL, 7 + result VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL, 8 + duration DOUBLE, 9 + properties LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 10 + dateCreated INT UNSIGNED NOT NULL, 11 + dateModified INT UNSIGNED NOT NULL, 12 + KEY `key_target` (buildTargetPHID) 13 + ) ENGINE=INNODB, COLLATE {$COLLATE_TEXT};
+4 -6
src/__phutil_library_map__.php
··· 833 833 'HarbormasterBuildEngine' => 'applications/harbormaster/engine/HarbormasterBuildEngine.php', 834 834 'HarbormasterBuildFailureException' => 'applications/harbormaster/exception/HarbormasterBuildFailureException.php', 835 835 'HarbormasterBuildGraph' => 'applications/harbormaster/engine/HarbormasterBuildGraph.php', 836 - 'HarbormasterBuildItem' => 'applications/harbormaster/storage/build/HarbormasterBuildItem.php', 837 - 'HarbormasterBuildItemPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildItemPHIDType.php', 838 - 'HarbormasterBuildItemQuery' => 'applications/harbormaster/query/HarbormasterBuildItemQuery.php', 836 + 'HarbormasterBuildLintMessage' => 'applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php', 839 837 'HarbormasterBuildLog' => 'applications/harbormaster/storage/build/HarbormasterBuildLog.php', 840 838 'HarbormasterBuildLogPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php', 841 839 'HarbormasterBuildLogQuery' => 'applications/harbormaster/query/HarbormasterBuildLogQuery.php', ··· 867 865 'HarbormasterBuildTransaction' => 'applications/harbormaster/storage/HarbormasterBuildTransaction.php', 868 866 'HarbormasterBuildTransactionEditor' => 'applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php', 869 867 'HarbormasterBuildTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildTransactionQuery.php', 868 + 'HarbormasterBuildUnitMessage' => 'applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php', 870 869 'HarbormasterBuildViewController' => 'applications/harbormaster/controller/HarbormasterBuildViewController.php', 871 870 'HarbormasterBuildWorker' => 'applications/harbormaster/worker/HarbormasterBuildWorker.php', 872 871 'HarbormasterBuildable' => 'applications/harbormaster/storage/HarbormasterBuildable.php', ··· 4253 4252 'HarbormasterBuildEngine' => 'Phobject', 4254 4253 'HarbormasterBuildFailureException' => 'Exception', 4255 4254 'HarbormasterBuildGraph' => 'AbstractDirectedGraph', 4256 - 'HarbormasterBuildItem' => 'HarbormasterDAO', 4257 - 'HarbormasterBuildItemPHIDType' => 'PhabricatorPHIDType', 4258 - 'HarbormasterBuildItemQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 4255 + 'HarbormasterBuildLintMessage' => 'HarbormasterDAO', 4259 4256 'HarbormasterBuildLog' => array( 4260 4257 'HarbormasterDAO', 4261 4258 'PhabricatorPolicyInterface', ··· 4309 4306 'HarbormasterBuildTransaction' => 'PhabricatorApplicationTransaction', 4310 4307 'HarbormasterBuildTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 4311 4308 'HarbormasterBuildTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 4309 + 'HarbormasterBuildUnitMessage' => 'HarbormasterDAO', 4312 4310 'HarbormasterBuildViewController' => 'HarbormasterController', 4313 4311 'HarbormasterBuildWorker' => 'HarbormasterWorker', 4314 4312 'HarbormasterBuildable' => array(
-33
src/applications/harbormaster/phid/HarbormasterBuildItemPHIDType.php
··· 1 - <?php 2 - 3 - final class HarbormasterBuildItemPHIDType extends PhabricatorPHIDType { 4 - 5 - const TYPECONST = 'HMBI'; 6 - 7 - public function getTypeName() { 8 - return pht('Build Item'); 9 - } 10 - 11 - public function newObject() { 12 - return new HarbormasterBuildItem(); 13 - } 14 - 15 - protected function buildQueryForObjects( 16 - PhabricatorObjectQuery $query, 17 - array $phids) { 18 - 19 - return id(new HarbormasterBuildItemQuery()) 20 - ->withPHIDs($phids); 21 - } 22 - 23 - public function loadHandles( 24 - PhabricatorHandleQuery $query, 25 - array $handles, 26 - array $objects) { 27 - 28 - foreach ($handles as $phid => $handle) { 29 - $build_item = $objects[$phid]; 30 - } 31 - } 32 - 33 - }
-60
src/applications/harbormaster/query/HarbormasterBuildItemQuery.php
··· 1 - <?php 2 - 3 - final class HarbormasterBuildItemQuery 4 - extends PhabricatorCursorPagedPolicyAwareQuery { 5 - 6 - private $ids; 7 - private $phids; 8 - 9 - public function withIDs(array $ids) { 10 - $this->ids = $ids; 11 - return $this; 12 - } 13 - 14 - public function withPHIDs(array $phids) { 15 - $this->phids = $phids; 16 - return $this; 17 - } 18 - 19 - protected function loadPage() { 20 - $table = new HarbormasterBuildItem(); 21 - $conn_r = $table->establishConnection('r'); 22 - 23 - $data = queryfx_all( 24 - $conn_r, 25 - 'SELECT * FROM %T %Q %Q %Q', 26 - $table->getTableName(), 27 - $this->buildWhereClause($conn_r), 28 - $this->buildOrderClause($conn_r), 29 - $this->buildLimitClause($conn_r)); 30 - 31 - return $table->loadAllFromArray($data); 32 - } 33 - 34 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 35 - $where = array(); 36 - 37 - if ($this->ids) { 38 - $where[] = qsprintf( 39 - $conn_r, 40 - 'id IN (%Ld)', 41 - $this->ids); 42 - } 43 - 44 - if ($this->phids) { 45 - $where[] = qsprintf( 46 - $conn_r, 47 - 'phid in (%Ls)', 48 - $this->phids); 49 - } 50 - 51 - $where[] = $this->buildPagingClause($conn_r); 52 - 53 - return $this->formatWhereClause($where); 54 - } 55 - 56 - public function getQueryApplicationClass() { 57 - return 'PhabricatorHarbormasterApplication'; 58 - } 59 - 60 - }
-19
src/applications/harbormaster/storage/build/HarbormasterBuildItem.php
··· 1 - <?php 2 - 3 - final class HarbormasterBuildItem extends HarbormasterDAO { 4 - 5 - protected $name; 6 - 7 - protected function getConfiguration() { 8 - return array( 9 - self::CONFIG_AUX_PHID => true, 10 - self::CONFIG_NO_TABLE => true, 11 - ) + parent::getConfiguration(); 12 - } 13 - 14 - public function generatePHID() { 15 - return PhabricatorPHID::generateNewPHID( 16 - HarbormasterBuildItemPHIDType::TYPECONST); 17 - } 18 - 19 - }
+98
src/applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php
··· 1 + <?php 2 + 3 + final class HarbormasterBuildLintMessage 4 + extends HarbormasterDAO { 5 + 6 + protected $buildTargetPHID; 7 + protected $path; 8 + protected $line; 9 + protected $characterOffset; 10 + protected $code; 11 + protected $severity; 12 + protected $name; 13 + protected $properties = array(); 14 + 15 + private $buildTarget = self::ATTACHABLE; 16 + 17 + public static function initializeNewLintMessage( 18 + HarbormasterBuildTarget $build_target) { 19 + return id(new HarbormasterBuildLintMessage()) 20 + ->setBuildTargetPHID($build_target->getPHID()); 21 + } 22 + 23 + public static function newFromDictionary( 24 + HarbormasterBuildTarget $build_target, 25 + array $dict) { 26 + 27 + $obj = self::initializeNewLintMessage($build_target); 28 + 29 + $spec = array( 30 + 'path' => 'string', 31 + 'line' => 'optional int', 32 + 'char' => 'optional int', 33 + 'code' => 'string', 34 + 'severity' => 'string', 35 + 'name' => 'string', 36 + 'description' => 'optional string', 37 + ); 38 + 39 + // We're just going to ignore extra keys for now, to make it easier to 40 + // add stuff here later on. 41 + $dict = array_select_keys($dict, array_keys($spec)); 42 + PhutilTypeSpec::checkMap($dict, $spec); 43 + 44 + $obj->setPath($dict['path']); 45 + $obj->setLine(idx($dict, 'line')); 46 + $obj->setCharacterOffset(idx($dict, 'char')); 47 + $obj->setCode($dict['code']); 48 + $obj->setSeverity($dict['severity']); 49 + $obj->setName($dict['name']); 50 + 51 + $description = idx($dict, 'description'); 52 + if (strlen($description)) { 53 + $obj->setProperty('description', $description); 54 + } 55 + 56 + return $obj; 57 + } 58 + 59 + protected function getConfiguration() { 60 + return array( 61 + self::CONFIG_SERIALIZATION => array( 62 + 'properties' => self::SERIALIZATION_JSON, 63 + ), 64 + self::CONFIG_COLUMN_SCHEMA => array( 65 + 'path' => 'text', 66 + 'line' => 'uint32?', 67 + 'characterOffset' => 'uint32?', 68 + 'code' => 'text32', 69 + 'severity' => 'text32', 70 + 'name' => 'text255', 71 + ), 72 + self::CONFIG_KEY_SCHEMA => array( 73 + 'key_target' => array( 74 + 'columns' => array('buildTargetPHID'), 75 + ), 76 + ), 77 + ) + parent::getConfiguration(); 78 + } 79 + 80 + public function attachBuildTarget(HarbormasterBuildTarget $build_target) { 81 + $this->buildTarget = $build_target; 82 + return $this; 83 + } 84 + 85 + public function getBuildTarget() { 86 + return $this->assertAttached($this->buildTarget); 87 + } 88 + 89 + public function getProperty($key, $default = null) { 90 + return idx($this->properties, $key, $default); 91 + } 92 + 93 + public function setProperty($key, $value) { 94 + $this->properties[$key] = $value; 95 + return $this; 96 + } 97 + 98 + }
+100
src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
··· 1 + <?php 2 + 3 + final class HarbormasterBuildUnitMessage 4 + extends HarbormasterDAO { 5 + 6 + protected $buildTargetPHID; 7 + protected $engine; 8 + protected $namespace; 9 + protected $name; 10 + protected $result; 11 + protected $duration; 12 + protected $properties = array(); 13 + 14 + private $buildTarget = self::ATTACHABLE; 15 + 16 + public static function initializeNewUnitMessage( 17 + HarbormasterBuildTarget $build_target) { 18 + return id(new HarbormasterBuildLintMessage()) 19 + ->setBuildTargetPHID($build_target->getPHID()); 20 + } 21 + 22 + public static function newFromDictionary( 23 + HarbormasterBuildTarget $build_target, 24 + array $dict) { 25 + 26 + $obj = self::initializeNewUnitMessage($build_target); 27 + 28 + $spec = array( 29 + 'engine' => 'optional string', 30 + 'namespace' => 'optional string', 31 + 'name' => 'string', 32 + 'result' => 'string', 33 + 'duration' => 'optional float', 34 + 'path' => 'optional string', 35 + 'coverage' => 'optional string', 36 + ); 37 + 38 + // We're just going to ignore extra keys for now, to make it easier to 39 + // add stuff here later on. 40 + $dict = array_select_keys($dict, array_keys($spec)); 41 + PhutilTypeSpec::checkMap($dict, $spec); 42 + 43 + $obj->setEngine(idx($dict, 'engine', '')); 44 + $obj->setNamespace(idx($dict, 'namespace', '')); 45 + $obj->setName($dict['name']); 46 + $obj->setResult($dict['result']); 47 + $obj->setDuration(idx($dict, 'duration')); 48 + 49 + $path = idx($dict, 'path'); 50 + if (strlen($path)) { 51 + $obj->setProperty('path', $path); 52 + } 53 + 54 + $coverage = idx($dict, 'coverage'); 55 + if (strlen($coverage)) { 56 + $obj->setProperty('coverage', $coverage); 57 + } 58 + 59 + return $obj; 60 + } 61 + 62 + protected function getConfiguration() { 63 + return array( 64 + self::CONFIG_SERIALIZATION => array( 65 + 'properties' => self::SERIALIZATION_JSON, 66 + ), 67 + self::CONFIG_COLUMN_SCHEMA => array( 68 + 'engine' => 'text255', 69 + 'namespace' => 'text255', 70 + 'name' => 'text255', 71 + 'result' => 'text32', 72 + 'duration' => 'double?', 73 + ), 74 + self::CONFIG_KEY_SCHEMA => array( 75 + 'key_target' => array( 76 + 'columns' => array('buildTargetPHID'), 77 + ), 78 + ), 79 + ) + parent::getConfiguration(); 80 + } 81 + 82 + public function attachBuildTarget(HarbormasterBuildTarget $build_target) { 83 + $this->buildTarget = $build_target; 84 + return $this; 85 + } 86 + 87 + public function getBuildTarget() { 88 + return $this->assertAttached($this->buildTarget); 89 + } 90 + 91 + public function getProperty($key, $default = null) { 92 + return idx($this->properties, $key, $default); 93 + } 94 + 95 + public function setProperty($key, $value) { 96 + $this->properties[$key] = $value; 97 + return $this; 98 + } 99 + 100 + }