2 Commits
Author SHA1 Message Date
kislovdm 26807458dc ok
Create and publish a Docker image / build-and-push-image (push) Failing after 12s
2024-02-07 18:59:43 +03:00
kislovdm 703ee0fb87 ok
Create and publish a Docker image / build-and-push-image (push) Failing after 15s
2024-02-07 18:45:00 +03:00
4 changed files with 91 additions and 89 deletions
+7 -3
View File
@@ -64,12 +64,16 @@ public class App : IApp
return 0;
}
var isCodeFreezePeriod = _settings.ReleaseCodeFreeze != "true";
var isCodeFreezePeriod = _settings.ReleaseCodeFreeze == "true";
var periodDescription = isCodeFreezePeriod ? "Code-Freeze. Restrictions may apply" : "Normal";
Console.WriteLine($"Current period is {periodDescription}.");
approversDict = FilterApprovers(approversDict, isCodeFreezePeriod);
if (!await IsApproved(mergeRequest, commit, approversDict))
var filtered = FilterApprovers(approversDict, isCodeFreezePeriod);
if (!filtered.Any() && isCodeFreezePeriod)
{
filtered = FilterApprovers(approversDict, false);
}
if (!await IsApproved(mergeRequest, commit, filtered))
{
return -1;
}
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Approve.Checker.Gitlab;
public class ApproversDto
{
public bool? ForCodeFreeze { get; set; }
public bool ForCodeFreeze { get; set; }
public int CountApprovers { get; set; } = 1;
public List<string> Users { get; set; } = new();
}
@@ -7,104 +7,103 @@ using Newtonsoft.Json;
#pragma warning disable CS8618
namespace Approve.Checker.Gitlab.Dto
namespace Approve.Checker.Gitlab.Dto;
public sealed class CustomMergeRequest
{
public sealed class CustomMergeRequest
{
[JsonProperty("iid")]
public int Iid { get; set; }
[JsonProperty("iid")]
public int Iid { get; set; }
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("created_at")]
public DateTime CreatedAt { get; set; }
[JsonProperty("created_at")]
public DateTime CreatedAt { get; set; }
[JsonProperty("updated_at")]
public DateTime UpdatedAt { get; set; }
[JsonProperty("updated_at")]
public DateTime UpdatedAt { get; set; }
[JsonProperty("labels")]
public List<string> Labels { get; } = new List<string>();
[JsonProperty("labels")]
public List<string> Labels { get; } = new List<string>();
[JsonProperty("source_branch")]
public string SourceBranch { get; set; }
[JsonProperty("source_branch")]
public string SourceBranch { get; set; }
[JsonProperty("downvotes")]
public int Downvotes { get; set; }
[JsonProperty("downvotes")]
public int Downvotes { get; set; }
[JsonProperty("author")]
public Assignee Author { get; set; }
[JsonProperty("author")]
public Assignee Author { get; set; }
[JsonProperty("assignee")]
public Assignee Assignee { get; set; }
[JsonProperty("assignee")]
public Assignee Assignee { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("force_remove_source_branch")]
public bool? ForceRemoveSourceBranch { get; set; }
[JsonProperty("force_remove_source_branch")]
public bool? ForceRemoveSourceBranch { get; set; }
[JsonProperty("milestone")]
public Milestone Milestone { get; set; }
[JsonProperty("milestone")]
public Milestone Milestone { get; set; }
[JsonProperty("merge_status")]
public MergeStatus Status { get; set; }
[JsonProperty("merge_status")]
public MergeStatus Status { get; set; }
[JsonProperty("merge_commit_sha")]
public string MergeCommitSha { get; set; }
[JsonProperty("merge_commit_sha")]
public string MergeCommitSha { get; set; }
[JsonProperty("merge_when_pipeline_succeeds")]
public bool MergeWhenPipelineSucceeds { get; set; }
[JsonProperty("merge_when_pipeline_succeeds")]
public bool MergeWhenPipelineSucceeds { get; set; }
[JsonProperty("sha")]
public string Sha { get; set; }
[JsonProperty("sha")]
public string Sha { get; set; }
[JsonProperty("project_id")]
public string ProjectId { get; set; }
[JsonProperty("project_id")]
public string ProjectId { get; set; }
[JsonProperty("should_remove_source_branch")]
public bool? ShouldRemoveSourceBranch { get; set; }
[JsonProperty("should_remove_source_branch")]
public bool? ShouldRemoveSourceBranch { get; set; }
[JsonProperty("target_project_id")]
public int TargetProjectId { get; set; }
[JsonProperty("target_project_id")]
public int TargetProjectId { get; set; }
[JsonProperty("state")]
public MergeRequestState State { get; set; }
[JsonProperty("state")]
public MergeRequestState State { get; set; }
[JsonProperty("source_project_id")]
public int SourceProjectId { get; set; }
[JsonProperty("source_project_id")]
public int SourceProjectId { get; set; }
[JsonProperty("closed_at")]
public DateTime? ClosedAt { get; set; }
[JsonProperty("closed_at")]
public DateTime? ClosedAt { get; set; }
[JsonProperty("closed_by")]
public ClosedBy ClosedBy { get; set; }
[JsonProperty("closed_by")]
public ClosedBy ClosedBy { get; set; }
[JsonProperty("target_branch")]
public string TargetBranch { get; set; }
[JsonProperty("target_branch")]
public string TargetBranch { get; set; }
[JsonProperty("upvotes")]
public int Upvotes { get; set; }
[JsonProperty("upvotes")]
public int Upvotes { get; set; }
[JsonProperty("web_url")]
public string WebUrl { get; set; }
[JsonProperty("web_url")]
public string WebUrl { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("user_notes_count")]
public int UserNotesCount { get; set; }
[JsonProperty("user_notes_count")]
public int UserNotesCount { get; set; }
[JsonProperty("work_in_progress")]
public bool WorkInProgress { get; set; }
[JsonProperty("work_in_progress")]
public bool WorkInProgress { get; set; }
[JsonProperty("time_stats")]
public MergeRequestTimeStatistic TimeStats { get; set; }
[JsonProperty("time_stats")]
public MergeRequestTimeStatistic TimeStats { get; set; }
[JsonProperty("pipeline")]
public Pipeline Pipeline { get; set; }
[JsonProperty("pipeline")]
public Pipeline Pipeline { get; set; }
[JsonProperty("merged_by")]
public Assignee MergedBy { get; set; }
}
[JsonProperty("merged_by")]
public Assignee MergedBy { get; set; }
}
+14 -15
View File
@@ -1,18 +1,17 @@
namespace Approve.Checker.Gitlab
{
public class Settings
{
public string GitlabUrl = Environment.GetEnvironmentVariable("CI_SERVER_URL") ?? CheckAndThrow("CI_SERVER_URL");
public string GitlabToken = Environment.GetEnvironmentVariable("GITLAB_TOKEN") ?? CheckAndThrow("GITLAB_TOKEN");
public string MrPath = Environment.GetEnvironmentVariable("CI_OPEN_MERGE_REQUESTS")!;
public string ProjectId = Environment.GetEnvironmentVariable("CI_PROJECT_ID") ?? CheckAndThrow("CI_PROJECT_ID");
public string Approvers = Environment.GetEnvironmentVariable("APPROVERS_FILEPATH") ?? CheckAndThrow("APPROVERS_FILEPATH");
public string ReleaseCodeFreeze = Environment.GetEnvironmentVariable("RELEASE_CODEFREEZE") ?? "false";
namespace Approve.Checker.Gitlab;
private static string CheckAndThrow(string name)
{
Console.WriteLine($"Please define {name}");
throw new ArgumentException($"Please define {name}");
}
public class Settings
{
public string GitlabUrl = Environment.GetEnvironmentVariable("CI_SERVER_URL") ?? CheckAndThrow("CI_SERVER_URL");
public string GitlabToken = Environment.GetEnvironmentVariable("GITLAB_TOKEN") ?? CheckAndThrow("GITLAB_TOKEN");
public string MrPath = Environment.GetEnvironmentVariable("CI_OPEN_MERGE_REQUESTS")!;
public string ProjectId = Environment.GetEnvironmentVariable("CI_PROJECT_ID") ?? CheckAndThrow("CI_PROJECT_ID");
public string Approvers = Environment.GetEnvironmentVariable("APPROVERS_FILEPATH") ?? CheckAndThrow("APPROVERS_FILEPATH");
public string ReleaseCodeFreeze = Environment.GetEnvironmentVariable("RELEASE_CODEFREEZE") ?? "false";
private static string CheckAndThrow(string name)
{
Console.WriteLine($"Please define {name}");
throw new ArgumentException($"Please define {name}");
}
}