Repository navigation
chore/fix(core): add integration tests to other VCS - #7663
Conversation
8f080ba to
07ab873
Compare
8cc6d4e to
301501d
Compare
2306eb4 to
611a900
Compare
jedevc
left a comment
There was a problem hiding this comment.
Yay! Nice to have tests for this!
Left a couple nit comments, I'm not 100% sure about the .git stripping - if the VCS doesn't provide it, we should let the VCS error out with it, and not be super clever here.
There was a problem hiding this comment.
Hm, we shouldn't strip this off right? It's part of the specified URL.
The user shouldn't specify .git on a GitLab URL if it's not supported.
There was a problem hiding this comment.
Mmh, I kind of agree but the current behavior of RepoRootForImportPath currently surprises me.
I feel more comfortable to have a coherent and expected behavior (detailed below), and be a bit smarter in this part of the logic instead of potentially paying the price later and handling those edge cases inside the ModuleSource part of the codebase.
A nice and easy mental model where:
Reporepresents a URL that a user can use to access the URL of the module, and all its variation (commit, tree view)Rootrepresents the name of the module source. It is currently only being used as the name of the module. But being coherent on whether the user input ref contained a.gitmakes it a valid source of truth of the input ref (and would help us debug)
Given this heuristic:
- a repo should never contain a
.git, whether it was specified or not - a root should contain the
.gitif it was provided
Why is it important not to have the .git in the repo
Internally, Repo represents the URL to access the repo from a given ref. Upon manual tests, GitHub does support URLs with the .git inside ; but, most VCS do not, especially when trying to query the tree view of the commit (bitbucket / Gitlab)
Why is it important to keep track of the .git
If we follow the Go convention for private repo handling, and based on the current implementation of the RepoRootForImportPath it is recommended to use .git in the ref for private repos (due to GitLab returning fake metadata on go-get=1 for unauthenticated refs).
With this postulate, relying on this declarative model empowers the user and facilitates the handling on our side.
What is the impact
When having a ref with .git, the way to separate the root of the repo and potential subpath changes:
- without it, it uses HTTP requests
- with it, it uses the git CLI
I'll dig the implications a bit further on your #7708 (comment). But, a nice way of handling root and subpaths is to ask users to actually specify the .git. This enables us to have ways to load auth at the vcs.RepoRootForImportPath
There was a problem hiding this comment.
Left a couple nit comments, I'm not 100% sure about the .git stripping - if the VCS doesn't provide it, we should let the VCS error out with it, and not be super clever here.
Plus, I don't think it is just being clever: Google's logic for GitLab is currently a bit weird -> https://github.com/dagger/dagger/pull/7663/files#diff-a0ad18eec985477f121c56ba61b7956832670d35b67db059eac6f429085386b0L159. Here, the user referenced a ref without a .git, the metadata parsing from GitLab contained a .git, but as stated above, GitLab does not allow URLs with tree view on a commit when the URL contains a .git
There was a problem hiding this comment.
Honestly, fair enough point 🎉 I'm happy with it as it! There's maybe some edge cases where this might not work, e.g. if dagger.git and dagger were separate repos - but that feels sooooo edge-casey, that we can fix it when we get to it.
Thanks for all the work on this, will be awesome to have tests for this!
There was a problem hiding this comment.
I like this helper, but why is it neccessary to test against with and without .git? Effectively, this x6 the tests we need to run, x3 already seems like quite a few.
There was a problem hiding this comment.
It is not necessary per se. But I wanted to have at least a few runs to make sure that all the tests were passing even with it.
This .git is going to be tested with private git repos, so I removed them from the matrix 🙏 x3 is already a lot I agree
There was a problem hiding this comment.
nit: for readability, if these are part of the "expected" values for the test case, they should be prefixed with expected.
There was a problem hiding this comment.
You're right, this has been implemented 🙏
There was a problem hiding this comment.
Bleh, the fact we need to do this is annoying. Sounds good to me though, I'm sure we'll get bug reports from users, and we can fix these one-by-one as they come in.
nit: we should use the parsed urls and look at the host FYI, I think this would break with a http:// scheme?
There was a problem hiding this comment.
You're totally right, this has been extended ✅
d436644 to
7b97299
Compare
… tests to other VCS It turns out that Google's implementation rendering the VCS' URL does not take into account that they do not support the .git in the URL when querying for some specific commits. To circumvent it, we do 2 things: - add a check on the static analysis from the VCS, to actually trim the .git - Always trim on matched dynamic: GitLab returns false information that we cannot use as HTML URL. It doesn't bring any issue on other VCS, we will change it for more granularity afterwards Signed-off-by: Guillaume de Rouville <[email protected]>
It turns out that Google's implementation rendering the VCS' URL does not take into account that they do not support the .git in the URL when querying for some specific commits. To circumvent it, we do 2 things: - add a check on the static analysis from the VCS, to actually trim the .git - Always trim on matched dynamic: GitLab returns false information that we cannot use as HTML URL. It doesn't bring any issue on other VCS, we will change it for more granularity afterwards With manual tests on most VCS, their URL never contains the .git Signed-off-by: Guillaume de Rouville <[email protected]>
This implements a new testOnMultipleVCS helper function that wraps the current tests and enables a simple DX to test on multiple VCS. Affected tests have been updated too Signed-off-by: Guillaume de Rouville <[email protected]>
7b97299 to
b2005f9
Compare
|
Both failing tests are due to flakiness |
This extends the integration tests to other VCS.
To do so, it relies on a mirror of dagger-module-tests:
(more could be added over time, but most use provider behavior is contained in GitHub, GitLab and Bitbucket)
Current implementation extends the test suite, fixes a few inconsistencies around the VCS URL (URL should almost never contain the .git if present in the ref, as providers do not like them).
It also contains a naive change
HTMLURL()to make it compatible with all VCS. I wonder if we should not add an enum field representing the VCS inside thegitSourceModuletype, what do you all think ?Now, all integration test needed to run against GitHub should be run against vcsTests, with a helper function provided for ease of testing: testOnMultipleVCS
TODO (guillaume), but non blocking: