Skip to content

Commit

Permalink
Add logs for autosubmit triage (#1987)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyonghan authored Jul 18, 2022
1 parent ccf20c0 commit b6282f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions auto_submit/lib/requests/check_pull_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,23 @@ class CheckPullRequest extends AuthenticatedRequestHandler {
log.info('There are no requests in the queue');
return Response.ok('No requests in the queue.');
}
log.info('Processing ${receivedMessages.length} messages');
ValidationService validationService = ValidationService(config);
final List<Future<void>> futures = <Future<void>>[];

for (pub.ReceivedMessage message in receivedMessages) {
final String messageData = message.message!.data!;
final rawBody = json.decode(String.fromCharCodes(base64.decode(messageData))) as Map<String, dynamic>;
final PullRequest pullRequest = PullRequest.fromJson(rawBody);
log.info('Processing PR: $pullRequest');
if (processingLog.contains(pullRequest.number)) {
// Ack duplicate.
log.info('Ack the duplicated message : ${message.ackId!}.');
await pubsub.acknowledge('auto-submit-queue-sub', message.ackId!);
continue;
} else {
await approver.approve(pullRequest);
log.info('Approved pull request: $pullRequest');
processingLog.add(pullRequest.number!);
}
futures.add(validationService.processMessage(pullRequest, message.ackId!, pubsub));
Expand Down
2 changes: 2 additions & 0 deletions auto_submit/lib/service/validation_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ValidationService {
/// Processes a pub/sub message associated with PullRequest event.
Future<void> processMessage(github.PullRequest messagePullRequest, String ackId, PubSub pubsub) async {
if (!await shouldProcess(messagePullRequest)) {
log.info('Shout not process $messagePullRequest, and ack the message.');
await pubsub.acknowledge('auto-submit-queue-sub', ackId);
return;
}
Expand Down Expand Up @@ -119,6 +120,7 @@ class ValidationService {
// If we got to this point it means we are ready to submit the PR.
bool processed = await processMerge(config, result, messagePullRequest);
if (processed) await pubsub.acknowledge('auto-submit-queue-sub', ackId);
log.info('Ack the processed message : $ackId.');
}

/// Merges the commit if the PullRequest passes all the validations.
Expand Down

0 comments on commit b6282f2

Please sign in to comment.