Ejemplo n.º 1
0
        public async Task ProcessPayload(CheckRunEventPayload payload, IGitHubManager gitHubManager, CancellationToken cancellationToken)
        {
            if (payload.Action != "rerequested")
            {
                return;
            }
            //nice thing about check runs we know they contain our pull request number in the title
            var prRegex = Regex.Match(payload.CheckRun.Name, "#([1-9][0-9]*)");

            if (prRegex.Success)
            {
                backgroundJobClient.Enqueue(() => ScanPullRequest(payload.Repository.Id, Convert.ToInt32(prRegex.Groups[1].Value, CultureInfo.InvariantCulture), JobCancellationToken.Null));
            }
            else
            {
                var now = DateTimeOffset.Now;
                var nmc = stringLocalizer[NaprLocalize];
                await gitHubManager.CreateCheckRun(payload.Repository.Id, new NewCheckRun
                {
                    CompletedAt = now,
                    StartedAt   = now,
                    Conclusion  = CheckConclusion.Neutral,
                    HeadBranch  = payload.CheckRun.CheckSuite.HeadBranch,
                    HeadSha     = payload.CheckRun.CheckSuite.HeadSha,
                    Name        = nmc,
                    Output      = new CheckRunOutput(nmc, String.Empty, null, null, null),
                    Status      = CheckStatus.Completed
                }, cancellationToken).ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
 public async Task ProcessPayload(CheckSuiteEventPayload payload, IGitHubManager gitHubManager, CancellationToken cancellationToken)
 {
     if (payload.Action != "requested" || payload.Action != "rerequested")
     {
         return;
     }
     if (payload.CheckSuite.PullRequests.Any())
     {
         foreach (var I in payload.CheckSuite.PullRequests)
         {
             backgroundJobClient.Enqueue(() => ScanPullRequest(payload.Repository.Id, I.Number, JobCancellationToken.Null));
         }
     }
     else
     {
         var now = DateTimeOffset.Now;
         var nmc = stringLocalizer[NaprLocalize];
         await gitHubManager.CreateCheckRun(payload.Repository.Id, new NewCheckRun
         {
             CompletedAt = now,
             StartedAt   = now,
             Conclusion  = CheckConclusion.Neutral,
             HeadBranch  = payload.CheckSuite.HeadBranch,
             HeadSha     = payload.CheckSuite.HeadSha,
             Name        = nmc,
             Output      = new CheckRunOutput(nmc, String.Empty, null, null, null),
             Status      = CheckStatus.Completed
         }, cancellationToken).ConfigureAwait(false);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a <see cref="CheckRun"/> for a <paramref name="checkSuiteSha"/> saying no pull requests could be associated with it
 /// </summary>
 /// <param name="repositoryId">The <see cref="Repository.Id"/></param>
 /// <param name="installationId">The <see cref="InstallationId.Id"/></param>
 /// <param name="gitHubManager">The <see cref="IGitHubManager"/> for the operation</param>
 /// <param name="checkSuiteSha">The <see cref="CheckSuite.HeadSha"/></param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
 /// <returns>A <see cref="Task"/> representing the running operation</returns>
 async Task CreateUnassociatedCheck(long repositoryId, long installationId, IGitHubManager gitHubManager, string checkSuiteSha, CancellationToken cancellationToken)
 {
     var now = DateTimeOffset.Now;
     var nmc = stringLocalizer["No Associated Pull Request"];
     await gitHubManager.CreateCheckRun(repositoryId, installationId, new NewCheckRun(nmc, checkSuiteSha)
     {
         CompletedAt = now,
         StartedAt   = now,
         Conclusion  = CheckConclusion.Neutral,
         Output      = new NewCheckRunOutput(nmc, String.Empty),
         Status      = CheckStatus.Completed
     }, cancellationToken).ConfigureAwait(false);
 }