#! /usr/bin/env bash
#
# Set up opam and install opam packages required to build and test testo
#
# This is used by the CI build.
#
set -eu

eval "$(opam env)"

# Set up the opam repo (skip if already done, e.g. from a restored cache).
if ! opam repo list | grep -q '^github\b'; then
  opam repo add --all-switches -k git \
    github https://github.com/ocaml/opam-repository.git
  opam repo remove default
fi
# no need for 'opam update'

opam install --deps-only --with-test -y \
  ./testo-diff.opam \
  ./testo-util.opam \
  ./testo.opam \
  ./testo-lwt.opam

# Install dev tools separately (--with-dev-setup requires opam >= 2.1).
# The version must match what's used locally (see testo.opam).
opam install -y ocamlformat.0.28.1
