コード例 #1
0
        /// <summary>
        /// Parses a Scorecard object from a given CSV file
        /// </summary>
        /// <param name="filePath">Path to CSV file</param>
        /// <param name="config">Config object to use during parsing</param>
        /// <returns></returns>
        public async static Task <Scorecard> ParseScorecardFromCsvAsync(string filePath, Config config)
        {
            using (StreamReader file = new StreamReader(filePath))
            {
                Scorecard scorecard = new Scorecard
                {
                    RolloutWeightConfig = config.RolloutWeightConfig
                };

                string[] rolloutInfo = (await file.ReadLineAsync()).Split(',');
                scorecard.Repo = config.RepoConfigs.Find(r => r.Repo == rolloutInfo[0]);
                scorecard.Date = DateTimeOffset.Parse(rolloutInfo[1]);
                await file.ReadLineAsync();

                await file.ReadLineAsync();

                string[] rolloutScorecardSummary = (await file.ReadLineAsync()).Split(',');
                scorecard.TimeToRollout  = TimeSpan.Parse(rolloutScorecardSummary[0]);
                scorecard.CriticalIssues = int.Parse(rolloutScorecardSummary[1]);
                scorecard._githubIssuesUris.AddRange(GetIssueLinksFromString(rolloutScorecardSummary[2]));
                scorecard.Hotfixes = int.Parse(rolloutScorecardSummary[3]);
                scorecard._githubIssuesUris.AddRange(GetIssueLinksFromString(rolloutScorecardSummary[4]));
                scorecard.Rollbacks = int.Parse(rolloutScorecardSummary[5]);
                scorecard._githubIssuesUris.AddRange(GetIssueLinksFromString(rolloutScorecardSummary[6]));
                scorecard.Downtime = TimeSpan.Parse(rolloutScorecardSummary[7]);
                scorecard.Failure  = bool.Parse(rolloutScorecardSummary[8]);
                scorecard._githubIssuesUris.AddRange(GetIssueLinksFromString(rolloutScorecardSummary[9]));
                await file.ReadLineAsync();

                await file.ReadLineAsync();

                string[] buildBreakdownLines = (await file.ReadToEndAsync()).Split('\n');
                foreach (string breakdownLine in buildBreakdownLines)
                {
                    if (breakdownLine.Length == 0)
                    {
                        break;
                    }

                    BuildSummary buildSummary = new BuildSummary();

                    string[] breakdownSummary = breakdownLine.Split(',');
                    buildSummary.BuildNumber        = breakdownSummary[0];
                    buildSummary.Links.WebLink.Href = breakdownSummary[1];

                    ScorecardBuildBreakdown buildBreakdown = new ScorecardBuildBreakdown(buildSummary);

                    buildBreakdown.Score.TimeToRollout  = TimeSpan.Parse(breakdownSummary[2]);
                    buildBreakdown.Score.CriticalIssues = int.Parse(breakdownSummary[3]);
                    buildBreakdown.Score.Hotfixes       = int.Parse(breakdownSummary[4]);
                    buildBreakdown.Score.Rollbacks      = int.Parse(breakdownSummary[5]);
                    buildBreakdown.Score.Downtime       = TimeSpan.Parse(breakdownSummary[6]);

                    scorecard.BuildBreakdowns.Add(buildBreakdown);
                }

                return(scorecard);
            }
        }
コード例 #2
0
 public ScorecardBuildBreakdown(BuildSummary buildSummary)
 {
     BuildSummary = buildSummary;
     Score        = new Scorecard();
 }