2022-07-18 18:08:46 +03:00
|
|
|
# Stage 1: setup an opam switch with all dependencies installed
|
|
|
|
# (only depends on the opam files)
|
2023-02-28 20:16:56 +03:00
|
|
|
FROM ocamlpro/ocaml:4.14-2023-02-26 AS dev-build-context
|
2022-07-18 18:08:46 +03:00
|
|
|
|
|
|
|
# pandoc is not in alpine stable yet, install it manually with an explicit repository
|
2022-12-16 16:24:16 +03:00
|
|
|
RUN sudo apk add pandoc --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community/
|
2022-07-18 18:08:46 +03:00
|
|
|
|
|
|
|
RUN mkdir catala
|
|
|
|
WORKDIR catala
|
|
|
|
|
|
|
|
# Get only the opam files at this stage to allow caching
|
|
|
|
ADD --chown=ocaml:ocaml *.opam ./
|
|
|
|
|
|
|
|
# trigger the selection of catala dev tools in opam
|
|
|
|
ENV OPAMVAR_cataladevmode=1
|
|
|
|
ENV OPAMVAR_catalaz3mode=1
|
|
|
|
|
|
|
|
# Get a switch with all the dependencies installed
|
|
|
|
RUN opam --cli=2.1 switch create catala ocaml-system && \
|
|
|
|
opam --cli=2.1 pin . --no-action && \
|
|
|
|
opam --cli=2.1 install . --with-test --with-doc --depext-only && \
|
|
|
|
opam --cli=2.1 install . --with-test --with-doc --deps-only && \
|
|
|
|
opam clean
|
|
|
|
# Note: just one `opam switch create .` command should be enough once opam 2.1.3 is released (opam#5047 ; opam#5185)
|
|
|
|
|
|
|
|
|
|
|
|
# Stage 2: get the whole repo, run checks and builds
|
2022-08-01 20:56:04 +03:00
|
|
|
FROM dev-build-context
|
2022-07-18 18:08:46 +03:00
|
|
|
|
|
|
|
# Get the full repo
|
|
|
|
ADD --chown=ocaml:ocaml . .
|
|
|
|
|
|
|
|
# Prepare extra local dependencies
|
2023-03-02 13:47:51 +03:00
|
|
|
RUN opam exec -- make dependencies-python dependencies-js pygments
|
2022-07-18 18:08:46 +03:00
|
|
|
|
|
|
|
# OCaml backtraces may be useful on failure
|
|
|
|
ENV OCAMLRUNPARAM=b
|
2023-02-28 19:26:49 +03:00
|
|
|
# Make sure warnings are treated as errors (variable used in Makefile, profile
|
|
|
|
# defined in ./dune)
|
|
|
|
ENV DUNE_PROFILE=check
|
2022-07-18 18:08:46 +03:00
|
|
|
|
|
|
|
# Check promoted files (but delay failure)
|
|
|
|
RUN opam exec -- make check-promoted > promotion.out 2>&1 || touch bad-promote
|
|
|
|
|
|
|
|
# Check the build
|
|
|
|
RUN opam exec -- make build
|
|
|
|
|
|
|
|
# Check tests & all alt targets
|
2022-07-22 17:30:59 +03:00
|
|
|
RUN OCAMLRUNPARAM=b opam exec -- make all -B
|
2022-07-18 18:08:46 +03:00
|
|
|
|
|
|
|
# Forward results of promotion check
|
|
|
|
RUN if [ -e bad-promote ]; then \
|
|
|
|
echo "[ERROR] Some promoted files were not up-to-date"; \
|
|
|
|
cat promotion.out; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|