public override void Execute() { foreach (RepositoryConfig repositoryConfig in _cmdLine.RepositoriesList) { HtmlPageCreator emailBody = new HtmlPageCreator($"Pull Requests older than 3 months in {repositoryConfig.Name}"); bool hasFoundPRs = FindStalePRsInRepo(repositoryConfig, emailBody); if (hasFoundPRs) { // send the email EmailSender.SendEmail(_cmdLine.EmailToken, _cmdLine.FromEmail, emailBody.GetContent(), repositoryConfig.ToEmail, repositoryConfig.CcEmail, $"Pull Requests older than 3 months in {repositoryConfig.Name}", _log); } } }
public override void Execute() { foreach (var repositoryConfig in _cmdLine.RepositoriesList) { HtmlPageCreator emailBody = new HtmlPageCreator($"Customer reported issues with invalid state in {repositoryConfig.Repo}"); bool hasFoundIssues = ValidateCustomerReportedIssues(repositoryConfig, emailBody); if (hasFoundIssues) { // send the email EmailSender.SendEmail(_cmdLine.EmailToken, _cmdLine.FromEmail, emailBody.GetContent(), repositoryConfig.ToEmail, repositoryConfig.CcEmail, $"Customer reported issues in invalid state in repo {repositoryConfig.Repo}", _log); } } }
public override void Execute() { foreach (var repositoryConfig in _cmdLine.RepositoriesList) { HtmlPageCreator emailBody = new HtmlPageCreator($"Issues in expired milestones for {repositoryConfig.Repo}"); bool hasFoundIssues = GetIssuesInBacklogMilestones(repositoryConfig, emailBody); if (hasFoundIssues) { // send the email EmailSender.SendEmail(_cmdLine.EmailToken, _cmdLine.FromEmail, emailBody.GetContent(), repositoryConfig.ToEmail, repositoryConfig.CcEmail, $"Issues in old milestone for {repositoryConfig.Repo}", _log); } } }
protected override async Task ExecuteCoreAsync(ReportExecutionContext context) { foreach (RepositoryConfiguration repositoryConfiguration in context.RepositoryConfigurations) { HtmlPageCreator emailBody = new HtmlPageCreator($"Issues in expired milestones for {repositoryConfiguration.Name}"); bool hasFoundIssues = FindIssuesInPastDuesMilestones(context, repositoryConfiguration, emailBody); if (hasFoundIssues) { // send the email EmailSender.SendEmail(context.SendGridToken, context.FromAddress, emailBody.GetContent(), repositoryConfiguration.ToEmail, repositoryConfiguration.CcEmail, $"Issues in old milestone for {repositoryConfiguration.Name}", context.Log); } } }
protected override async Task ExecuteCoreAsync(ReportExecutionContext context) { foreach (RepositoryConfiguration repositoryConfiguration in context.RepositoryConfigurations) { await ExecuteWithRetryAsync(3, async() => { HtmlPageCreator emailBody = new HtmlPageCreator($"Test related issues in {repositoryConfiguration.Name}"); bool hasFoundIssues = FindIssuesWithLabel(context, repositoryConfiguration, emailBody); if (hasFoundIssues) { // send the email EmailSender.SendEmail(context.SendGridToken, context.FromAddress, emailBody.GetContent(), repositoryConfiguration.ToEmail, repositoryConfiguration.CcEmail, $"Issues with test-* labels for {repositoryConfiguration.Name}", Logger); } }); } }
public override void Execute() { _log.LogInformation($"Started function execution: {DateTime.Now}"); var storageConnString = Environment.GetEnvironmentVariable("AzureWebJobsStorage"); BlobServiceClient bsc = new BlobServiceClient(storageConnString); BlobContainerClient bcc = bsc.GetBlobContainerClient(ContainerName); // create the container bcc.CreateIfNotExists(); _log.LogInformation("Storage account accessed"); DateTime to = DateTime.UtcNow; DateTime fromTwoDaysBack = DateTime.UtcNow.AddDays(-2); foreach (var repositoryConfig in _cmdLine.RepositoriesList) { // retrieve the last accessed time for this repository BlobClient bc = bcc.GetBlobClient($"{repositoryConfig.Owner}_{repositoryConfig.Repo}"); DateTime lastDateRun = DateTime.UtcNow.AddDays(-1); try { string content = StreamHelpers.GetContentAsString(bc.Download().Value.Content); lastDateRun = DateTime.Parse(content); } catch { } _log.LogInformation("Last processed date for {0} is {1}", repositoryConfig, lastDateRun); string owner = repositoryConfig.Owner; string repo = repositoryConfig.Repo; _log.LogInformation("Processing repository {0}\\{1}", owner, repo); HtmlPageCreator emailBody = new HtmlPageCreator($"New items in {repo}"); SearchIssuesRequest requestOptions = new SearchIssuesRequest() { #pragma warning disable CS0618 // Type or member is obsolete Created = DateRange.Between(fromTwoDaysBack, to), #pragma warning restore CS0618 // Type or member is obsolete Order = SortDirection.Descending, Repos = new RepositoryCollection() }; requestOptions.Repos.Add(owner, repo); // get the issues requestOptions.Is = new[] { IssueIsQualifier.Open, IssueIsQualifier.Issue }; RetrieveItemsFromGitHub(requestOptions, lastDateRun, emailBody, "New issues"); // get the PRs requestOptions.Is = new[] { IssueIsQualifier.Open, IssueIsQualifier.PullRequest }; RetrieveItemsFromGitHub(requestOptions, lastDateRun, emailBody, "New PRs"); emailBody.AddContent($"<p>Last checked range: {lastDateRun} -> {to} </p>"); _log.LogInformation("Sending email..."); // send the email EmailSender.SendEmail(_cmdLine.EmailToken, _cmdLine.FromEmail, emailBody.GetContent(), repositoryConfig.ToEmail, repositoryConfig.CcEmail, $"New issues in the {repo} repo as of {to.ToShortDateString()}", _log); _log.LogInformation("Email sent..."); bc.Upload(StreamHelpers.GetStreamForString(to.ToUniversalTime().ToString()), overwrite: true); _log.LogInformation($"Persisted last event time for {repositoryConfig.Owner}\\{repositoryConfig.Repo} as {to}"); } }
protected override async Task ExecuteCoreAsync(ReportExecutionContext context) { foreach (RepositoryConfiguration repositoryConfiguration in context.RepositoryConfigurations) { HtmlPageCreator emailBody = new HtmlPageCreator($"Pull Requests older than 3 months in {repositoryConfiguration.Name}"); bool hasFoundPRs = FindStalePRsInRepo(context, repositoryConfiguration, emailBody); if (hasFoundPRs) { // send the email EmailSender.SendEmail(context.SendGridToken, context.FromAddress, emailBody.GetContent(), repositoryConfiguration.ToEmail, repositoryConfiguration.CcEmail, $"Pull Requests older than 3 months in {repositoryConfiguration.Name}", context.Log); } } }
protected override async Task ExecuteCoreAsync(ReportExecutionContext context) { Logger.LogInformation($"Started function execution: {DateTime.Now}"); var storageConnString = Environment.GetEnvironmentVariable("AzureWebJobsStorage"); BlobServiceClient bsc = new BlobServiceClient(storageConnString); BlobContainerClient bcc = bsc.GetBlobContainerClient(ContainerName); // create the container bcc.CreateIfNotExists(); Logger.LogInformation("Storage account accessed"); DateTime to = DateTime.UtcNow; foreach (RepositoryConfiguration repositoryConfiguration in context.RepositoryConfigurations) { await ExecuteWithRetryAsync(3, async() => { // retrieve the last accessed time for this repository BlobClient bc = bcc.GetBlobClient($"{repositoryConfiguration.Owner}_{repositoryConfiguration.Name}"); DateTime lastDateRun = DateTime.UtcNow.AddDays(-1); try { string content = StreamHelpers.GetContentAsString(bc.Download().Value.Content); lastDateRun = DateTime.Parse(content); } catch { } Logger.LogInformation("Last processed date for {0} is {1}", repositoryConfiguration, lastDateRun); string owner = repositoryConfiguration.Owner; string repo = repositoryConfiguration.Name; Logger.LogInformation("Processing repository {0}\\{1}", owner, repo); HtmlPageCreator emailBody = new HtmlPageCreator($"New items in {repo}"); // get new issues RetrieveNewItems(context, CreateQueryForNewItems(repositoryConfiguration, IssueIsQualifier.Issue), lastDateRun, emailBody, "New issues"); // get new PRs RetrieveNewItems(context, CreateQueryForNewItems(repositoryConfiguration, IssueIsQualifier.PullRequest), lastDateRun, emailBody, "New PRs"); // get needs attention issues RetrieveNeedsAttentionIssues(context, repositoryConfiguration, emailBody); emailBody.AddContent($"<p>Last checked range: {lastDateRun} -> {to} </p>"); Logger.LogInformation("Sending email..."); // send the email EmailSender.SendEmail(context.SendGridToken, context.FromAddress, emailBody.GetContent(), repositoryConfiguration.ToEmail, repositoryConfiguration.CcEmail, $"New issues in the {repo} repo as of {to.ToShortDateString()}", Logger); Logger.LogInformation("Email sent..."); bc.Upload(StreamHelpers.GetStreamForString(to.ToUniversalTime().ToString()), overwrite: true); Logger.LogInformation($"Persisted last event time for {repositoryConfiguration.Owner}\\{repositoryConfiguration.Name} as {to}"); }); } }
protected override async Task ExecuteCoreAsync(ReportExecutionContext context) { foreach (RepositoryConfiguration repositoryConfiguration in context.RepositoryConfigurations) { HtmlPageCreator emailBody = new HtmlPageCreator($"Customer reported issues with invalid state in {repositoryConfiguration.Name}"); bool hasFoundIssues = ValidateCustomerReportedIssues(context, repositoryConfiguration, emailBody); if (hasFoundIssues) { // send the email EmailSender.SendEmail(context.SendGridToken, context.FromAddress, emailBody.GetContent(), repositoryConfiguration.ToEmail, repositoryConfiguration.CcEmail, $"Customer reported issues in invalid state in repo {repositoryConfiguration.Name}", context.Log); } } }