-
Notifications
You must be signed in to change notification settings - Fork 540
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
Resolve devImports #331
Resolve devImports #331
Conversation
Can be omitted by using the new flag --without-dev glide update [--without-dev] glide install [--without-dev]
Note, this implements #320. |
@alde This is a good start. Thanks. It still needs to have the resolver get the imports from the test files and put them into the devImports. |
Cheers, I'll try to fix that this weekend, or on monday. |
I was originally going to suggest that we do not include dev dependencies by default (e.g. that we have When we encounter Glide.yaml files in dependencies, do we obey this flag in regards to those? I'm kinda thinking no. But I could be swayed the other way. |
My idea with --without-dev was that if you know that you won't be running the tests for example you'd know that you don't want/need them installed I am however having some issues with the resolver, as in I'm not sure I fully understand what it's meant to do. I assumed at first it went through the .go files and found imports, and as such it would need to go through the _test.go files for dev imports, but that doesn't seem to be the case |
Maybe we should step back a moment and describe what Here's my first pass:
Examples of devImports:
My assumption is that by default, when I import with Does that sound similar to what you were thinking @mattfarina and @alde ? |
Yes, that was my thought, and the reason I started trying to patch it. |
@technosophos The external tools become a little more difficult to use for |
So based on the comments of @alde @mattfarina and me, it sounds like we're down to just this use case:
Does that sound right? |
I wanted to +1 @technosophos's comment for this use-case:
We do this currently for |
@alde Is this something I should pickup and finish completing or is this something you wanted to finish rounding out? |
Yeah, sorry, I've got it a bit hectic atm. If you want to finish it, please feel free, I don't know when I'll have the time to focus on it again :( |
Ditto. By comparison, I've been happy using export GOPATH="$PWD/vendor:$PWD"
PATH_add "$PWD/vendor/bin"
PATH_add "$PWD/bin" Of course Would it be viable for Glide to install the I start to wish that Go vendor experiment had followed |
I think that a critical conflation of dev versus test has pervaded the thread—I was first confused by @technosophos's quoted mention of CI. I thought, "I certainly do not want to use Ruby's Bundler supports arbitrary groups with dev and test being common convention; all are installed by default, and typically But presumably Go build tooling does a fine job already of keeping test libraries from bloating production artifacts when they're only imported in In that case I think it becomes the clear choice that The downside is that, if Glide looks at |
Here's a thought, should it change from |
@mattfarina I think that renaming would probably be helpful. I may rejigger the corresponding naming for
Yeah, this is part of a more general problem - what @technosophos and I have been calling the "bi-modal analysis" problem: do you operate at the project or package level in building the depgraph? When you do the former, you may get excess packages; when you do the latter, you have no version information. The former is wasteful, but ultimately correct; the latter is just wrong (which is why we're all here). It's not intractable, I don't think; it just involves making some tradeoffs. However, I've deferred work on it in favor of trying to get |
@mattfarina If we've resolved that the semantic is meant to be analogous to Consideration of a feature for dev tooling like the |
Hi guys, What's the status of that? The lack of vendoring imports from tests is pretty big issue for me, as basically you can't run tests that relay on some packages that aren't required in the code itself. To bypass the issue right now I do Btw this was working couple months ago, as then glide was fetching ALL dependencies... I love that it doesn't do that anymore but yeah since then it doesn't parse dependencies from test files:/ |
Something like this (without this patch) fixes the issue for me index dc88f62..62b4731 100644
--- a/dependency/resolver.go
+++ b/dependency/resolver.go
@@ -266,7 +266,7 @@ func (r *Resolver) ResolveLocal(deep bool) ([]string, error) {
return err
}
} else {
- imps = p.Imports
+ imps = append(p.Imports, p.TestImports...)
}
// We are only looking for dependencies in vendor. No root, cgo, etc. I've started to think that maybe a good idea would be to merge just that one line to fix the issue with |
Please note that it's also possible for test files in package
If the list of test imports is being collected from the imps := p.Imports // imports from GoFiles, CgoFiles
imps = append(imps, p.TestImports...) // imports from TestGoFiles
imps = append(imps, p.XTestImports...) // imports from XTestGoFiles |
Is there any news on this PR or similar functionality (vendoring test dependencies) going into glide anytime soon? |
I know this is closed, but perhaps this will be helpful for those trying to vendor their test deps with glide. It's a crazy stupid long one liner in bash that passes all recursive test deps into
Unfortunately, this only works if your vendor directory is empty. Otherwise you'll end up with a bunch of subpackages in your |
Early next week I'll have a PR to more formalize this. The hard part is already done. |
Can be omitted by using the new flag --without-dev
glide update [--without-dev]
glide install [--without-dev]