예제 #1
0
        public ModelBuild EnsureBuild(BuildInfo buildInfo)
        {
            var modelBuildId = GetModelBuildId(buildInfo.Key);
            var modelBuild   = Context.ModelBuilds
                               .Where(x => x.Id == modelBuildId)
                               .FirstOrDefault();

            if (modelBuild is object)
            {
                return(modelBuild);
            }

            var prKey = buildInfo.PullRequestKey;

            modelBuild = new ModelBuild()
            {
                Id = modelBuildId,
                ModelBuildDefinitionId = EnsureBuildDefinition(buildInfo.DefinitionInfo).Id,
                GitHubOrganization     = prKey?.Organization,
                GitHubRepository       = prKey?.Repository,
                PullRequestNumber      = prKey?.Number,
                StartTime   = buildInfo.StartTime,
                FinishTime  = buildInfo.FinishTime,
                BuildNumber = buildInfo.Number,
            };
            Context.ModelBuilds.Add(modelBuild);
            Context.SaveChanges();
            return(modelBuild);
        }
예제 #2
0
 public static BuildInfo GetBuildInfo(ModelBuild build) =>
 new BuildInfo(
     GetBuildKey(build),
     GetBuildDefinitionInfo(build.ModelBuildDefinition),
     build.GitHubOrganization,
     build.GitHubRepository,
     build.PullRequestNumber,
     build.StartTime,
     build.FinishTime);
예제 #3
0
        private void DoSearchTimeline(
            Build build,
            Timeline timeline,
            ModelBuild modelBuild,
            ModelTimelineQuery modelTimelineQuery)
        {
            var searchText = modelTimelineQuery.SearchText;

            Logger.LogInformation($@"Text: ""{searchText}""");
            if (TriageContextUtil.IsProcessed(modelTimelineQuery, modelBuild))
            {
                Logger.LogInformation($@"Skipping");
                return;
            }

            var count = 0;

            foreach (var result in QueryUtil.SearchTimeline(build, timeline, text: searchText))
            {
                count++;

                var modelTimelineItem = new ModelTimelineItem()
                {
                    TimelineRecordName = result.TimelineRecord.Name,
                    Line               = result.Line,
                    ModelBuild         = modelBuild,
                    ModelTimelineQuery = modelTimelineQuery,
                    BuildNumber        = result.Build.GetBuildKey().Number,
                };
                Context.ModelTimelineItems.Add(modelTimelineItem);
            }

            var modelTimelineQueryComplete = new ModelTimelineQueryComplete()
            {
                ModelTimelineQuery = modelTimelineQuery,
                ModelBuild         = modelBuild,
            };

            Context.ModelTimelineQueryCompletes.Add(modelTimelineQueryComplete);

            try
            {
                Logger.LogInformation($@"Saving {count} jobs");
                Context.SaveChanges();
            }
            catch (Exception ex)
            {
                Logger.LogError($"Cannot save timeline complete: {ex.Message}");
            }
        }
예제 #4
0
 public bool IsProcessed(ModelTimelineQuery timelineQuery, ModelBuild modelBuild) =>
 Context.ModelTimelineQueryCompletes.Any(x =>
                                         x.ModelTimelineQueryId == timelineQuery.Id &&
                                         x.ModelBuildId == modelBuild.Id);
예제 #5
0
 public static BuildKey GetBuildKey(ModelBuild build) =>
 new BuildKey(build.ModelBuildDefinition.AzureOrganization, build.ModelBuildDefinition.AzureProject, build.BuildNumber);
예제 #6
0
 public static GitHubPullRequestKey?GetGitHubPullRequestKey(ModelBuild build) =>
 build.PullRequestNumber.HasValue
         ? (GitHubPullRequestKey?)new GitHubPullRequestKey(build.GitHubOrganization, build.GitHubRepository, build.PullRequestNumber.Value)
         : null;