-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
we definitely want this approach of doing it out in dep isn't going to work, unfortunately. at most, it helps us with the root project, but it doesn't do anything for dependencies. we've gotta handle this in the solver. |
specifically, we'll need to introduce some new props, maybe a slice of strings, on the actually, no, not a slice. we'll want a trie, so that the prefix search is O(1) in the number of wildcard ignores specified by the root. i'm musing on whether or not we want the ignores to be case-insensitive, in keeping with #1079. for now, let's assume no - not only is that easier, but i think it's more consistent with shell-globbing, and so will be less confusing for people. |
ah! right! didn't think of the dependencies. I'll try to implement it in the solver 😊 |
33bdf18
to
2ead833
Compare
Another attempt 😅 |
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.
definitely looks like we're heading in the right direction!
internal/gps/pkgtree/pkgtree.go
Outdated
) | ||
|
||
// recursive ignore suffix |
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.
"recursive" isn't quite the right word to use for this, as it suggests a specific type of self-referential algorithm. better to just call these "wildcard ignores."
internal/gps/pkgtree/pkgtree.go
Outdated
) | ||
|
||
// recursive ignore suffix | ||
const recIgnoreSuffix = "/*" |
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 don't see a reason why we actually have to restrict to immediately following a slash - i think our only criteria here is that the asterisk has to be the last character.
internal/gps/pkgtree/pkgtree.go
Outdated
@@ -445,6 +450,15 @@ func (t PackageTree) ToReachMap(main, tests, backprop bool, ignore map[string]bo | |||
ignore = make(map[string]bool) | |||
} | |||
|
|||
// Create a radix tree for ignore prefixes | |||
xt := radix.New() |
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 allocs because it returns a pointer, so let's defer creating the trie until the last possible moment - if we see something with the expected suffix.
c768bc2
to
9e652ed
Compare
Do we have any existing repo that could be used to test dependency package ignore? |
internal/gps/pkgtree/pkgtree.go
Outdated
if xt == nil { | ||
xt = radix.New() | ||
} | ||
i = strings.TrimSuffix(i, wcIgnoreSuffix) |
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 ends up on the strings.HasSuffix()
call. better to just do the trim operation ourselves.
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 mean for cases like "github.com/x/someprefix-*-somesuffix"
?
Like using regex match?
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.
nope, i meant that this is the implementation of string.TrimSuffix()
:
func TrimSuffix(s, suffix string) string {
if HasSuffix(s, suffix) {
return s[:len(s)-len(suffix)]
}
return s
}
and the conditional has already been checked, so it's better to just do the s[:len(s)-len(suffix)]
operation ourselves rather than calling strings.TrimSuffix()
, as this method is processing-bound (possibly memory, possibly CPU), and this is within a loop, so easy microoptimizations like this are worth it.
so the PR as-is seems like it covers the essentials. now, i think, we need to do the harder work of thinking through the models and making sure that the edge cases are covered - especially the new ones that are induced by this. here are a few i can think of:
these are just what i can think of right now. also, this change will probably entail us bumping the solver version. consequently, i may want to wait to merge it until just before we're ready to make the next release (which'll be |
68ac3c2
to
4f73e5f
Compare
@sdboyer Yes, right now we use I have a PR that uses |
4f73e5f
to
e43c5da
Compare
I went through both gps and dep, and found that most of the places where we care about ignoring use
|
e43c5da
to
560c6b5
Compare
internal/gps/hash.go
Outdated
|
||
// Add wildcard ignores to ignore list. | ||
if s.rd.igpfx != nil { | ||
s.rd.igpfx.Walk(radix.WalkFn(func(s string, v interface{}) bool { |
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.
nit: it should be unnecessary to have the type conversion here - just passing the anonymous function with the correct signature is sufficient.
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.
just the two nits then we can merge
internal/gps/pkgtree/pkgtree.go
Outdated
@@ -16,8 +16,13 @@ import ( | |||
"strconv" | |||
"strings" | |||
"unicode" | |||
|
|||
radix "github.com/armon/go-radix" |
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 package name is already radix
, so this is unnecessary.
560c6b5
to
b17e759
Compare
Excited for this 😃 |
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.
Just one question and then it LGTM.
// CreateIgnorePrefixTree takes a set of strings to be ignored and returns a | ||
// trie consisting of strings prefixed with wildcard ignore suffix (*). | ||
func CreateIgnorePrefixTree(ig map[string]bool) *radix.Tree { | ||
var xt *radix.Tree |
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.
Why not initialize a new tree here instead of checking for nil later on?
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 had that earlier but then we decided to allocate memory only when we get a wildcard suffix. Refer #1156 (comment)
woohoo! i think we should roll a release after this. speaking of, this is missing a CHANGELOG update :) |
* Create trie only when wildcard is found * Rename 'recursive' to 'wildcard' ignore
Adds test for createIgnorePrefixTree() which verifies the global ignore skip. Also, unifies createIgnorePrefixTree() of solver and pkgtree, moving it to pkgtree package.
b17e759
to
4376248
Compare
fix CHANGELOG conflict for this, and we're good to go on it |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
nvm, i just fixed it directly :) |
What does this do / why do we need it?
Adds support for ignoring packages and subpackages using wildcard notation ("/*").
What should your reviewer look out for in this PR?
Implementation and tests. All the changes are in manifest, not touching gps.
Do you need help or clarification on anything?
Do we use "/*" or "/..." for this need?
Which issue(s) does this PR fix?
fixes #691