Skip to content

Commit 510788e

Browse files
committed
Make symbolizer usable as a local tool
The server side symbolizer seems to have fallen over and maintaining it is too much hassle. Instead make it easy to run this tool from command line. Delete all server related code. Change-Id: Iaf92892e2497595708f40b2f73ba1808896d988f Reviewed-on: https://dart-review.googlesource.com/c/dart_ci/+/357627 Reviewed-by: William Hesse <[email protected]>
1 parent 3a501da commit 510788e

26 files changed

+4665
-4303
lines changed

github-label-notifier/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ FROM dart:stable AS build
55
# Resolve app dependencies.
66
WORKDIR /app
77
COPY functions/pubspec.* functions/
8-
COPY symbolizer symbolizer
98
WORKDIR /app/functions
109
RUN dart pub get
1110

github-label-notifier/functions/bin/server.dart

Lines changed: 15 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import 'package:gcp/gcp.dart';
1010
import 'package:sendgrid_mailer/sendgrid_mailer.dart' as sendgrid;
1111
import 'package:shelf/shelf.dart';
1212
import 'package:shelf_router/shelf_router.dart';
13-
import 'package:symbolizer/model.dart';
14-
import 'package:symbolizer/parser.dart';
15-
import 'package:symbolizer/bot.dart';
1613

1714
import 'package:github_label_notifier/github_utils.dart';
1815
import 'package:github_label_notifier/redirecting_http.dart';
@@ -178,19 +175,13 @@ Sent by dart-github-label-notifier.web.app
178175
/// The handler will search the body of the open issue for specific keywords
179176
/// and send emails to all subscribers to a specific label.
180177
Future<void> onIssueOpened(Map<String, dynamic> event) async {
181-
SymbolizationResult? symbolizedCrashes;
182-
183178
final repositoryName = event['repository']['full_name'];
184179
print("opened issue $repositoryName");
185180
final subscription = await db.lookupKeywordSubscription(repositoryName);
186181
if (subscription == null) return;
187-
if (subscription.keywords.contains('crash') &&
188-
containsCrash(event['issue']['body'])) {
189-
symbolizedCrashes = await _trySymbolize(event['issue']);
190-
}
191182

192-
final match = (symbolizedCrashes is SymbolizationResultOk &&
193-
symbolizedCrashes.results.isNotEmpty)
183+
final match = (subscription.keywords.contains('crash') &&
184+
_containsCrash(event['issue']['body']))
194185
? 'crash'
195186
: subscription.match(event['issue']['body']);
196187
if (match == null) {
@@ -210,51 +201,6 @@ Future<void> onIssueOpened(Map<String, dynamic> event) async {
210201

211202
final escape = htmlEscape.convert;
212203

213-
final symbolizedCrashesText = symbolizedCrashes
214-
?.when(
215-
ok: (results) {
216-
return [
217-
'',
218-
...results.expand((r) => [
219-
if (r.symbolized != null)
220-
'# engine ${r.engineBuild!.engineHash} ${r.engineBuild!.variant.pretty} crash'
221-
else
222-
'# engine crash',
223-
for (var note in r.notes)
224-
if (note.message != null)
225-
'# ${noteMessage[note.kind]}: ${note.message}'
226-
else
227-
'# ${noteMessage[note.kind]}',
228-
r.symbolized ?? r.crash.frames.toString(),
229-
]),
230-
''
231-
];
232-
},
233-
error: (note) => null)
234-
?.join('\n') ??
235-
'';
236-
237-
final symbolizedCrashesHtml = symbolizedCrashes
238-
?.when(
239-
ok: (results) {
240-
return results.expand((r) => [
241-
if (r.symbolized != null)
242-
'<p>engine ${r.engineBuild!.engineHash} ${r.engineBuild!.variant.pretty} crash</p>'
243-
else
244-
'<p>engine crash</p>',
245-
for (var note in r.notes)
246-
if (note.message != null)
247-
'<em>${noteMessage[note.kind]}: <pre>${escape(note.message!)}</pre></em>'
248-
else
249-
'<em>${noteMessage[note.kind]}</em>',
250-
'<pre>${escape(r.symbolized ?? r.crash.frames.toString())}</pre>',
251-
]);
252-
},
253-
error: (note) => null,
254-
)
255-
?.join('') ??
256-
'';
257-
258204
final personalizations = [
259205
for (final to in subscribers)
260206
sendgrid.Personalization([sendgrid.Address(to)])
@@ -270,7 +216,7 @@ $issueUrl
270216
Reported by $issueReporterUsername
271217
272218
Matches keyword: $match
273-
$symbolizedCrashesText
219+
274220
You are getting this mail because you are subscribed to label ${subscription.label}.
275221
--
276222
Sent by dart-github-label-notifier.web.app
@@ -279,7 +225,6 @@ Sent by dart-github-label-notifier.web.app
279225
<p><strong><a href="$issueUrl">${escape(issueTitle)}</a>&nbsp;(${escape(repositoryName)}#${escape(issueNumber.toString())})</strong></p>
280226
<p>Reported by <a href="$issueReporterUrl">${escape(issueReporterUsername)}</a></p>
281227
<p>Matches keyword: <b>$match</b></p>
282-
$symbolizedCrashesHtml
283228
<p>You are getting this mail because you are subscribed to label ${subscription.label}</p>
284229
<hr>
285230
<p>Sent by <a href="https://dart-github-label-notifier.web.app/">GitHub Label Notifier</a></p>
@@ -292,18 +237,7 @@ $symbolizedCrashesHtml
292237
}
293238

294239
Future<void> onIssueCommentCreated(Map<String, dynamic> event) async {
295-
final body = event['comment']['body'];
296-
297-
if (Bot.isCommand(body)) {
298-
final response = await http.post(
299-
Uri.http(symbolizerServer, 'command'),
300-
body: jsonEncode(event),
301-
);
302-
if (response.statusCode != HttpStatus.ok) {
303-
throw WebHookError(HttpStatus.internalServerError,
304-
'Failed to process ${event['comment']['html_url']}: ${response.body}');
305-
}
306-
}
240+
// Do nothing.
307241
}
308242

309243
class WebHookError {
@@ -324,23 +258,6 @@ String getRequiredHeaderValue(Request request, String header) {
324258
HttpStatus.badRequest, 'Missing $header header value.'));
325259
}
326260

327-
Future<SymbolizationResult> _trySymbolize(Map<String, dynamic> body) async {
328-
try {
329-
final response = await http
330-
.post(
331-
Uri.http(symbolizerServer, 'symbolize'),
332-
body: jsonEncode(body),
333-
)
334-
.timeout(const Duration(seconds: 20));
335-
return SymbolizationResult.fromJson(jsonDecode(response.body));
336-
} catch (e, st) {
337-
return SymbolizationResult.error(
338-
error: SymbolizationNote(
339-
kind: SymbolizationNoteKind.exceptionWhileSymbolizing,
340-
message: '$e\n$st'));
341-
}
342-
}
343-
344261
Future<http.Response> Function(Uri url,
345262
{Object? body,
346263
Encoding? encoding,
@@ -351,3 +268,14 @@ Future<http.Response> Function(Uri url,
351268
return http.post(newUrl, body: body, encoding: encoding, headers: headers);
352269
};
353270
}
271+
272+
final _androidCrashMarker =
273+
'*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***';
274+
275+
final _iosCrashMarker = RegExp(
276+
r'(Incident Identifier:\s+([A-F0-9]+-?)+)|(Exception Type:\s+EXC_CRASH)');
277+
278+
/// Returns [true] if the given text is likely to contain a crash.
279+
bool _containsCrash(String text) {
280+
return text.contains(_androidCrashMarker) || text.contains(_iosCrashMarker);
281+
}

github-label-notifier/functions/pubspec.lock

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ packages:
1313
dependency: transitive
1414
description:
1515
name: _fe_analyzer_shared
16-
sha256: "0816708f5fbcacca324d811297153fe3c8e047beb5c6752e12292d2974c17045"
16+
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
1717
url: "https://pub.dev"
1818
source: hosted
19-
version: "62.0.0"
19+
version: "64.0.0"
2020
analyzer:
2121
dependency: transitive
2222
description:
2323
name: analyzer
24-
sha256: "21862995c9932cd082f89d72ae5f5e2c110d1a0204ad06e4ebaee8307b76b834"
24+
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
2525
url: "https://pub.dev"
2626
source: hosted
27-
version: "6.0.0"
27+
version: "6.2.0"
2828
args:
2929
dependency: transitive
3030
description:
@@ -33,14 +33,6 @@ packages:
3333
url: "https://pub.dev"
3434
source: hosted
3535
version: "2.4.2"
36-
asn1lib:
37-
dependency: transitive
38-
description:
39-
name: asn1lib
40-
sha256: b74e3842a52c61f8819a1ec8444b4de5419b41a7465e69d4aa681445377398b0
41-
url: "https://pub.dev"
42-
source: hosted
43-
version: "1.4.1"
4436
async:
4537
dependency: "direct main"
4638
description:
@@ -73,14 +65,6 @@ packages:
7365
url: "https://pub.dev"
7466
source: hosted
7567
version: "3.1.1"
76-
corsac_jwt:
77-
dependency: transitive
78-
description:
79-
name: corsac_jwt
80-
sha256: f86d1a1ad7d4db5727ae5d68dfd4437cbcf62daabe920190fcd5425457f5f377
81-
url: "https://pub.dev"
82-
source: hosted
83-
version: "1.0.0-nullsafety.1"
8468
coverage:
8569
dependency: transitive
8670
description:
@@ -97,14 +81,6 @@ packages:
9781
url: "https://pub.dev"
9882
source: hosted
9983
version: "3.0.3"
100-
dart_internal:
101-
dependency: transitive
102-
description:
103-
name: dart_internal
104-
sha256: dae3976f383beddcfcd07ad5291a422df2c8c0a8a03c52cda63ac7b4f26e0f4e
105-
url: "https://pub.dev"
106-
source: hosted
107-
version: "0.2.8"
10884
file:
10985
dependency: transitive
11086
description:
@@ -113,14 +89,6 @@ packages:
11389
url: "https://pub.dev"
11490
source: hosted
11591
version: "7.0.0"
116-
freezed_annotation:
117-
dependency: transitive
118-
description:
119-
name: freezed_annotation
120-
sha256: aeac15850ef1b38ee368d4c53ba9a847e900bb2c53a4db3f6881cbb3cb684338
121-
url: "https://pub.dev"
122-
source: hosted
123-
version: "2.2.0"
12492
frontend_server_client:
12593
dependency: transitive
12694
description:
@@ -137,14 +105,6 @@ packages:
137105
url: "https://pub.dev"
138106
source: hosted
139107
version: "0.1.1"
140-
github:
141-
dependency: transitive
142-
description:
143-
name: github
144-
sha256: "5640619ae3780877fe62b7837b41343350acc845c528f7b339c34c60745f2cdd"
145-
url: "https://pub.dev"
146-
source: hosted
147-
version: "9.15.1"
148108
glob:
149109
dependency: transitive
150110
description:
@@ -217,14 +177,6 @@ packages:
217177
url: "https://pub.dev"
218178
source: hosted
219179
version: "0.6.7"
220-
json_annotation:
221-
dependency: transitive
222-
description:
223-
name: json_annotation
224-
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
225-
url: "https://pub.dev"
226-
source: hosted
227-
version: "4.8.1"
228180
lints:
229181
dependency: "direct dev"
230182
description:
@@ -289,22 +241,6 @@ packages:
289241
url: "https://pub.dev"
290242
source: hosted
291243
version: "1.8.3"
292-
pedantic:
293-
dependency: transitive
294-
description:
295-
name: pedantic
296-
sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602"
297-
url: "https://pub.dev"
298-
source: hosted
299-
version: "1.11.1"
300-
pointycastle:
301-
dependency: transitive
302-
description:
303-
name: pointycastle
304-
sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c"
305-
url: "https://pub.dev"
306-
source: hosted
307-
version: "3.7.3"
308244
pool:
309245
dependency: transitive
310246
description:
@@ -321,14 +257,6 @@ packages:
321257
url: "https://pub.dev"
322258
source: hosted
323259
version: "2.1.4"
324-
rsa_pkcs:
325-
dependency: transitive
326-
description:
327-
name: rsa_pkcs
328-
sha256: "17a52b0c010319f0d4c7bcc635eb89e2efeaec44975b3fb45f850b350a2b0513"
329-
url: "https://pub.dev"
330-
source: hosted
331-
version: "2.0.1"
332260
sendgrid_mailer:
333261
dependency: "direct main"
334262
description:
@@ -425,13 +353,6 @@ packages:
425353
url: "https://pub.dev"
426354
source: hosted
427355
version: "1.2.0"
428-
symbolizer:
429-
dependency: "direct main"
430-
description:
431-
path: "../symbolizer"
432-
relative: true
433-
source: path
434-
version: "0.0.1"
435356
term_glyph:
436357
dependency: transitive
437358
description:
@@ -513,4 +434,4 @@ packages:
513434
source: hosted
514435
version: "3.1.2"
515436
sdks:
516-
dart: ">=3.0.0 <3.2.0"
437+
dart: ">=3.0.0 <4.0.0"

github-label-notifier/functions/pubspec.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ dependencies:
2020
shelf: ^1.4.0
2121
shelf_router: ^1.1.3
2222
test: any
23-
symbolizer:
24-
path: ../symbolizer
2523

2624
dev_dependencies:
2725
lints: ^2.0.1

0 commit comments

Comments
 (0)