From 410e4c4767cd01acc23d072452e557d338dff636 Mon Sep 17 00:00:00 2001 From: rhys-childs Date: Mon, 14 Apr 2025 10:17:51 -0600 Subject: [PATCH] fix: Check failCommentCondition in "success" step --- lib/success.js | 5 ++++ test/success.test.js | 67 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/lib/success.js b/lib/success.js index 5363863c..29c8defc 100644 --- a/lib/success.js +++ b/lib/success.js @@ -265,6 +265,11 @@ export default async function success(pluginConfig, context, { Octokit }) { if (failComment === false || failTitle === false) { logger.log("Skip closing issue."); + logger.warn( + `DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.`, + ); + } else if (failCommentCondition === false) { + logger.log("Skip closing issue."); } else { const srIssues = await findSRIssues( octokit, diff --git a/test/success.test.js b/test/success.test.js index 6f8a4ed5..d5348999 100644 --- a/test/success.test.js +++ b/test/success.test.js @@ -4355,6 +4355,11 @@ test('Skip closing issues if "failComment" is "false"', async (t) => { }, ); t.true(t.context.log.calledWith("Skip closing issue.")); + t.true( + t.context.warn.calledWith( + "DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.", + ), + ); t.true(fetch.done()); }); @@ -4370,6 +4375,68 @@ test('Skip closing issues if "failTitle" is "false"', async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; + const fetch = fetchMock + .sandbox() + .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + full_name: `${owner}/${repo}`, + clone_url: `https://api.github.local/${owner}/${repo}.git`, + }) + .postOnce("https://api.github.local/graphql", { + data: { + repository: { + commit123: { + oid: "123", + associatedPullRequests: { + pageInfo: { + endCursor: "NI", + hasNextPage: false, + }, + nodes: [], + }, + }, + }, + }, + }); + + await success( + pluginConfig, + { + env, + options, + branch: { name: "master" }, + commits, + nextRelease, + releases, + logger: t.context.logger, + }, + { + Octokit: TestOctokit.defaults((options) => ({ + ...options, + request: { ...options.request, fetch }, + })), + }, + ); + t.true(t.context.log.calledWith("Skip closing issue.")); + t.true( + t.context.warn.calledWith( + "DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.", + ), + ); + t.true(fetch.done()); +}); + +test('Skip closing issues if "failCommentCondition" is "false"', async (t) => { + const owner = "test_user"; + const repo = "test_repo"; + const env = { GITHUB_TOKEN: "github_token" }; + const pluginConfig = { failCommentCondition: false }; + const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git` }; + const commits = [{ hash: "123", message: "Commit 1 message" }]; + const nextRelease = { version: "1.0.0" }; + const releases = [ + { name: "GitHub release", url: "https://github.com/release" }, + ]; + const fetch = fetchMock .sandbox() .getOnce(`https://api.github.local/repos/${owner}/${repo}`, {