示例#1
0
        public ModelBuild AddBuild(string data, ModelBuildDefinition def)
        {
            var parts  = data.Split("|");
            var number = GetPartOrNull(parts, 0) is { } part?int.Parse(part) : BuildCount++;

            var dt = GetPartOrNull(parts, 3);
            var br = GetPartOrNull(parts, 4);

            var build = new ModelBuild()
            {
                Id                                            = TriageContextUtil.GetModelBuildId(new BuildKey(def.AzureOrganization, def.AzureProject, number)),
                BuildNumber                                   = number,
                GitHubOrganization                            = GetPartOrNull(parts, 1),
                GitHubRepository                              = GetPartOrNull(parts, 2),
                AzureOrganization                             = def.AzureOrganization,
                AzureProject                                  = def.AzureProject,
                QueueTime                                     = dt is object?DateTime.ParseExact(dt, "yyyy-MM-dd", null) : (DateTime?)null,
                                                  BuildResult = br is object?Enum.Parse <BuildResult>(br) : (BuildResult?)null,
                                                                    ModelBuildDefinition = def,
                                                                    DefinitionId         = def.DefinitionId,
                                                                    DefinitionName       = def.DefinitionName,
            };

            Context.ModelBuilds.Add(build);
            return(build);
        }
示例#2
0
        public async Task <IActionResult> OnGet()
        {
            if (!(Number is { } number))
            {
                return(Page());
            }

            var buildKey     = GetBuildKey(number);
            var project      = buildKey.Project;
            var organization = buildKey.Organization;
            var buildId      = TriageContextUtil.GetModelBuildId(buildKey);

            var modelBuild = await PopulateBuildInfo();

            await PopulateTimeline();
            await PopulateTests();

            return(Page());

            async Task <ModelBuild?> PopulateBuildInfo()
            {
                var modelBuild = await TriageContextUtil
                                 .GetModelBuildQuery(buildKey)
                                 .Include(x => x.ModelGitHubIssues)
                                 .FirstOrDefaultAsync();

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

                BuildUri       = DevOpsUtil.GetBuildUri(organization, project, number);
                BuildResult    = modelBuild.BuildResult ?? BuildResult.None;
                Repository     = $"{modelBuild.GitHubOrganization}/{modelBuild.GitHubRepository}";
                RepositoryUri  = $"https://{modelBuild.GitHubOrganization}/{modelBuild.GitHubRepository}";
                DefinitionName = modelBuild.DefinitionName;
                TargetBranch   = modelBuild.GitHubTargetBranch;
                GitHubIssues.Clear();
                GitHubIssues.AddRange(modelBuild.ModelGitHubIssues.Select(x => x.GetGitHubIssueKey()));

                if (modelBuild.PullRequestNumber is { } prNumber)
                {
                    PullRequestKey = new GitHubPullRequestKey(
                        modelBuild.GitHubOrganization,
                        modelBuild.GitHubRepository,
                        prNumber);
                }

                return(modelBuild);
            }

            async Task PopulateTimeline()
            {
                var query = TriageContextUtil
                            .Context
                            .ModelTimelineIssues
                            .Where(x => x.ModelBuildId == buildId)
                            .Include(x => x.ModelBuild);

                TimelineIssuesDisplay = await TimelineIssuesDisplay.Create(
                    query,
                    includeBuildColumn : false,
                    includeIssueTypeColumn : true,
                    includeAttemptColumn : true);

                Attempts = TimelineIssuesDisplay.Issues.Count > 0
                    ? TimelineIssuesDisplay.Issues.Max(x => x.Attempt)
                    : 1;
            }

            async Task PopulateTests()
            {
                var query = TriageContextUtil
                            .Context
                            .ModelTestResults
                            .Where(x => x.ModelBuildId == buildId)
                            .Include(x => x.ModelTestRun)
                            .Include(x => x.ModelBuild);
                var modelTestResults = await query.ToListAsync();

                TestResultsDisplay = new TestResultsDisplay(modelTestResults)
                {
                    IncludeBuildColumn        = false,
                    IncludeBuildKindColumn    = false,
                    IncludeTestFullNameColumn = true,
                    IncludeTestFullNameLinks  = true,
                    IncludeErrorMessageColumn = true,
                };

                if (modelBuild is object)
                {
                    TestResultsDisplay.BuildsRequest = new SearchBuildsRequest()
                    {
                        Definition = modelBuild.DefinitionName,
                        Started    = new DateRequestValue(dayQuery: 7)
                    };
                }
            }
        }