-
Notifications
You must be signed in to change notification settings - Fork 40
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
Check if switch exists before creating #40
Conversation
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.
Changes need to be made in both the Windows and Unix install scripts (even if the former is not at present using caching).
Just for general reference, the venerable OCaml Travis CI Scripts are a good source of opam fu. The test you're proposing is very verbose to harden to deal with substrings and spaces - the better pattern is opam switch set "$1" || opam switch create "$1" "$1"
(cf. https://github.com/ocaml/ocaml-ci-scripts/blob/master/.travis-ocaml.sh#L307)
Very nice trick! I read Opam's manual in search of such a solution, but didn't figure this one out! I looked at the Windows installation script and it does not seem to use |
Yes, I did, but I don't recommend that users use it. Because at this time, there are very few ways for users to strictly cache using |
@smorimoto Interesting! What kind of issue could happen with this setup? |
Well, this change is not bad for hackers. (So I'm not trying to argue against this PR.) |
Oh, good point - it always |
Signed-off-by: Sora Morimoto <sora@morimoto.io>
Signed-off-by: Sora Morimoto <sora@morimoto.io>
A possible issue at this point is that |
It's also fragile without opam lock. |
This looks good to me. If @dra27 doesn't request additional changes to this, I will merge this and release the new patch version. |
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.
LGTM!
I'm out now, so I'll release a new version when I get home. |
Thanks @tmattio! |
Great, thanks for your work on caching 😉 |
Well, that was important to our company, so anytime! |
Hi!
I noticed that @smorimoto worked on caching on a separate repo and tried to integrate https://github.com/avsm/hello-world-action-ocaml/blob/with-cache/.github/workflows/workflow.yml in Opium (rgrinberg/opium#183)
Unfortunately, it seems that caching the
~/.opam
directory does not work with multiple compilers at the moment because ocaml-setup usesopam switch create
even if a switch with the same name already exists.This PR adds a check that will only create a switch if it does not already exist. The check is really basic, maybe there's a better way to do this with opam?