@@ -7,20 +7,206 @@ public function getAPIMethodName() {
77 return 'harbormaster.sendmessage ' ;
88 }
99
10+ public function getMethodSummary () {
11+ return pht (
12+ 'Send a message about the status of a build target to Harbormaster, ' .
13+ 'notifying the application of build results in an external system. ' );
14+ }
15+
1016 public function getMethodDescription () {
17+ $ messages = HarbormasterMessageType::getAllMessages ();
18+
19+ $ head_type = pht ('Constant ' );
20+ $ head_desc = pht ('Description ' );
21+ $ head_key = pht ('Key ' );
22+ $ head_type = pht ('Type ' );
23+ $ head_name = pht ('Name ' );
24+
25+ $ rows = array ();
26+ $ rows [] = "| {$ head_type } | {$ head_desc } | " ;
27+ $ rows [] = '|--------------|--------------| ' ;
28+ foreach ($ messages as $ message ) {
29+ $ description = HarbormasterMessageType::getMessageDescription ($ message );
30+ $ rows [] = "| ` {$ message }` | {$ description } | " ;
31+ }
32+ $ message_table = implode ("\n" , $ rows );
33+
34+ $ rows = array ();
35+ $ rows [] = "| {$ head_key } | {$ head_type } | {$ head_desc } | " ;
36+ $ rows [] = '|-------------|--------------|--------------| ' ;
37+ $ unit_spec = HarbormasterBuildUnitMessage::getParameterSpec ();
38+ foreach ($ unit_spec as $ key => $ parameter ) {
39+ $ type = idx ($ parameter , 'type ' );
40+ $ type = str_replace ('| ' , pht (' or ' ), $ type );
41+ $ description = idx ($ parameter , 'description ' );
42+ $ rows [] = "| ` {$ key }` | // {$ type }// | {$ description } | " ;
43+ }
44+ $ unit_table = implode ("\n" , $ rows );
45+
46+ $ rows = array ();
47+ $ rows [] = "| {$ head_key } | {$ head_name } | {$ head_desc } | " ;
48+ $ rows [] = '|-------------|--------------|--------------| ' ;
49+ $ results = ArcanistUnitTestResult::getAllResultCodes ();
50+ foreach ($ results as $ result_code ) {
51+ $ name = ArcanistUnitTestResult::getResultCodeName ($ result_code );
52+ $ description = ArcanistUnitTestResult::getResultCodeDescription (
53+ $ result_code );
54+ $ rows [] = "| ` {$ result_code }` | ** {$ name }** | {$ description } | " ;
55+ }
56+ $ result_table = implode ("\n" , $ rows );
57+
58+ $ rows = array ();
59+ $ rows [] = "| {$ head_key } | {$ head_type } | {$ head_desc } | " ;
60+ $ rows [] = '|-------------|--------------|--------------| ' ;
61+ $ lint_spec = HarbormasterBuildLintMessage::getParameterSpec ();
62+ foreach ($ lint_spec as $ key => $ parameter ) {
63+ $ type = idx ($ parameter , 'type ' );
64+ $ type = str_replace ('| ' , pht (' or ' ), $ type );
65+ $ description = idx ($ parameter , 'description ' );
66+ $ rows [] = "| ` {$ key }` | // {$ type }// | {$ description } | " ;
67+ }
68+ $ lint_table = implode ("\n" , $ rows );
69+
70+ $ rows = array ();
71+ $ rows [] = "| {$ head_key } | {$ head_name } | " ;
72+ $ rows [] = '|-------------|--------------| ' ;
73+ $ severities = ArcanistLintSeverity::getLintSeverities ();
74+ foreach ($ severities as $ key => $ name ) {
75+ $ rows [] = "| ` {$ key }` | ** {$ name }** | " ;
76+ }
77+ $ severity_table = implode ("\n" , $ rows );
78+
79+ $ valid_unit = array (
80+ array (
81+ 'name ' => 'PassingTest ' ,
82+ 'result ' => ArcanistUnitTestResult::RESULT_PASS ,
83+ ),
84+ array (
85+ 'name ' => 'FailingTest ' ,
86+ 'result ' => ArcanistUnitTestResult::RESULT_FAIL ,
87+ ),
88+ );
89+
90+ $ valid_lint = array (
91+ array (
92+ 'name ' => pht ('Syntax Error ' ),
93+ 'code ' => 'EXAMPLE1 ' ,
94+ 'severity ' => ArcanistLintSeverity::SEVERITY_ERROR ,
95+ 'path ' => 'path/to/example.c ' ,
96+ 'line ' => 17 ,
97+ 'char ' => 3 ,
98+ ),
99+ array (
100+ 'name ' => pht ('Not A Haiku ' ),
101+ 'code ' => 'EXAMPLE2 ' ,
102+ 'severity ' => ArcanistLintSeverity::SEVERITY_ERROR ,
103+ 'path ' => 'path/to/source.cpp ' ,
104+ 'line ' => 23 ,
105+ 'char ' => 1 ,
106+ 'description ' => pht (
107+ 'This function definition is not a haiku. ' ),
108+ ),
109+ );
110+
111+ $ json = new PhutilJSON ();
112+ $ valid_unit = $ json ->encodeAsList ($ valid_unit );
113+ $ valid_lint = $ json ->encodeAsList ($ valid_lint );
114+
11115 return pht (
12- 'Send a message to a build target, notifying it of results in an ' .
13- 'external system. ' );
116+ "Send a message about the status of a build target to Harbormaster, " .
117+ "notifying the application of build results in an external system. " .
118+ "\n\n" .
119+ "Sending Messages \n" .
120+ "================ \n" .
121+ "If you run external builds, you can use this method to publish build " .
122+ "results back into Harbormaster after the external system finishes work " .
123+ "or as it makes progress. " .
124+ "\n\n" .
125+ "The simplest way to use this method is to call it once after the " .
126+ "build finishes with a `pass` or `fail` message. This will record the " .
127+ "build result, and continue the next step in the build if the build was " .
128+ "waiting for a result. " .
129+ "\n\n" .
130+ "When you send a status message about a build target, you can " .
131+ "optionally include detailed `lint` or `unit` results alongside the " .
132+ "message. See below for details. " .
133+ "\n\n" .
134+ "If you want to report intermediate results but a build hasn't " .
135+ "completed yet, you can use the `work` message. This message doesn't " .
136+ "have any direct effects, but allows you to send additional data to " .
137+ "update the progress of the build target. The target will continue " .
138+ "waiting for a completion message, but the UI will update to show the " .
139+ "progress which has been made. " .
140+ "\n\n" .
141+ "Message Types \n" .
142+ "============= \n" .
143+ "When you send Harbormaster a message, you must include a `type`, " .
144+ "which describes the overall state of the build. For example, use " .
145+ "`pass` to tell Harbomaster that a build completed successfully. " .
146+ "\n\n" .
147+ "Supported message types are: " .
148+ "\n\n" .
149+ "%s " .
150+ "\n\n" .
151+ "Unit Results \n" .
152+ "============ \n" .
153+ "You can report test results alongside a message. The simplest way to " .
154+ "do this is to report all the results alongside a `pass` or `fail` " .
155+ "message, but you can also send a `work` message to report intermediate " .
156+ "results. \n\n" .
157+ "To provide unit test results, pass a list of results in the `unit` " .
158+ "parameter. Each result shoud be a dictionary with these keys: " .
159+ "\n\n" .
160+ "%s " .
161+ "\n\n" .
162+ "The `result` parameter recognizes these test results: " .
163+ "\n\n" .
164+ "%s " .
165+ "\n\n" .
166+ "This is a simple, valid value for the `unit` parameter. It reports " .
167+ "one passing test and one failing test: \n\n" .
168+ "\n\n" .
169+ "```lang=json \n" .
170+ "%s " .
171+ "``` " .
172+ "\n\n" .
173+ "Lint Results \n" .
174+ "============ \n" .
175+ "Like unit test results, you can report lint results alongside a " .
176+ "message. The `lint` parameter should contain results as a list of " .
177+ "dictionaries with these keys: " .
178+ "\n\n" .
179+ "%s " .
180+ "\n\n" .
181+ "The `severity` parameter recognizes these severity levels: " .
182+ "\n\n" .
183+ "%s " .
184+ "\n\n" .
185+ "This is a simple, valid value for the `lint` parameter. It reports one " .
186+ "error and one warning: " .
187+ "\n\n" .
188+ "```lang=json \n" .
189+ "%s " .
190+ "``` " .
191+ "\n\n" ,
192+ $ message_table ,
193+ $ unit_table ,
194+ $ result_table ,
195+ $ valid_unit ,
196+ $ lint_table ,
197+ $ severity_table ,
198+ $ valid_lint );
14199 }
15200
16201 protected function defineParamTypes () {
17- $ type_const = $ this ->formatStringConstants (array ('pass ' , 'fail ' ));
202+ $ messages = HarbormasterMessageType::getAllMessages ();
203+ $ type_const = $ this ->formatStringConstants ($ messages );
18204
19205 return array (
20206 'buildTargetPHID ' => 'required phid ' ,
21- 'lint ' => 'optional list<wild> ' ,
22- 'unit ' => 'optional list<wild> ' ,
23207 'type ' => 'required ' .$ type_const ,
208+ 'unit ' => 'optional list<wild> ' ,
209+ 'lint ' => 'optional list<wild> ' ,
24210 );
25211 }
26212
0 commit comments