feat: implement error notification as pr comment (#124)

* feat: implement error notification as pr comment

* Update action.yml

Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com>

* feat: implement gitlab client and surround with try catch

* docs: add error notification enablment in the doc

* feat: disable comment if dry-run

* feat: update the default comment on error

---------

Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com>
This commit is contained in:
Andrea Lamparelli 2024-04-10 23:01:16 +02:00 committed by GitHub
parent 6042bcc40b
commit 2bb7f73112
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 594 additions and 39 deletions

View file

@ -139,6 +139,10 @@ describe("github pull request config parser", () => {
labels: [],
comments: [],
});
expect(configs.errorNotification).toEqual({
enabled: false,
message: "The backport to `{{target-branch}}` failed. Check the latest run for more details."
});
});
test("override folder", async () => {
@ -939,4 +943,26 @@ describe("github pull request config parser", () => {
comments: ["First comment", "Second comment"],
});
});
test("enable error notification message", async () => {
const args: Args = {
dryRun: false,
auth: "",
pullRequest: mergedPRUrl,
targetBranch: "prod",
enableErrorNotification: true,
};
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(configs.errorNotification).toEqual({
"enabled": true,
"message": "The backport to `{{target-branch}}` failed. Check the latest run for more details."
});
});
});