Skip to content

chore/fix(core): add integration tests to other VCS - #7663

Merged
grouville merged 3 commits into
dagger:mainfrom
grouville:vcs-integration-tests
Jul 3, 2024
Merged

grouville merged 3 commits into
dagger:mainfrom
grouville:vcs-integration-tests

Conversation

@grouville

@grouville grouville commented Jun 14, 2024 •

Copy link
Copy Markdown
Member

This extends the integration tests to other VCS.

To do so, it relies on a mirror of dagger-module-tests:

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 the gitSourceModule type, 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

⚠️ This increases the integration test suite time linearly (with cache though)

TODO (guillaume), but non blocking:

  • Add automatic syncing (followup PR on both repo, after private repo support is done)

@grouville
grouville force-pushed the vcs-integration-tests branch from 8f080ba to 07ab873 Compare June 18, 2024 23:51
@grouville
grouville marked this pull request as ready for review June 19, 2024 04:53
@grouville
grouville force-pushed the vcs-integration-tests branch 2 times, most recently from 8cc6d4e to 301501d Compare June 19, 2024 06:01
@grouville grouville mentioned this pull request Jun 19, 2024
3 of 5 tasks
@grouville
grouville force-pushed the vcs-integration-tests branch 2 times, most recently from 2306eb4 to 611a900 Compare June 19, 2024 20:18
@grouville grouville changed the title chore: add integration tests to other VCS chore/fix(core): add integration tests to other VCS Jun 19, 2024

@jedevc jedevc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread engine/vcs/vcs.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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:

  • Repo represents a URL that a user can use to access the URL of the module, and all its variation (commit, tree view)
  • Root represents 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 .git makes 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 .git if 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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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!

Comment thread core/integration/module_config_test.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Comment thread core/integration/module_config_test.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: for readability, if these are part of the "expected" values for the test case, they should be prefixed with expected.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right, this has been implemented 🙏

Comment thread core/modulesource.go Outdated
Comment on lines 450 to 454

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're totally right, this has been extended ✅

@grouville
grouville force-pushed the vcs-integration-tests branch 2 times, most recently from d436644 to 7b97299 Compare July 3, 2024 18:43
grouville added 3 commits July 3, 2024 19:36
… 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]>
@grouville
grouville force-pushed the vcs-integration-tests branch from 7b97299 to b2005f9 Compare July 3, 2024 19:36
@grouville
grouville requested a review from jedevc July 3, 2024 19:38
@grouville

Copy link
Copy Markdown
Member Author

Both failing tests are due to flakiness

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