Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2ec14c48a | ||
|
|
558319bbaa | ||
|
|
909bb2350e | ||
|
|
8392e499b2 | ||
|
|
d35ccc3980 | ||
|
|
26807458dc | ||
|
|
703ee0fb87 | ||
|
|
ee39e29269 | ||
|
|
d6c7792a6c | ||
|
|
c92e6f5ee9 | ||
|
|
8d56dbf2b3 | ||
|
|
1d127cadd3 | ||
|
|
97e81c3af4 | ||
|
|
071aa73015 |
@@ -4,6 +4,8 @@ name: Create and publish a Docker image
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
|
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
|
||||||
env:
|
env:
|
||||||
@@ -1,93 +1,3 @@
|
|||||||
# aproove.checker
|
# aproove.checker
|
||||||
|
|
||||||
|
Gitlab approve checker
|
||||||
|
|
||||||
## Getting started
|
|
||||||
|
|
||||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
||||||
|
|
||||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
||||||
|
|
||||||
## Add your files
|
|
||||||
|
|
||||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
||||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
||||||
|
|
||||||
```
|
|
||||||
cd existing_repo
|
|
||||||
git remote add origin https://gitlab.dev002.local/systems/multibus/tools/aproove.checker.git
|
|
||||||
git branch -M master
|
|
||||||
git push -uf origin master
|
|
||||||
```
|
|
||||||
|
|
||||||
## Integrate with your tools
|
|
||||||
|
|
||||||
- [ ] [Set up project integrations](https://gitlab.dev002.local/systems/multibus/tools/aproove.checker/-/settings/integrations)
|
|
||||||
|
|
||||||
## Collaborate with your team
|
|
||||||
|
|
||||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
||||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
||||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
||||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
||||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
||||||
|
|
||||||
## Test and Deploy
|
|
||||||
|
|
||||||
Use the built-in continuous integration in GitLab.
|
|
||||||
|
|
||||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
||||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
||||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
||||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
||||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
# Editing this README
|
|
||||||
|
|
||||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
||||||
|
|
||||||
## Suggestions for a good README
|
|
||||||
|
|
||||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
||||||
|
|
||||||
## Name
|
|
||||||
Choose a self-explaining name for your project.
|
|
||||||
|
|
||||||
## Description
|
|
||||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
||||||
|
|
||||||
## Badges
|
|
||||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
||||||
|
|
||||||
## Visuals
|
|
||||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
||||||
|
|
||||||
## Support
|
|
||||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
||||||
|
|
||||||
## Roadmap
|
|
||||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
State if you are open to contributions and what your requirements are for accepting them.
|
|
||||||
|
|
||||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
||||||
|
|
||||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
||||||
|
|
||||||
## Authors and acknowledgment
|
|
||||||
Show your appreciation to those who have contributed to the project.
|
|
||||||
|
|
||||||
## License
|
|
||||||
For open source projects, say how it is licensed.
|
|
||||||
|
|
||||||
## Project status
|
|
||||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
||||||
|
|||||||
+67
-13
@@ -23,11 +23,6 @@ public class App : IApp
|
|||||||
ServerCertificateCustomValidationCallback = (_, _, _, _) => true
|
ServerCertificateCustomValidationCallback = (_, _, _, _) => true
|
||||||
};
|
};
|
||||||
_settings = new Settings();
|
_settings = new Settings();
|
||||||
if (string.IsNullOrEmpty(_settings.GitlabUrl))
|
|
||||||
{
|
|
||||||
Console.WriteLine("CI_SERVER_URL is not defined.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_client = new GitLabClient(_settings.GitlabUrl, _settings.GitlabToken, httpHandler);
|
_client = new GitLabClient(_settings.GitlabUrl, _settings.GitlabToken, httpHandler);
|
||||||
_customClient = new GitlabCustomClient(_settings.GitlabUrl, _settings.GitlabToken, httpHandler);
|
_customClient = new GitlabCustomClient(_settings.GitlabUrl, _settings.GitlabToken, httpHandler);
|
||||||
}
|
}
|
||||||
@@ -44,11 +39,55 @@ public class App : IApp
|
|||||||
Console.WriteLine("Not in MergeRequest. Exiting.");
|
Console.WriteLine("Not in MergeRequest. Exiting.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
var mrId = int.Parse(_settings.MrPath.Split('!')[1]);
|
var approversDict = ParseApprovers();
|
||||||
|
if (approversDict is null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var mrIdStr = _settings.MrPath.Split('!')[1];
|
||||||
|
if (mrIdStr.Contains(","))
|
||||||
|
{
|
||||||
|
mrIdStr = mrIdStr.Split(',')[0];
|
||||||
|
}
|
||||||
|
var mrId = int.Parse(mrIdStr);
|
||||||
|
|
||||||
var mergeRequest = await _client.MergeRequests.GetAsync(_settings.ProjectId, mrId);
|
var mergeRequest = await _client.MergeRequests.GetAsync(_settings.ProjectId, mrId);
|
||||||
var commit = await _client.Commits.GetAsync(_settings.ProjectId, mergeRequest.Sha);
|
var commit = await _client.Commits.GetAsync(_settings.ProjectId, mergeRequest.Sha);
|
||||||
if (!await IsApproved(mergeRequest, commit))
|
if (mergeRequest.Labels.Contains("renovate") &&
|
||||||
|
string.Equals(mergeRequest.Author.Username, "kislovdm", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
var message = $"Одобряю MR renovate без аппрува.";
|
||||||
|
|
||||||
|
await _client.MergeRequests.CreateNoteAsync(mergeRequest.ProjectId, mergeRequest.Iid,
|
||||||
|
new CreateMergeRequestNoteRequest(message));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var mrsToSameRelease = await _customClient.GetMergeRequestsByTargetBranch(mergeRequest.TargetBranch);
|
||||||
|
var sameMrs = mrsToSameRelease.Where(f => f.SourceBranch == mergeRequest.SourceBranch &&
|
||||||
|
f.TargetBranch == mergeRequest.TargetBranch &&
|
||||||
|
f.State == MergeRequestState.Merged).ToArray();
|
||||||
|
if (sameMrs.Any())
|
||||||
|
{
|
||||||
|
var mrUrls = string.Join("\r\n", sameMrs.Select(f=>f.WebUrl));
|
||||||
|
var message = $"Аналогичный MR ({sameMrs.First().WebUrl}) уже был одобрен и влит, автоматически одобряю текущий:\r\n{mrUrls}";
|
||||||
|
|
||||||
|
await _client.MergeRequests.CreateNoteAsync(mergeRequest.ProjectId, mergeRequest.Iid,
|
||||||
|
new CreateMergeRequestNoteRequest(message));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var isCodeFreezePeriod = _settings.ReleaseCodeFreeze == "true";
|
||||||
|
var periodDescription = isCodeFreezePeriod ? "Code-Freeze. Restrictions may apply" : "Normal";
|
||||||
|
Console.WriteLine($"Current period is {periodDescription}.");
|
||||||
|
|
||||||
|
var filtered = FilterApprovers(approversDict, isCodeFreezePeriod);
|
||||||
|
if (!filtered.Any() && isCodeFreezePeriod)
|
||||||
|
{
|
||||||
|
filtered = FilterApprovers(approversDict, false);
|
||||||
|
}
|
||||||
|
if (!await IsApproved(mergeRequest, commit, filtered))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -56,13 +95,8 @@ public class App : IApp
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> IsApproved(MergeRequest mergeRequest, Commit commit)
|
private async Task<bool> IsApproved(MergeRequest mergeRequest, Commit commit, Dictionary<string, ApproversDto> approversDict)
|
||||||
{
|
{
|
||||||
var approversDict = ParseApprovers();
|
|
||||||
if (approversDict is null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var emojis = await _client.MergeRequests.GetAwardEmojisAsync(_settings.ProjectId, mergeRequest.Iid);
|
var emojis = await _client.MergeRequests.GetAwardEmojisAsync(_settings.ProjectId, mergeRequest.Iid);
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
@@ -71,8 +105,15 @@ public class App : IApp
|
|||||||
if (emoji.UpdatedAt <= commit.CommittedDate)
|
if (emoji.UpdatedAt <= commit.CommittedDate)
|
||||||
{
|
{
|
||||||
sb.AppendLine($" - Удален {emoji.Name} от {emoji.User.Username} ({emoji.UpdatedAt}), т.к. после него были коммиты ({commit.CommittedDate}).");
|
sb.AppendLine($" - Удален {emoji.Name} от {emoji.User.Username} ({emoji.UpdatedAt}), т.к. после него были коммиты ({commit.CommittedDate}).");
|
||||||
|
try
|
||||||
|
{
|
||||||
await _customClient.DeleteEmoji(mergeRequest.ProjectId, mergeRequest.Iid, emoji.Id);
|
await _customClient.DeleteEmoji(mergeRequest.ProjectId, mergeRequest.Iid, emoji.Id);
|
||||||
}
|
}
|
||||||
|
catch (HttpRequestException ex) when(ex.Message.Contains("Response status code does not indicate success"))
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sb.Length > 0)
|
if (sb.Length > 0)
|
||||||
{
|
{
|
||||||
@@ -130,4 +171,17 @@ public class App : IApp
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, ApproversDto> FilterApprovers(Dictionary<string, ApproversDto> approvers, bool isCodeFreezePeriod)
|
||||||
|
{
|
||||||
|
var result = new Dictionary<string, ApproversDto>();
|
||||||
|
foreach (var approversDto in approvers)
|
||||||
|
{
|
||||||
|
if (approversDto.Value.ForCodeFreeze == isCodeFreezePeriod)
|
||||||
|
{
|
||||||
|
result.Add(approversDto.Key, approversDto.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ namespace Approve.Checker.Gitlab;
|
|||||||
|
|
||||||
public class ApproversDto
|
public class ApproversDto
|
||||||
{
|
{
|
||||||
|
public bool ForCodeFreeze { get; set; }
|
||||||
public int CountApprovers { get; set; } = 1;
|
public int CountApprovers { get; set; } = 1;
|
||||||
public List<string> Users { get; set; }
|
public List<string> Users { get; set; } = new();
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
using GitLabApiClient.Models.Issues.Responses;
|
||||||
|
using GitLabApiClient.Models.MergeRequests.Responses;
|
||||||
|
using GitLabApiClient.Models.Milestones.Responses;
|
||||||
|
using GitLabApiClient.Models.Pipelines.Responses;
|
||||||
|
using GitLabApiClient.Models;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
#pragma warning disable CS8618
|
||||||
|
|
||||||
|
namespace Approve.Checker.Gitlab.Dto;
|
||||||
|
|
||||||
|
public sealed class CustomMergeRequest
|
||||||
|
{
|
||||||
|
[JsonProperty("iid")]
|
||||||
|
public int Iid { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("created_at")]
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("updated_at")]
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("labels")]
|
||||||
|
public List<string> Labels { get; } = new List<string>();
|
||||||
|
|
||||||
|
[JsonProperty("source_branch")]
|
||||||
|
public string SourceBranch { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("downvotes")]
|
||||||
|
public int Downvotes { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("author")]
|
||||||
|
public Assignee Author { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("assignee")]
|
||||||
|
public Assignee Assignee { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("force_remove_source_branch")]
|
||||||
|
public bool? ForceRemoveSourceBranch { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("milestone")]
|
||||||
|
public Milestone Milestone { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("merge_status")]
|
||||||
|
public MergeStatus Status { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("merge_commit_sha")]
|
||||||
|
public string MergeCommitSha { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("merge_when_pipeline_succeeds")]
|
||||||
|
public bool MergeWhenPipelineSucceeds { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("sha")]
|
||||||
|
public string Sha { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("project_id")]
|
||||||
|
public string ProjectId { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("should_remove_source_branch")]
|
||||||
|
public bool? ShouldRemoveSourceBranch { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("target_project_id")]
|
||||||
|
public int TargetProjectId { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("state")]
|
||||||
|
public MergeRequestState State { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("source_project_id")]
|
||||||
|
public int SourceProjectId { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("closed_at")]
|
||||||
|
public DateTime? ClosedAt { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("closed_by")]
|
||||||
|
public ClosedBy ClosedBy { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("target_branch")]
|
||||||
|
public string TargetBranch { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("upvotes")]
|
||||||
|
public int Upvotes { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("web_url")]
|
||||||
|
public string WebUrl { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("title")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("user_notes_count")]
|
||||||
|
public int UserNotesCount { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("work_in_progress")]
|
||||||
|
public bool WorkInProgress { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("time_stats")]
|
||||||
|
public MergeRequestTimeStatistic TimeStats { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("pipeline")]
|
||||||
|
public Pipeline Pipeline { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("merged_by")]
|
||||||
|
public Assignee MergedBy { get; set; }
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Approve.Checker.Gitlab.Dto;
|
||||||
using GitLabApiClient.Models.Job.Responses;
|
using GitLabApiClient.Models.Job.Responses;
|
||||||
using GitLabApiClient.Models.MergeRequests.Responses;
|
using GitLabApiClient.Models.MergeRequests.Responses;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -54,7 +55,7 @@ public class GitlabCustomClient : IGitlabCustomClient
|
|||||||
return responseObj!;
|
return responseObj!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<MergeRequest[]> GetMergeRequestsByTargetBranch(string targetBranch)
|
public async Task<CustomMergeRequest[]> GetMergeRequestsByTargetBranch(string targetBranch)
|
||||||
{
|
{
|
||||||
var request = new HttpRequestMessage(HttpMethod.Get, $"{_url}/api/v4/merge_requests?target_branch={targetBranch}&scope=all&per_page=1000");
|
var request = new HttpRequestMessage(HttpMethod.Get, $"{_url}/api/v4/merge_requests?target_branch={targetBranch}&scope=all&per_page=1000");
|
||||||
request.Headers.Add("PRIVATE-TOKEN", _token);
|
request.Headers.Add("PRIVATE-TOKEN", _token);
|
||||||
@@ -62,7 +63,7 @@ public class GitlabCustomClient : IGitlabCustomClient
|
|||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
var responseStr = await response.Content.ReadAsStringAsync();
|
var responseStr = await response.Content.ReadAsStringAsync();
|
||||||
var responseObj = JsonConvert.DeserializeObject<MergeRequest[]>(responseStr)!;
|
var responseObj = JsonConvert.DeserializeObject<CustomMergeRequest[]>(responseStr)!;
|
||||||
return responseObj;
|
return responseObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using GitLabApiClient.Models.Job.Responses;
|
using Approve.Checker.Gitlab.Dto;
|
||||||
|
using GitLabApiClient.Models.Job.Responses;
|
||||||
using GitLabApiClient.Models.MergeRequests.Responses;
|
using GitLabApiClient.Models.MergeRequests.Responses;
|
||||||
using ReleaseScripts.ExternalSystems.Gitlab.CustomClient.Dto;
|
using ReleaseScripts.ExternalSystems.Gitlab.CustomClient.Dto;
|
||||||
using ReleaseScripts.ExternalSystems.Gitlab.CustomClient.Dto.ApprovalState;
|
using ReleaseScripts.ExternalSystems.Gitlab.CustomClient.Dto.ApprovalState;
|
||||||
@@ -10,7 +11,7 @@ public interface IGitlabCustomClient
|
|||||||
Task<Reviewers[]> GetReviewers(string projectId, int Iid);
|
Task<Reviewers[]> GetReviewers(string projectId, int Iid);
|
||||||
Task<ApprovalStateResponse> GetApprovals(string projectId, int Iid);
|
Task<ApprovalStateResponse> GetApprovals(string projectId, int Iid);
|
||||||
Task<ApprovalStateResponse> GetDiscussions(string projectId, int Iid);
|
Task<ApprovalStateResponse> GetDiscussions(string projectId, int Iid);
|
||||||
Task<MergeRequest[]> GetMergeRequestsByTargetBranch(string targetBranch);
|
Task<CustomMergeRequest[]> GetMergeRequestsByTargetBranch(string targetBranch);
|
||||||
Task<Job[]> GetPipelineTriggers(string projectId, int pipelineId);
|
Task<Job[]> GetPipelineTriggers(string projectId, int pipelineId);
|
||||||
Task RestartJob(string projectId, int failedJobId);
|
Task RestartJob(string projectId, int failedJobId);
|
||||||
Task<MergeRequest[]> GetMergeRequestsBySourceBranch(string targetBranch);
|
Task<MergeRequest[]> GetMergeRequestsBySourceBranch(string targetBranch);
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
using System;
|
namespace Approve.Checker.Gitlab;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Approve.Checker.Gitlab
|
|
||||||
{
|
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
public string GitlabUrl = Environment.GetEnvironmentVariable("CI_SERVER_URL") ?? CheckAndThrow("CI_SERVER_URL");
|
public string GitlabUrl = Environment.GetEnvironmentVariable("CI_SERVER_URL") ?? CheckAndThrow("CI_SERVER_URL");
|
||||||
@@ -13,6 +7,7 @@ namespace Approve.Checker.Gitlab
|
|||||||
public string MrPath = Environment.GetEnvironmentVariable("CI_OPEN_MERGE_REQUESTS")!;
|
public string MrPath = Environment.GetEnvironmentVariable("CI_OPEN_MERGE_REQUESTS")!;
|
||||||
public string ProjectId = Environment.GetEnvironmentVariable("CI_PROJECT_ID") ?? CheckAndThrow("CI_PROJECT_ID");
|
public string ProjectId = Environment.GetEnvironmentVariable("CI_PROJECT_ID") ?? CheckAndThrow("CI_PROJECT_ID");
|
||||||
public string Approvers = Environment.GetEnvironmentVariable("APPROVERS_FILEPATH") ?? CheckAndThrow("APPROVERS_FILEPATH");
|
public string Approvers = Environment.GetEnvironmentVariable("APPROVERS_FILEPATH") ?? CheckAndThrow("APPROVERS_FILEPATH");
|
||||||
|
public string ReleaseCodeFreeze = Environment.GetEnvironmentVariable("RELEASE_CODEFREEZE") ?? "false";
|
||||||
|
|
||||||
private static string CheckAndThrow(string name)
|
private static string CheckAndThrow(string name)
|
||||||
{
|
{
|
||||||
@@ -20,4 +15,3 @@ namespace Approve.Checker.Gitlab
|
|||||||
throw new ArgumentException($"Please define {name}");
|
throw new ArgumentException($"Please define {name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user