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
Made logs.badge.branch
capable of accepting a regular expression
#1538
Made logs.badge.branch
capable of accepting a regular expression
#1538
Conversation
logs.badge.matchBranchRegex
config to match multiple branches i…logs.badge.matchBranchRegex
config to match multiple branches in reporting
@@ -65,7 +63,8 @@ private function assertLogsStateIs( | |||
$this->assertNull($badge); | |||
} else { | |||
$this->assertNotNull($badge); | |||
$this->assertBadgeStateIs($badge, $expectedBadge->getBranch()); |
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.
Removed this: it made the tests much more confusing than they were, and a simpler solution was to do object-to-object equality.
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.
object-to-object equality is always tricky due to the loose comparison, but if anyone is interested there is https://github.com/webmozarts/strict-phpunit which solves that issue and allows to remove a lot of boilertemplate
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.
I'm ok with the current state of PR.
One idea to discuss though: what if we make existing (in master
) config key branch
more clever to understand regexes?
{
"logs": {
"badge": {
"branch": "master"
}
}
}
^ BC support, pushes the report for the exact branch - master
in this case.
{
"logs": {
"badge": {
"branch": "/^foo$/"
}
}
}
^ new feature. Infection understands this is a regex and matches with preg_match()
.
In this case we will keep BC and extend the functionality of branch
config key.
Didn't want to mess with the existing What I can certainly try to do is say that if the |
IMO, sounds ok :) I believe the majority of the users use it like Also, why I like the idea of having just one |
Ok, will go back at this and simplify the patch: possibly rewrite, since that would be simpler :D |
Thinking further about this, git branches cannot start with |
logs.badge.matchBranchRegex
config to match multiple branches in reportinglogs.badge.branch
capable of accepting a regular expression
@maks-rafalko I've reworked this to hide the fact that a regex or exact match happens inside a I'll rework the docs PR. Small suggestion: smash docs and sources together - easier for atomic diffs ;-) |
Also removed `logs.badge.matchBranchRegex` docs: the upstream patch in infection/infection#1538 also got rid of it.
Docs PR also updated. |
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.
👍
Applied suggested improvements 👍 |
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.
👍 Left some comments but I don't think they are critical
@@ -65,7 +63,8 @@ private function assertLogsStateIs( | |||
$this->assertNull($badge); | |||
} else { | |||
$this->assertNotNull($badge); | |||
$this->assertBadgeStateIs($badge, $expectedBadge->getBranch()); |
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.
object-to-object equality is always tricky due to the loose comparison, but if anyone is interested there is https://github.com/webmozarts/strict-phpunit which solves that issue and allows to remove a lot of boilertemplate
@theofidry for value objects, object-to-object equality is an acceptable trade-off, so I'll leave that one as-is. It is true that some edge cases can be troublesome, but they mostly affect floating point arithmetic and deeply nested graphs with recursion, so not really important in here. |
@Ocramius definitely, not necessary here for this case |
…rough a data provider Previously, we had a single test with multiple assertions. Ref: infection#1538 (comment)
79823a0
to
8a37265
Compare
…n reporting By configuring `logs.badge.matchBranchRegex`, it is possible to set multiple branches to report their mutation score to upstream tools: ```json { "source": { "directories": ["src/"] }, "logs": { "badge": { "matchBranchRegex": "/^release-.*$/" } } } ``` Note that `logs.badge.matchBranchRegex` is mutually exclusive with `logs.badge.branch`, which is much more restrictive: the two cannot be used together. Fixes infection#1536
By configuring `logs.badge.branch` with a `/`-delimited regular expression, we can collect reports about a number of branches. ```json { "source": { "directories": ["src/"] }, "logs": { "badge": { "branch": "/^release-.*$/" } } } ``` Note that `logs.badge.matchBranchRegex`, initially proposed as an alternative, has also been removed. We can safely assume that a `branch` value starting and ending with `/` is a regular expression, because git branches starting or ending with `/` are not valid anyway. Fixes infection#1536
…rough a data provider Previously, we had a single test with multiple assertions. Ref: infection#1538 (comment)
8a37265
to
2925fe2
Compare
Rebased and applied @maks-rafalko and @theofidry's suggestions. Also looking forward to have this merged, so I don't have to wait for upstream approval for CI 🤷 (thanks crypto-bros, for ruining github) |
Thanks for the merge! @theofidry FWIW, avoid squashing - I put some effort in commit messages, and 0dde91a is really butchered :-\ |
We squash the commits in general: the git history of a PR is rarely tidy and it too often provides close to no value for the amount of efforts it requires to keep it tidy (and even more to try to enforce it) when IMO a link to GitHub/GitLab provides a lot more information. That said I'll be aware to avoid to do that on yours in the future, I did not took notice of it here |
By configuring
logs.badge.branch
with a/
-delimited regular expression, we can collectreports about a number of branches.
Note that
logs.badge.matchBranchRegex
, initially proposed as an alternative, has also been removed.We can safely assume that a
branch
value starting and ending with/
is a regular expression, becausegit branches starting or ending with
/
are not valid anyway.Fixes #1536
Fixes #814
Related: #1137
Related: #1149
This PR:
logs.badge.branch
accepting a regular expression site#220