Skip to content

Commit

Permalink
Put repo processing in try/catch (#8976)
Browse files Browse the repository at this point in the history
* Put repo processing in try/catch
* Remove repo list and docs from ci trigger
  • Loading branch information
hallipr authored Sep 16, 2024
1 parent 56c5f87 commit 8d731be
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,43 +56,50 @@ protected override async Task ProcessAsync(CancellationToken cancellationToken)

foreach (string ownerAndRepository in repositories)
{
string owner = ownerAndRepository.Split('/')[0];
string repository = ownerAndRepository.Split('/')[1];

string[] knownBlobs = await this.processor.GetRunBlobNamesAsync(ownerAndRepository, runMinTime, runMaxTime, cancellationToken);

WorkflowRunsResponse listRunsResponse = await this.client.Actions.Workflows.Runs.List(owner, repository, new WorkflowRunsRequest
try
{
Created = $"{runMinTime:o}..{runMaxTime:o}",
Status = CheckRunStatusFilter.Completed,
});
string owner = ownerAndRepository.Split('/')[0];
string repository = ownerAndRepository.Split('/')[1];

var skipCount = 0;
var enqueueCount = 0;
string[] knownBlobs = await this.processor.GetRunBlobNamesAsync(ownerAndRepository, runMinTime, runMaxTime, cancellationToken);

foreach (WorkflowRun run in listRunsResponse.WorkflowRuns)
{
var blobName = this.processor.GetRunBlobName(run);

if (knownBlobs.Contains(blobName, StringComparer.InvariantCultureIgnoreCase))
WorkflowRunsResponse listRunsResponse = await this.client.Actions.Workflows.Runs.List(owner, repository, new WorkflowRunsRequest
{
Created = $"{runMinTime:o}..{runMaxTime:o}",
Status = CheckRunStatusFilter.Completed,
});

var skipCount = 0;
var enqueueCount = 0;

foreach (WorkflowRun run in listRunsResponse.WorkflowRuns)
{
skipCount++;
continue;
var blobName = this.processor.GetRunBlobName(run);

if (knownBlobs.Contains(blobName, StringComparer.InvariantCultureIgnoreCase))
{
skipCount++;
continue;
}

var queueMessage = new RunCompleteQueueMessage
{
Owner = owner,
Repository = repository,
RunId = run.Id
};

this.logger.LogInformation("Enqueuing missing run {Repository} {RunId} for processing", ownerAndRepository, run.Id);
await this.queue.EnqueueMessageAsync(queueMessage);
enqueueCount++;
}

var queueMessage = new RunCompleteQueueMessage
{
Owner = owner,
Repository = repository,
RunId = run.Id
};

this.logger.LogInformation("Enqueuing missing run {Repository} {RunId} for processing", ownerAndRepository, run.Id);
await this.queue.EnqueueMessageAsync(queueMessage);
enqueueCount++;
this.logger.LogInformation("Enqueued {EnqueueCount} missing runs, skipped {SkipCount} existing runs in repository {Repository}", enqueueCount, skipCount, ownerAndRepository);
}
catch (Exception ex)
{
this.logger.LogError(ex, "Error processing repository {Repository}", ownerAndRepository);
}

this.logger.LogInformation("Enqueued {EnqueueCount} missing runs, skipped {SkipCount} existing runs in repository {Repository}", enqueueCount, skipCount, ownerAndRepository);
}
}

Expand Down
3 changes: 3 additions & 0 deletions tools/pipeline-witness/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ pr:
paths:
include:
- tools/pipeline-witness
exclude:
- tools/pipeline-witness/monitored-repos.json
- tools/pipeline-witness/docs/*

extends:
template: ../../eng/pipelines/templates/stages/archetype-sdk-tool-azure-webapp.yml
Expand Down

0 comments on commit 8d731be

Please sign in to comment.