OCaml Travis and GitHub CI

What is the current best practice to run OCaml CI on Travis for basic projects that have an opam file? I suspect it is using .travis-docker.sh in ocaml-ci-scripts but this is not documented in the README and I learned about it by peeking into other OCaml projects. If so, this is somewhat counter intuitive as you naively would consider something with ocaml and opam in the name first.

The instructions in https://github.com/ocaml/ocaml-ci-scripts/blob/master/README-travis.md are accurate. The Travis Docker is for more advanced cases.

For new projects, you may also want to consider something like: GitHub Actions for OCaml / opam now available as it is quite closely integrated in with the rest of GitHub (including secrets management).

3 Likes

The README has this high-level structure:

  1. Plain OCaml Install, .travis-ocaml.sh
  2. opam Package, .travis-opam.sh
  3. GCC and binutils
  4. Ubuntu Trusty
  5. Mirage Unikernels, .travis-mirage.sh
  6. Pushing OCamldoc docs to Github page, .travis-docgen.sh

If .travis-opam.sh is the common case, could it move to the top? I’ll take a look at GitGub Actions.

Looking at GitHub Actions, they seem to be easy to set up. I’m trying to run them with OCaml 4.09 and notice that this leads to the download of OCaml 4.09 sources and compilation as part of the action. This creates a little unease with me about the resources this consumes for every push to the repo but maybe I’m overthinking this. On the positive side, at leat the network traffic is internal to GitHub unlike when running Travis CI.

2 Likes

That’s very true; it is possible to enable caching which is being worked on a couple of ways:

  • @smorimoto has been working with the GitHub team to optimise their actions/cache plugin to be much faster.
  • We then need to make caching work across all the supported operating systems. Since GHA works so well across Windows/macOS/Linux, I’m reluctant to add a feature which doesn’t work across all three. So someone needs to figure out how to get it to work on Windows/Cygwin (which is using @fdopen’s fork until we roll in the native Windows patchset into a released opam). For now, I figured a slightly slower non-caching version is still useful, but ideas/PRs very welcome to help with that.
2 Likes

I think in terms of resources (energy in particular) it is not clear at all what the correct tradeoff is between downloading large Docker images versus downloading sources and compiling them. This applies to Travis and GH Actions. I don’t mind if a build takes long but when a local build takes 1 second and CI build 8 minutes, I do wonder whether it is responsible to use these cloud builds at all.

1 Like

I think that’s a very valid point. Though not exactly what you asked about, you may be interested in looking at Circle CI’s caching: Caching Dependencies - CircleCI

I’ve used that in the past and that mechanism saved me a lot of build time. I also don’t know what the situation would be for Windows either, if that is important to you.

2 Likes

Note that Travis has a concept of community supported languages.

I wonder if OCaml is still not first class on Travis only because no one bothered to go through that process yet.

2 Likes

@dmbaturin that sounds like an excellent idea, would you have the time to build a group to do this?

@gasche I’m happy to volunteer, though we still need two more people. We also need to decide how and where to coordinate that development (maybe make a forum thread for it?).

I will discuss this at Citrix in Cambridge. We use Travis for OCaml heavily and would be interested to improve resource consumption.

1 Like