-
Notifications
You must be signed in to change notification settings - Fork 27
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
Support Git in x-opam-monorepo-opam-repositories
#317
Support Git in x-opam-monorepo-opam-repositories
#317
Conversation
ba204e7
to
a950480
Compare
Thanks for looking into this! The main problem with this PR at the moment is that by using I think here we need an alternate version of I think we should instead have a thin and simple cache layer in For this to work properly, I think it would be reasonable to only accept remote VCS urls (e.g. no straight tarballs) and to resolve all VCS URLs to a commit hash, similarly to what we do for packages sources already. What do you think? |
Also we could eventually store archives in that temporary cache instead of the full source tree, similarly to what opam does but that can be done later! |
I looked at the OPAM API and it supports specifying a dedicated The issue with not supporting archives is that to support #315 by reading the list of repos from the switch we need to support archives since this is the most common way to retrieve the That said, I'm currently trying to figure out how OPAM actually uses the |
We had a discussion about this exact problem when you first suggested to move to a single solver and I think we agreed that having a special rule to turn I even remember hearing @dra27 mentioning they were considering dropping the use of tarballs for repos in opam. What do you think? |
x-opam-monorepo-opam-repositories
@NathanReb Sorry, took a while to get back to this but I finally managed to continue on this (mostly testing that things work as desired). I've implemented it to support Git repos specifically. What it does is the following:
There is a small test where it asserts that the checkout works and the lockfile URLs are updated. I didn't add tests for the cache because that is supposed to be functionality of I also tested this on opam-monorepo itself, adding these lines to the
Leaving out the overlays caused the usual solver failures with missing dune-versions, exactly how it works at the moment when the overlays repo is not added to the switch. |
ab8c043
to
a49869a
Compare
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 looks great! Thanks for your hard work on this!
I'm happy that we can reuse opam's git cache implementation, saves us a lot of troubles.
I have no comments about the code and the tests, it all looks great.
My only concern is how we handle resolution of repo URLs to an exact revision. It seems that we pull the sources from the user provided URL and then look at what revision we got.
I can see two problems with this approach:
- we might cache based on an ambiguous URL, e.g.
git+https://github.com/ocaml/opam-repository#master
is what gets hashed and therefore I'm not entirely sure whether the current implementation will ever try to fetch it again as long as it is cached, meaning a user might wonder why they're not getting the latest version - It mix the two concerns of pulling the sources and making the source config unambiguous.
I'm not exactly sure about 1
as I don't fully understand how the cache works yet so please correct me if I misinterpreted how things were run here. I think either way, this should be fairly easy to add to the test by pushing a new version of a package on the default branch of the local git repo in the cram test.
b8d7aa8
to
65aa663
Compare
|
Yeah sorry this was poorly explained. For inidividual packages which have a git source URL (a pinned package for instance), we first turn this potentially ambiguous URL into an "exact" one, i.e. one that ends with What I meant in my second point was that we could do something similar here and separate things in two steps:
If the opam cache helps us with this I'm also happy with the current implementation. It's slightly harder to figure out this resolution happens with the current code but as long as it works I'm happy with this. Maybe adding a comment or a bit of documentation here would help maintain this code in the future? |
CHANGES: ### Added - Add support for specifying remote URLs in `x-opam-monorepo-repositories` (tarides/opam-monorepo#284, tarides/opam-monorepo#317, @Leonidas-from-XIV) ### Fixed - Enable locking of packages with depexts even with uninitialized system package manager state (tarides/opam-monorepo#322, @Leonidas-from-XIV) - Fix a bug where `pull` would crash if the lock file contained no package to vendor (tarides/opam-monorepo#321, @NathanReb) - Display a better error message when the depext command fails when getting the status of the packages (tarides/opam-monorepo#258, tarides/opam-monorepo#323, @RyanGibb, @Julow) - Take `archive-mirrors` from the global opam configuration into account to allow more local caches (tarides/opam-monorepo#337, @hannesm) - Log at WARN level when opam-monorepo chooses a source for a package that doesn't match the package's version (tarides/opam-monorepo#352, @reynir)
The main issue with this code is that it is difficult to test, since we probably don't want our tests to do IO with the outside world, since it creates issues with sandboxing and dependencies on other services being up and reachable.
I tested it by adding
https://opam.ocaml.org
to thex-opam-monorepo-repositories
invendored.opam
and it indeed outputs a lock file that has e.g. a newer dune than what we expect in the test.Fixes: #284