Skip to content

Conversation

wilzbach
Copy link
Contributor

No description provided.

@wilzbach wilzbach force-pushed the merge-prs branch 2 times, most recently from e63d8e8 to cacedfa Compare December 18, 2016 17:54
Copy link
Contributor Author

@wilzbach wilzbach left a 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)
Copy link
Contributor Author

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]

Copy link
Member

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?

Copy link
Contributor Author

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;
Copy link
Contributor Author

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;
Copy link
Contributor Author

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);
Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor Author

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)
Copy link
Contributor Author

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);
Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

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

What about gdc?

Copy link
Member

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.

Copy link
Contributor Author

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"
Copy link
Member

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.

Copy link
Contributor Author

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 @@
[
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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);
}
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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?

@MartinNowak
Copy link
Member

Maybe one bigger thing?
Can we just have the test server, serve files matching a particular folder structure, without hard-coding the responses?
So payloads/github/repos/dlang/dmd/pulls?state=open would be a text file for that exact request?
We could unconditionally replace API URLs for github in payloads/github.

// no existing dlang bot comment -> create comment
unittest
{
auto expectedURLs = ["/github/repos/dlang/phobos/pulls/4921/commits",
Copy link
Member

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("...");

@wilzbach wilzbach mentioned this pull request Dec 18, 2016
@wilzbach
Copy link
Contributor Author

Closed in favor of #17

@wilzbach wilzbach closed this Dec 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants