예제 #1
0
        /// <inheritdoc />
        public async Task <CheckRun> SubmitAsync(string owner, string repository, string sha, string cloneRoot,
                                                 string resourcePath)
        {
            _logger.LogInformation("SubmitAsync owner:{0} repository:{1} sha:{2} cloneRoot:{3} resourcePath:{4}",
                                   owner, repository, sha, cloneRoot, resourcePath);

            var startedAt = DateTimeOffset.Now;

            var buildDetails = _binaryLogProcessor.ProcessLog(resourcePath, cloneRoot);

            var logAnalyzerConfiguration = await _gitHubAppModelService.GetLogAnalyzerConfigurationAsync(owner, repository, sha);

            var annotations = CreateAnnotations(buildDetails, owner, repository, sha, logAnalyzerConfiguration);

            var checkRun = await SubmitCheckRun(annotations,
                                                owner,
                                                repository,
                                                sha,
                                                "MSBuildLog Analyzer",
                                                "MSBuildLog Analysis",
                                                "",
                                                startedAt,
                                                DateTimeOffset.Now).ConfigureAwait(false);

            _logger.LogInformation($"CheckRun Created - {checkRun.Url}");

            return(checkRun);
        }
        /// <inheritdoc />
        public async Task <CheckRun> SubmitAsync(string owner, string repository, string sha, string cloneRoot,
                                                 string resourcePath)
        {
            _logger.LogInformation("SubmitAsync owner:{0} repository:{1} sha:{2} cloneRoot:{3} resourcePath:{4}",
                                   owner, repository, sha, cloneRoot, resourcePath);

            var startedAt = DateTimeOffset.Now;

            try
            {
                var buildDetails = _binaryLogProcessor.ProcessLog(resourcePath, cloneRoot);

                var logAnalyzerConfiguration = await _gitHubAppModelService.GetLogAnalyzerConfigurationAsync(owner, repository, sha);

                var annotations = CreateAnnotations(buildDetails, owner, repository, sha, logAnalyzerConfiguration);

                var success = (annotations?.All(annotation => annotation.CheckWarningLevel != CheckWarningLevel.Failure) ?? true);

                var checkRun = await SubmitCheckRun(annotations,
                                                    owner,
                                                    repository,
                                                    sha,
                                                    CheckRunName,
                                                    CheckRunTitle,
                                                    "",
                                                    startedAt,
                                                    DateTimeOffset.Now, success).ConfigureAwait(false);

                _logger.LogInformation($"CheckRun Created - {checkRun.Url}");

                return(checkRun);
            }
            catch (Exception ex)
            {
                var checkRun = await SubmitCheckRun(null,
                                                    owner,
                                                    repository,
                                                    sha,
                                                    CheckRunName,
                                                    CheckRunTitle,
                                                    ex.ToString(),
                                                    startedAt,
                                                    DateTimeOffset.Now, false)
                               .ConfigureAwait(false);

                return(checkRun);
            }
        }