Skip to content
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

Warn when fixing enhancements without changelog #274

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Empty file.
22 changes: 22 additions & 0 deletions source/dlangbot/warnings.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ struct UserMessage
}


void checkEnhancementChangelog(in ref PullRequest pr, ref UserMessage[] msgs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use in ref please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using the same signature as the method below.

in Issue[] bugzillaIssues, in IssueRef[] refs)
{
import dlangbot.utils : request, expectOK;
import vibe.stream.operations : readAllUTF8;

if (bugzillaIssues.any!(i => i.status.among("NEW", "ASSIGNED", "REOPENED") &&
i.severity == "enhancement" &&
refs.canFind!(r => r.id == i.id && r.fixed)))
{
auto diff = request(pr.diffURL).expectOK.bodyReader.readAllUTF8;
if (!diff.canFind("\n+++ b/changelog/"))
{
msgs ~= UserMessage(UserMessage.Type.Warning,
"Pull requests implementing enhancements should include a [full changelog entry](https://github.com/dlang/dmd/tree/master/changelog)."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, won't this trigger for other repos too ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of #273 the list of refs for non-Bugzilla-using projects should be empty, which should match projects which use the changelog directory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see what you mean, well spotted. Fix pushed.

);
}
}
}


/**
Check bugzilla priority
- enhancement -> changelog entry
Expand Down Expand Up @@ -50,6 +71,7 @@ UserMessage[] checkForWarnings(in PullRequest pr, in Issue[] bugzillaIssues, in
{
UserMessage[] msgs;
pr.checkBugzilla(msgs, bugzillaIssues, refs);
pr.checkEnhancementChangelog(msgs, bugzillaIssues, refs);
return msgs;
}

Expand Down
89 changes: 89 additions & 0 deletions test/comments.d
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ unittest
8573,"A simpler Phobos function that returns the index of the mix or max item","NEW","---","enhancement","P2",`);
},
"/github/repos/dlang/phobos/issues/4921/labels",
"/github.com/dlang/phobos/pull/4921.diff",
"/github/repos/dlang/phobos/issues/4921/labels", (ref Json j) {
j = Json.emptyArray;
},
Expand Down Expand Up @@ -169,6 +170,7 @@ unittest
8574,"Some Bug","NEW","---","normal","P2",`);
},
"/github/repos/dlang/phobos/issues/4921/labels",
"/github.com/dlang/phobos/pull/4921.diff",
"/github/repos/dlang/phobos/issues/4921/labels", (ref Json j) {
j = Json.emptyArray;
},
Expand Down Expand Up @@ -200,6 +202,7 @@ unittest
"/github/repos/dlang/phobos/issues/4921/comments",
"/bugzilla/buglist.cgi?bug_id=8573&ctype=csv&columnlist=short_desc,bug_status,resolution,bug_severity,priority,keywords",
"/github/repos/dlang/phobos/issues/4921/labels",
"/github.com/dlang/phobos/pull/4921.diff",
"/github/repos/dlang/phobos/issues/4921/labels", (ref Json j) {
j[0]["name"] = "Enhancement";
},
Expand Down Expand Up @@ -558,3 +561,89 @@ unittest
assert("a\\b".markdownEscape == "a\\\\b");
assert("a+b".markdownEscape == r"a\+b");
}

@("enhancement-with-changelog")
unittest
{
setAPIExpectations(
"/github/repos/dlang/phobos/pulls/4921/commits", (ref Json j) {
j[0]["commit"]["message"] = "Fix Issue 8573";
},
"/github/repos/dlang/phobos/issues/4921/comments",
"/bugzilla/buglist.cgi?bug_id=8573&ctype=csv&columnlist=short_desc,bug_status,resolution,bug_severity,priority,keywords",
(scope HTTPServerRequest req, scope HTTPServerResponse res){
res.writeBody(
`bug_id,"short_desc","bug_status","resolution","bug_severity","priority","keywords"
8573,"A simpler Phobos function that returns the index of the mix or max item","NEW","---","enhancement","P2",`);
},
"/github/repos/dlang/phobos/issues/4921/labels",
"/github.com/dlang/phobos/pull/4921.diff", (scope HTTPServerRequest req, scope HTTPServerResponse res){
res.writeBody(q"EOF
diff --git a/changelog/bla-bla.dd b/changelog/bla-bla.dd
new file mode 100644
index 00000000000..0147f501f08
--- /dev/null
+++ b/changelog/bla-bla.dd
@@ -0,0 +1,1 @@
+bla bla
EOF");
},
"/github/repos/dlang/phobos/issues/4921/labels", (ref Json j) {
j = Json.emptyArray;
},
"/github/orgs/dlang/public_members?per_page=100",
"/github/repos/dlang/phobos/issues/comments/262784442",
(scope HTTPServerRequest req, scope HTTPServerResponse res){
assert(req.method == HTTPMethod.PATCH);
assert(!req.json["body"].get!string.canFind("Pull requests implementing enhancements should include"));
res.writeVoidBody;
},
"/github/repos/dlang/phobos/issues/4921/labels",
(scope HTTPServerRequest req, scope HTTPServerResponse res){
assert(req.json[].equal(["Enhancement"]));
},
"/trello/1/search?query=name:%22Issue%208573%22&"~trelloAuth,
"/bugzilla/jsonrpc.cgi", // Bug.comments
"/bugzilla/jsonrpc.cgi", // Bug.update
);

postGitHubHook("dlang_phobos_synchronize_4921.json");
}

@("enhancement-with-changelog")
unittest
{
setAPIExpectations(
"/github/repos/dlang/phobos/pulls/4921/commits", (ref Json j) {
j[0]["commit"]["message"] = "Fix Issue 8573";
},
"/github/repos/dlang/phobos/issues/4921/comments",
"/bugzilla/buglist.cgi?bug_id=8573&ctype=csv&columnlist=short_desc,bug_status,resolution,bug_severity,priority,keywords",
(scope HTTPServerRequest req, scope HTTPServerResponse res){
res.writeBody(
`bug_id,"short_desc","bug_status","resolution","bug_severity","priority","keywords"
8573,"A simpler Phobos function that returns the index of the mix or max item","NEW","---","enhancement","P2",`);
},
"/github/repos/dlang/phobos/issues/4921/labels",
"/github.com/dlang/phobos/pull/4921.diff",
"/github/repos/dlang/phobos/issues/4921/labels", (ref Json j) {
j = Json.emptyArray;
},
"/github/orgs/dlang/public_members?per_page=100",
"/github/repos/dlang/phobos/issues/comments/262784442",
(scope HTTPServerRequest req, scope HTTPServerResponse res){
assert(req.method == HTTPMethod.PATCH);
assert(req.json["body"].get!string.canFind("Pull requests implementing enhancements should include"));
res.writeVoidBody;
},
"/github/repos/dlang/phobos/issues/4921/labels",
(scope HTTPServerRequest req, scope HTTPServerResponse res){
assert(req.json[].equal(["Enhancement"]));
},
"/trello/1/search?query=name:%22Issue%208573%22&"~trelloAuth,
"/bugzilla/jsonrpc.cgi", // Bug.comments
"/bugzilla/jsonrpc.cgi", // Bug.update
);

postGitHubHook("dlang_phobos_synchronize_4921.json");
}