Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Maestro/Client/src/Generated/Models/SubscriptionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ namespace Microsoft.DotNet.Maestro.Client.Models
{
public partial class SubscriptionData
{
public SubscriptionData(string channelName, string sourceRepository, string targetRepository, string targetBranch, Models.SubscriptionPolicy policy)
public SubscriptionData(string channelName, string sourceRepository, string targetRepository, string targetBranch, Models.SubscriptionPolicy policy, string failureNotificationTags)
{
ChannelName = channelName;
SourceRepository = sourceRepository;
TargetRepository = targetRepository;
TargetBranch = targetBranch;
Policy = policy;
PullRequestFailureNotificationTags = failureNotificationTags;
}

[JsonProperty("channelName")]
Expand Down
2 changes: 1 addition & 1 deletion src/Maestro/Maestro.DataProviders/MaestroBarClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Task<Channel> CreateChannelAsync(string name, string classification)
}

public Task<Subscription> CreateSubscriptionAsync(string channelName, string sourceRepo, string targetRepo, string targetBranch,
string updateFrequency, bool batchable, List<MergePolicy> mergePolicies)
string updateFrequency, bool batchable, List<MergePolicy> mergePolicies, string failureNotificationTags)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Maestro/SubscriptionActorService/MaestroBarClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Task<Channel> CreateChannelAsync(string name, string classification)
}

public Task<Subscription> CreateSubscriptionAsync(string channelName, string sourceRepo, string targetRepo, string targetBranch,
string updateFrequency, bool batchable, List<MergePolicy> mergePolicies)
string updateFrequency, bool batchable, List<MergePolicy> mergePolicies, string failureNotificationTags)
{
throw new NotImplementedException();
}
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.DotNet.Darc/src/Darc/Helpers/UxHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public static string GetTextSubscriptionDescription(Subscription subscription, I
subInfo.AppendLine($" - Update Frequency: {subscription.Policy.UpdateFrequency}");
subInfo.AppendLine($" - Enabled: {subscription.Enabled}");
subInfo.AppendLine($" - Batchable: {subscription.Policy.Batchable}");
subInfo.AppendLine($" - PR Failure Notification tags: {subscription.PullRequestFailureNotificationTags}");

IEnumerable<MergePolicy> policies = mergePolicies ?? subscription.Policy.MergePolicies;
subInfo.Append(UxHelpers.GetMergePoliciesDescription(policies, " "));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class AddSubscriptionPopUp : EditorPopUp
public string UpdateFrequency => _yamlData.UpdateFrequency;
public List<MergePolicy> MergePolicies => MergePoliciesPopUpHelpers.ConvertMergePolicies(_yamlData.MergePolicies);
public bool Batchable => bool.Parse(_yamlData.Batchable);
public string FailureNotificationTags => _yamlData.FailureNotificationTags;

public AddSubscriptionPopUp(string path,
ILogger logger,
Expand All @@ -37,7 +38,8 @@ public AddSubscriptionPopUp(string path,
IEnumerable<string> suggestedChannels,
IEnumerable<string> suggestedRepositories,
IEnumerable<string> availableUpdateFrequencies,
IEnumerable<string> availableMergePolicyHelp)
IEnumerable<string> availableMergePolicyHelp,
string failureNotificationTags)
: base(path)
{
_logger = logger;
Expand All @@ -49,7 +51,8 @@ public AddSubscriptionPopUp(string path,
TargetBranch = GetCurrentSettingForDisplay(targetBranch, "<required>", false),
UpdateFrequency = GetCurrentSettingForDisplay(updateFrequency, $"<'{string.Join("', '", Constants.AvailableFrequencies)}'>", false),
Batchable = GetCurrentSettingForDisplay(batchable.ToString(), batchable.ToString(), false),
MergePolicies = MergePoliciesPopUpHelpers.ConvertMergePolicies(mergePolicies)
MergePolicies = MergePoliciesPopUpHelpers.ConvertMergePolicies(mergePolicies),
FailureNotificationTags = failureNotificationTags
};

ISerializer serializer = new SerializerBuilder().Build();
Expand All @@ -63,7 +66,9 @@ public AddSubscriptionPopUp(string path,
new Line("A subscription maps a build of a source repository that has been applied to a specific channel", true),
new Line("onto a specific branch in a target repository. The subscription has a trigger (update frequency)", true),
new Line("and merge policy. If a subscription is batchable, no merge policy should be provided, and the", true),
new Line("set-repository-policies command should be used instead to set policies on the repository + branch level. ", true),
new Line("set-repository-policies command should be used instead to set policies at the repository and branch level. ", true),
new Line("For non-batched subscriptions, providing a list of semicolon-delineated GitHub tags will tag these", true),
new Line("logins when monitoring the pull requests, once one or more policy checks fail.", true),
new Line("For additional information about subscriptions, please see", true),
new Line("https://github.com/dotnet/arcade/blob/main/Documentation/BranchesChannelsAndSubscriptions.md", true),
new Line("", true),
Expand Down Expand Up @@ -151,6 +156,8 @@ public override int ProcessContents(IList<Line> contents)

_yamlData.Batchable = outputYamlData.Batchable;

_yamlData.FailureNotificationTags = outputYamlData.FailureNotificationTags;

_yamlData.UpdateFrequency = ParseSetting(outputYamlData.UpdateFrequency, _yamlData.UpdateFrequency, false);
if (string.IsNullOrEmpty(_yamlData.UpdateFrequency) ||
!Constants.AvailableFrequencies.Contains(_yamlData.UpdateFrequency, StringComparer.OrdinalIgnoreCase))
Expand All @@ -176,6 +183,7 @@ class SubscriptionData
public const string updateFrequencyElement = "Update Frequency";
public const string mergePolicyElement = "Merge Policies";
public const string batchableElement = "Batchable";
public const string failureNotificationTagsElement = "Pull Request Failure Notification Tags";

[YamlMember(Alias = channelElement, ApplyNamingConventions = false)]
public string Channel { get; set; }
Expand All @@ -197,6 +205,9 @@ class SubscriptionData

[YamlMember(Alias = mergePolicyElement, ApplyNamingConventions = false)]
public List<MergePolicyData> MergePolicies { get; set; }

[YamlMember(Alias = failureNotificationTagsElement, ApplyNamingConventions = false)]
public string FailureNotificationTags { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private List<Line> GetContentValues(IEnumerable<string> contents)
/// </summary>
/// <param name="currentValue">Current value of the setting</param>
/// <param name="defaultValue">Default value if the current setting value is empty</param>
/// <param name="isSecret">If secret and current value is empty, should display ***</param>
/// <param name="isSecret">If secret and current value is not empty, should display ***</param>
/// <returns>String to display</returns>
protected static string GetCurrentSettingForDisplay(string currentValue, string defaultValue, bool isSecret)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class UpdateSubscriptionPopUp : EditorPopUp

public bool Enabled => bool.Parse(_yamlData.Enabled);

public string FailureNotificationTags => _yamlData.FailureNotificationTags;

public List<MergePolicy> MergePolicies => MergePoliciesPopUpHelpers.ConvertMergePolicies(_yamlData.MergePolicies);

public UpdateSubscriptionPopUp(string path,
Expand All @@ -39,7 +41,8 @@ public UpdateSubscriptionPopUp(string path,
IEnumerable<string> suggestedChannels,
IEnumerable<string> suggestedRepositories,
IEnumerable<string> availableUpdateFrequencies,
IEnumerable<string> availableMergePolicyHelp)
IEnumerable<string> availableMergePolicyHelp,
string failureNotificationTags)
: base(path)
{
_logger = logger;
Expand All @@ -52,6 +55,7 @@ public UpdateSubscriptionPopUp(string path,
Batchable = GetCurrentSettingForDisplay(subscription.Policy.Batchable.ToString(), subscription.Policy.Batchable.ToString(), false),
UpdateFrequency = GetCurrentSettingForDisplay(subscription.Policy.UpdateFrequency.ToString(), subscription.Policy.UpdateFrequency.ToString(), false),
Enabled = GetCurrentSettingForDisplay(subscription.Enabled.ToString(), subscription.Enabled.ToString(), false),
FailureNotificationTags = GetCurrentSettingForDisplay(failureNotificationTags, failureNotificationTags, false)
};

_yamlData.MergePolicies = MergePoliciesPopUpHelpers.ConvertMergePolicies(subscription.Policy.MergePolicies);
Expand Down Expand Up @@ -157,6 +161,8 @@ public override int ProcessContents(IList<Line> contents)
return Constants.ErrorCode;
}

_yamlData.FailureNotificationTags = ParseSetting(outputYamlData.FailureNotificationTags, _yamlData.FailureNotificationTags, false);

return Constants.SuccessCode;
}

Expand All @@ -172,6 +178,7 @@ private class SubscriptionData
public const string updateFrequencyElement = "Update Frequency";
public const string mergePolicyElement = "Merge Policies";
public const string enabled = "Enabled";
public const string failureNotificationTagsElement = "Pull Request Failure Notification Tags";

[YamlMember(ApplyNamingConventions = false)]
public string Id { get; set; }
Expand All @@ -193,6 +200,9 @@ private class SubscriptionData

[YamlMember(Alias = mergePolicyElement, ApplyNamingConventions = false)]
public List<MergePolicyData> MergePolicies { get; set; }

[YamlMember(Alias = failureNotificationTagsElement, ApplyNamingConventions = false)]
public string FailureNotificationTags { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public override async Task<int> ExecuteAsync()
string targetBranch = GitHelpers.NormalizeBranchName(_options.TargetBranch);
string updateFrequency = _options.UpdateFrequency;
bool batchable = _options.Batchable;
string failureNotificationTags = _options.PullRequestFailureNotificationTags;

// If in quiet (non-interactive mode), ensure that all options were passed, then
// just call the remote API
Expand All @@ -117,6 +118,11 @@ public override async Task<int> ExecuteAsync()
}
else
{
if (!string.IsNullOrEmpty(failureNotificationTags) && batchable)
{
Logger.LogWarning("Failure Notification Tags may be set, but will not be used while in batched mode.");
}

// Grab existing subscriptions to get suggested values.
// TODO: When this becomes paged, set a max number of results to avoid
// pulling too much.
Expand All @@ -138,7 +144,8 @@ public override async Task<int> ExecuteAsync()
(await suggestedChannels).Select(suggestedChannel => suggestedChannel.Name),
(await suggestedRepos).SelectMany(subscription => new List<string> {subscription.SourceRepository, subscription.TargetRepository }).ToHashSet(),
Constants.AvailableFrequencies,
Constants.AvailableMergePolicyYamlHelp);
Constants.AvailableMergePolicyYamlHelp,
failureNotificationTags);

UxManager uxManager = new UxManager(_options.GitLocation, Logger);
int exitCode = _options.ReadStandardIn ? uxManager.ReadFromStdIn(addSubscriptionPopup) : uxManager.PopUp(addSubscriptionPopup);
Expand All @@ -153,6 +160,7 @@ public override async Task<int> ExecuteAsync()
updateFrequency = addSubscriptionPopup.UpdateFrequency;
mergePolicies = addSubscriptionPopup.MergePolicies;
batchable = addSubscriptionPopup.Batchable;
failureNotificationTags = addSubscriptionPopup.FailureNotificationTags;
}

try
Expand All @@ -169,6 +177,11 @@ public override async Task<int> ExecuteAsync()
Console.WriteLine($"Please use 'darc set-repository-policies --repo {targetRepository} --branch {targetBranch}' " +
$"to set policies.{Environment.NewLine}");
}

if (!string.IsNullOrEmpty(failureNotificationTags))
{
Console.WriteLine("Warning: Failure notification tags may be set, but are ignored on batched subscriptions.");
}
}

// Verify the target
Expand All @@ -193,7 +206,9 @@ public override async Task<int> ExecuteAsync()
targetBranch,
updateFrequency,
batchable,
mergePolicies);
mergePolicies,
failureNotificationTags);

Console.WriteLine($"Successfully created new subscription with id '{newSubscription.Id}'.");

// Prompt the user to trigger the subscription unless they have explicitly disallowed it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public override async Task<int> ExecuteAsync()
(await suggestedChannels).Select(suggestedChannel => suggestedChannel.Name),
(await suggestedRepos).SelectMany(subs => new List<string> { subscription.SourceRepository, subscription.TargetRepository }).ToHashSet(),
Constants.AvailableFrequencies,
Constants.AvailableMergePolicyYamlHelp);
Constants.AvailableMergePolicyYamlHelp,
subscription.PullRequestFailureNotificationTags);

UxManager uxManager = new UxManager(_options.GitLocation, Logger);

Expand All @@ -65,6 +66,7 @@ public override async Task<int> ExecuteAsync()
string updateFrequency = updateSubscriptionPopUp.UpdateFrequency;
bool batchable = updateSubscriptionPopUp.Batchable;
bool enabled = updateSubscriptionPopUp.Enabled;
string failureNotificationTags = updateSubscriptionPopUp.FailureNotificationTags;
List<MergePolicy> mergePolicies = updateSubscriptionPopUp.MergePolicies;

try
Expand All @@ -75,6 +77,7 @@ public override async Task<int> ExecuteAsync()
SourceRepository = sourceRepository ?? subscription.SourceRepository,
Enabled = enabled,
Policy = subscription.Policy,
PullRequestFailureNotificationTags = failureNotificationTags
};
subscriptionToUpdate.Policy.Batchable = batchable;
subscriptionToUpdate.Policy.UpdateFrequency = Enum.Parse<UpdateFrequency>(updateFrequency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class AddSubscriptionCommandLineOptions : CommandLineOptions
[Option("batchable", HelpText = "Make subscription batchable.")]
public bool Batchable { get; set; }

[Option("standard-automerge", HelpText = "Use standard auto-merge policies. GitHub ignores WIP, license/cla and auto-merge.config.enforce checks," +
[Option("standard-automerge", HelpText = "Use standard auto-merge policies. GitHub ignores WIP, license/cla and auto-merge.config.enforce checks, " +
"Azure DevOps ignores comment, reviewer and work item linking. Both will not auto-merge if changes are requested.")]
public bool StandardAutoMergePolicies { get; set; }

[Option("all-checks-passed", HelpText = "PR is automatically merged if there is at least one checks and all are passed. " +
"Optionally provide a comma separated list of ignored check with --ignore-checks.")]
[Option("all-checks-passed", HelpText = "PR is automatically merged if there is at least one check, and all checks have passed. " +
"Optionally provide a comma-separated list of ignored check with --ignore-checks.")]
public bool AllChecksSuccessfulMergePolicy { get; set; }

[Option("ignore-checks", Separator = ',', HelpText = "For use with --all-checks-passed. A set of checks that are ignored.")]
Expand All @@ -58,6 +58,9 @@ class AddSubscriptionCommandLineOptions : CommandLineOptions
[Option("no-trigger", SetName = "notrigger", HelpText = "Do not trigger the subscription on creation.")]
public bool NoTriggerOnCreate { get; set; }

[Option("failure-notification-tags", HelpText = "Semicolon-delineated list of GitHub tags (GitHub login or GitHub team) to notify in the case of non-batched subscription pull-request policy failure. Users must be publicly a member of the Microsoft org.", Default = "")]
public string PullRequestFailureNotificationTags { get; set; }

public override Operation GetOperation()
{
return new AddSubscriptionOperation(this);
Expand Down
6 changes: 4 additions & 2 deletions src/Microsoft.DotNet.Darc/src/DarcLib/Actions/Remote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ public Task<Subscription> CreateSubscriptionAsync(
string targetBranch,
string updateFrequency,
bool batchable,
List<MergePolicy> mergePolicies)
List<MergePolicy> mergePolicies,
string failureNotificationTags)
{
CheckForValidBarClient();
return _barClient.CreateSubscriptionAsync(
Expand All @@ -247,7 +248,8 @@ public Task<Subscription> CreateSubscriptionAsync(
targetBranch,
updateFrequency,
batchable,
mergePolicies);
mergePolicies,
failureNotificationTags);
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.DotNet.Darc/src/DarcLib/IBarClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Task<Subscription> CreateSubscriptionAsync(
string targetBranch,
string updateFrequency,
bool batchable,
List<MergePolicy> mergePolicies);
List<MergePolicy> mergePolicies,
string failureNotificationTags);

/// <summary>
/// Update an existing subscription
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.DotNet.Darc/src/DarcLib/IRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ Task<Subscription> CreateSubscriptionAsync(
string targetBranch,
string updateFrequency,
bool batchable,
List<MergePolicy> mergePolicies);
List<MergePolicy> mergePolicies,
string failureNotificationTags);

/// <summary>
/// Update an existing subscription
Expand Down
Loading