Skip to content

fix: Check failCommentCondition in "success" step #1026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions lib/success.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
67 changes: 67 additions & 0 deletions test/success.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});

Expand All @@ -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}`, {
Expand Down