setup-ocaml
setup-ocaml copied to clipboard
Feature: Create a switch by default when no opam files are present
I want to make a test that just installs dune and ocamlformat and runs dune fmt
. I don't want to install all the dependencies of my
project - just dune and ocamlformat.
Currently this doesn't work:
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.14.1
- uses: actions/checkout@v3
- run: opam install -y dune ocamlformat
The error is:
Run opam install -y dune ocamlformat
[ERROR] No switch is currently set. Please use 'opam switch' to set or install a switch
'opam install -y dune ocamlformat' failed.
Error: Process completed with exit code 50.
This is part of the log here: https://github.com/gridbugs/llama/actions/runs/5687888861/job/15416935603
I think I could work around this by checking out the project before setting up ocaml but that would waste time downloading dependencies that I don't need for this test.
I think I could work around this by checking out the project before setting up ocaml but that would waste time downloading dependencies that I don't need for this test.
I believe the undesired behaviour can be avoided by disabling pinning:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.14.1
opam-pin: false
I use a dedicated workflow for formatting here: https://github.com/xapi-project/xen-api/blob/master/.github/workflows/format.yml
The next major refactoring will improve the handling of such things, but I've been working on a lot of real world stuff lately and the ETA is still not clear... @psafont's suggestion is the best in the short term.
I tried this but got the same error:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.14.1
opam-pin: false
opam-depext: false
Why would disabling pinning also cause it to create a switch?