-
-
Notifications
You must be signed in to change notification settings - Fork 14
Automatically merge PRs with auto-merge #15
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
Conversation
e63d8e8
to
cacedfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
enum splitRE = regex(`[^\d]+`); // ctRegex throws a weird error in unittest compilation | ||
auto closed = !m.captures[1].empty; | ||
return m.captures[5].stripRight.splitter(ctRegex!`[^\d]+`) | ||
return m.captures[5].stripRight.splitter(splitRE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With ctRegex
and the unittest
below, I was getting the following error:
However I couldn't reproduce this in an isolated case :/
m.captures[5] = ["16319", ""];
core.exception.AssertError@/usr/include/dlang/dmd/std/regex/package.d(563): wrong match: 9..4
----------------
??:? _d_assert_msg [0xa47df5]
/usr/include/dlang/dmd/std/regex/package.d:564 std.regex.Captures!(immutable(char)[], ulong).Captures.opIndex!().opIndexinout(pure nothrow @trusted inout(immutable(char)[]) function(ulong)) [0x878691]
source/app.d:155 @safe app.IssueRef[] app.matchIssueRefs(immutable(char)[]).matchToRefs!(std.regex.Captures!(immutable(char)[], ulong).Captures).matchToRefs(std.regex.Captures!(immutable(char)[], ulong).Captures) [0x8772ec]
/usr/include/dlang/dmd/std/algorithm/iteration.d:593 @property @safe app.IssueRef[] std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult.front() [0x87e89d]
/usr/include/dlang/dmd/std/algorithm/iteration.d:2376 ref @safe std.algorithm.iteration.joiner!(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult).joiner(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult).Result std.algorithm.iteration.joiner!(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult).joiner(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult).Result.__ctor(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult) [0x87f3ea]
/usr/include/dlang/dmd/std/algorithm/iteration.d:2419 @safe std.algorithm.iteration.joiner!(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult).joiner(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult).Result std.algorithm.iteration.joiner!(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult).joiner(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult) [0x87f2ed]
source/app.d:164 @safe std.algorithm.iteration.joiner!(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult).joiner(std.algorithm.iteration.__T9MapResultS383app14matchIssueRefsFAyaZ11matchToRefsTS3std5regex108__T10RegexMatchTAyaS853std5regex8internal12backtracking29__T19BacktrackingMatcherVbi1Z19BacktrackingMatcherZ10RegexMatchZ.MapResult).Result app.matchIssueRefs(immutable(char)[]) [0x81e169]
source/app.d:169 void app.__unittestL167_8() [0x81e1c7]
??:? void app.__modtest() [0x8ba6c0]
??:? int core.runtime.runModuleUnitTests().__foreachbody2(object.ModuleInfo*) [0xaa6788]
??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)).__lambda2(immutable(object.ModuleInfo*)) [0xa469eb]
??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))).__foreachbody2(ref rt.sections_elf_shared.DSO) [0xa534c6]
??:? int rt.sections_elf_shared.DSO.opApply(scope int delegate(ref rt.sections_elf_shared.DSO)) [0xa53a0d]
??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))) [0xa53457]
??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)) [0xa469c7]
??:? runModuleUnitTests [0xaa667a]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0xa4e5aa]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0xa4e54c]
??:? _d_run_main [0xa4e4bd]
??:? main [0x81b677]
??:? __libc_start_main [0x15bd5290]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still know for which input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes for the existing unittest
below, hence the capture variable is set as:
m.captures[5] = ["16319", ""];
string travisAPIURL = "https://api.travis-ci.org"; | ||
string trelloAPIURL = "https://api.trello.com"; | ||
string bugzillaURL = "https://issues.dlang.org"; | ||
bool runAsync = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the testing a lot easier :)
string trelloAPIURL = "https://api.trello.com"; | ||
string bugzillaURL = "https://issues.dlang.org"; | ||
bool runAsync = true; | ||
bool runTrello = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I disabled the Trello capabilties in the testing framework
// https://developer.github.com/changes/2016-09-26-pull-request-merge-api-update/ | ||
req.headers["Accept"] = "application/vnd.github.polaris-preview+json"; | ||
req.writeJsonBody(reqInput); | ||
}, prUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try the merge here .. it will probably fail & in the error case we just print a log message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to enable squash merges on all repos for that, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to enable squash merges on all repos for that, right?
Yep, but we don't need to do this for now or we could just enable it for one repo.
//============================================================================== | ||
|
||
Json verifyRequest(string signature, string data) | ||
auto getSignature(string data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split in two parts so that a "fake" signature can be stubbed
searchForAutoMergePrs(repoSlug); | ||
if (Clock.currTime - lastFullPRCheck >= timeBetweenFullPRChecks) | ||
{ | ||
searchForAutoMergePrs(repoSlug); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple throttling for querying over all open PRs. Currently it's throttle to 15.minutes
d: | ||
- dmd-beta | ||
- dmd | ||
- ldc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about gdc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OTOH, same reasoning as with the OS, we merely need to test the version we deploy with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about gdc?
I stopped testing/using it a long time ago, because one just runs into too many fixed bugs or missing features.
@@ -0,0 +1,2 @@ | |||
bug_id,"short_desc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a csv file, not json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> Changed in #16
@@ -0,0 +1,9128 @@ | |||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's possible to gzip the files? Vibe.d serves pre-compressed files by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah probably, but it's compressed in the git history anyways and locally it doesn't matter?
The entire payloads folder has less than 1M atm.
sudo: false | ||
os: | ||
- linux | ||
- osx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really OSX? We don't want to test vibe.d, and aren't using any platform specific stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough -> In #16 I removed macOS
travisAuth = "token " ~ environment["TRAVIS_TOKEN"]; | ||
|
||
// workaround for stupid openssl.conf on Heroku | ||
if (environment.get("DYNO") !is null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing that one.
static if (T.length) | ||
req.writeJsonBody(arg); | ||
}, url); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The weird vibe.d request API is actually a good test case for the scope/DIP1000 topic. It's only using callbacks to not escape scoped classes.
|
||
auto analyseLabels(Json[] labels) | ||
{ | ||
auto labelNames = labels.map!`a["name"].get!string`.array; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid string lambdas.
// https://developer.github.com/changes/2016-09-26-pull-request-merge-api-update/ | ||
req.headers["Accept"] = "application/vnd.github.polaris-preview+json"; | ||
req.writeJsonBody(reqInput); | ||
}, prUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to enable squash merges on all repos for that, right?
auto prs = ghGetRequest("%s/repos/%s/pulls?state=open".format(githubAPIURL, repoSlug)).readJson[]; | ||
foreach (pr; prs) | ||
{ | ||
handleGithubLabel(repoSlug, pr["number"].get!uint, pr["commits_url"].get!string, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not restricting label?
Sounds a bit better to first get all label:auto-merge
, then all label:auto-merge-squash
, subtract the latter from the former (in case of both), and then loop over the 2 arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would mean, you need to break up the handleGithubLabel
function into an information retrieving part and an action part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not restricting label?
Sounds a bit better to first get all label:auto-merge, then all label:auto-merge-squash, subtract the latter from the former (in case of both), and then loop over the 2 arrays.
At GitHub there are two APIs for this: issue
and pulls
.
With the issue
API we can directly filter on the labels -> #17
fakeSettings.bindAddresses = ["0.0.0.0"]; | ||
fakeSettings.options = HTTPServerOption.defaults & HTTPServerOption.parseJsonBody; | ||
auto router = new URLRouter; | ||
router.any("*", &payloadServer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about letting the router do the GH, Trello, Travis dispatching?
Maybe one bigger thing? |
// no existing dlang bot comment -> create comment | ||
unittest | ||
{ | ||
auto expectedURLs = ["/github/repos/dlang/phobos/pulls/4921/commits", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks a bit as if it could be done somewhat similar to the router.
setAPIExpectations!(
"/github/repos/dlang/phobos/pulls/4921/commits",
"/github/repos/dlang/phobos/issues/4921/labels",
//...
"/github/repos/dlang/phobos/issues/4921/comments", (scope req, scope res) {
// assert(req == );
});
postStatus("...");
Closed in favor of #17 |
No description provided.