Basic GitLab CI configuration

I’ve now hit an “odd bug”, so you’ve been proven right here. :smile:

For example, any library that depends upon ocamlc -where during its build will fail to install properly. Specifically in my experience, num does this, which results in its artifacts being spread between the local and global switches, resulting in a variety of bad outcomes.

As for relocatability, I now see that the switch’s path is hardcoded in a bunch of different places within its built compilers (relevant to the num example, the absolute path to stdlib is defined in lib/ocaml/caml/s.h).

Since I still really don’t want to pay for an opam create as part of my CI build, I’m now always using the global switch, but I do move it in its entirety into my project working directory right at the end of a build stage. This makes it accessible to the caching mechanism. e.g.:

prep:
  stage: prep
  only:
    - branches
  cache:
    key: "$CI_COMMIT_REF_SLUG"
    paths:
      - _opam
      - node_modules
  script:
    - '[ ! -d _opam ] || (rm -rf ~/.opam/4.07 && mv _opam ~/.opam/4.07)'
    - eval $(opam env)
    - opam switch
    - opam install --deps-only -t -y .
    - mv ~/.opam/4.07 _opam