Add support for OCaml builds on Travis-CI

Yesterday, I wanted to setup automatic build for a project written in OCaml, using Travis-CI. However, there is no preinstalled OCaml environment available there, so I wrote my custom .travis.yml file:

language: c
before_install: sudo apt-get update -qq
install: sudo apt-get -y install ocaml
before_script: ocaml --version
script: sh && ./a.out
os: linux
dist: focal

(Where is a simple script that calls ocamlopt with all my files in the project)

What about adding OCaml support directly to Travis-CI?

I saw that the system which converts the .travis.yml file to a build file is here:

Starting with the file lib/travis/build/script.rb, and then adding a file lib/travis/build/script/ocaml.rb, I think we can get it to work. Then we might have to update the documentation as well, but easy part.

Issues are not enabled on this repository, so I will try to do my own pull request, and post an update here with what I end with.

1 Like

Update: created a pull request, but I’m not sure of what I did (went for a draft)

1 Like

I don’t know how it works to add support directly in travis. In the past I used to use ocaml-ci-scripts/ at master · ocaml/ocaml-ci-scripts · GitHub (for an example you can refer to owl/.travis.yml at master · owlbarn/owl · GitHub)

1 Like

@NathanFallet Now I can use this command to install ocamlopt in my PC before I execute the whole program. :slightly_smiling_face: