private async Task <string> GetBody(HashSet <CodeFragment> contributions, string name)
        {
            var files = contributions.Select(f => f.Path).Distinct();

            var url = await _teamcityService.GetTeamCityBuildUrl(_buildId, "&tab=Inspection", false);

            var body =
                $@"<body style=""margin: 0; padding: 0;"">
 <table border=""1"" cellpadding=""0"" cellspacing=""0"" width=""100%"">
  <tr>
   <td>
    Hello {name},

    New errors have been introduced in the last <a href=""{url}"">daily inspection</a>.
Can you have a look please?
It seems you contributed to the following file(s):
{string.Join("\r\n", files)}

If you received this mail by error, please <a href=""mailto:[email protected],[email protected]&subject=Bad attribution"">notify us</a>.

Thank you,
Best regards,

Shift Quality Team
     </td>
  </tr>
 </table>
</body>";

            return(body);
        }
Exemple #2
0
        private async Task CheckCurrentBranch(DateTime now)
        {
            Console.WriteLine($"Checking status for build {_buildId}");
            var build = await _teamcityApi.GetTeamCityBuild(_buildId);

            var id       = GithubApi.GetBranchId(build.BranchName);
            var buildUrl = await _teamcityApi.GetTeamCityBuildUrl(_buildId, "", false);

            if (!id.HasValue)
            {
                Console.WriteLine($"{build.BranchName} is not a valid PR branch name");
                return;
            }

            var pullRequest = await _github.GetPullRequestAsync(id.Value);

            await CheckDerivationStatus(pullRequest, now, buildUrl);
        }
Exemple #3
0
        private async Task <HangoutCard> GetReportCard(DateTime utcNow)
        {
            var url = await _teamCityService.GetTeamCityBuildUrl(_buildId, "&tab=report_project117_Release_Note");

            var section = await CardBuilderHelper.GetLinkSectionToUrl(url, "Release notes");

            var sections = new [] { section };

            return(new HangoutCard
            {
                Header = CardBuilderHelper.GetCardHeader("<b>Daily release note</b>", utcNow, "https://icon-icons.com/icons2/560/PNG/128/Dynamic-Content_icon-icons.com_53724.png"),
                Sections = sections
            });
        }
Exemple #4
0
        private async Task <HangoutCardSection[]> GetSections(DuplicateComparator comparator)
        {
            var(newDuplicates, removedDuplicates, currentDuplicates) = comparator.GetComparison();

            var hasNew  = newDuplicates.Length > 0;
            var hasLess = removedDuplicates.Length > 0;

            Console.WriteLine($"Creating section of message for all {currentDuplicates.Length} duplications");
            var sections = new List <HangoutCardSection>
            {
                CardBuilderHelper.GetTextParagraphSection($"The total of duplications in our code base is <b>{currentDuplicates.Length}</b>.")
            };

            if (!hasNew && !hasLess)
            {
                Console.WriteLine("No change in duplications");
                sections.Add(CardBuilderHelper.GetTextParagraphSection("No change was found during the inspection"));
            }

            if (hasNew)
            {
                Console.WriteLine($"Adding section for the {newDuplicates.Length} new duplicates");
                sections.Add(CardBuilderHelper.GetTextParagraphSection(
                                 $"+ <b>{newDuplicates.Length}</b> duplication{(newDuplicates.Length == 1 ? "has" : "s have")} been introduced."));
            }

            if (hasLess)
            {
                Console.WriteLine($"Adding section for the {removedDuplicates.Length} removed duplicates");
                sections.Add(CardBuilderHelper.GetTextParagraphSection(
                                 $"- <b>{removedDuplicates.Length}</b> duplication{(removedDuplicates.Length == 1 ? "has" : "s have")} been removed."));
            }

            var url = await _teamcityService.GetTeamCityBuildUrl(_buildId, "&tab=Duplicator");

            sections.Add(await CardBuilderHelper.GetLinkSectionToUrl(url, "Go to TeamCity build"));

            return(sections.ToArray());
        }