Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to OCaml 4.12 #408

Merged
merged 7 commits into from Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci-macosx.sh
Expand Up @@ -6,7 +6,7 @@ brew update
brew install pkg-config
brew install opam
brew install libev
opam init -y --compiler=4.05.0
opam init -y --compiler=4.12.0
eval $(opam env)

opam install -y -j 2 . --deps-only --locked
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/static-builds.yml
Expand Up @@ -46,20 +46,16 @@ jobs:
sw_vers
system_profiler SPSoftwareDataType
uname -a
# Need unreleased 2.1.0~rc
# - name: Retrieve opam
# run: |
# mkdir "$HOME/bin"
# wget https://github.com/ocaml/opam/releases/download/2.1.0-beta2/opam-2.1.0-beta2-x86_64-macos -O $HOME/bin/opam
# chmod a+x $HOME/bin/opam
# echo "$HOME/bin" >> $GITHUB_PATH
- name: Install latest opam
- name: Retrieve opam
run: |
brew install opam --HEAD
mkdir "$HOME/bin"
wget https://github.com/ocaml/opam/releases/download/2.1.0/opam-2.1.0-x86_64-macos -O $HOME/bin/opam
chmod a+x $HOME/bin/opam
echo "$HOME/bin" >> $GITHUB_PATH
- name: Prepare build environment
run: |
opam init -a --bare
opam switch create . ocaml-base-compiler 'dune<2' --deps-only
opam switch create . ocaml-base-compiler --deps-only
- name: Build the binaries
run: |
opam exec -- make LINKING_MODE=static
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Expand Up @@ -6,14 +6,10 @@ _opam
.opam-switch
Makefile.local
docker/
src/ppx-metaquot/ast_lifter.ml

learnocaml-server.byte
learn-ocaml.install

src/grader/embedded_cmis.ml
src/grader/embedded_grading_cmis.ml

demo-repository/exercises/*.stderr
demo-repository/exercises/*.stdout
demo-repository/exercises/*.outcomes
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
@@ -1,15 +1,15 @@
FROM ocaml/opam:alpine-3.13-ocaml-4.05 as compilation
FROM ocaml/opam:alpine-3.13-ocaml-4.12 as compilation
LABEL Description="learn-ocaml building" Vendor="OCamlPro"

WORKDIR learn-ocaml
WORKDIR /home/opam/learn-ocaml

COPY learn-ocaml.opam learn-ocaml.opam.locked learn-ocaml-client.opam ./
COPY learn-ocaml.opam learn-ocaml.opam.locked learn-ocaml-client.opam learn-ocaml-client.opam.locked ./
RUN sudo chown -R opam:nogroup .

ENV OPAMYES true
RUN echo 'archive-mirrors: [ "https://opam.ocaml.org/cache" ]' >> ~/.opam/config \
&& opam repository set-url default http://opam.ocaml.org \
&& opam switch 4.05 \
&& opam switch 4.12 \
&& echo 'pre-session-commands: [ "sudo" "apk" "add" depexts ]' >> ~/.opam/config \
&& opam install . --deps-only --locked

Expand Down Expand Up @@ -42,7 +42,7 @@ WORKDIR /learnocaml

COPY --from=compilation /home/opam/install-prefix/bin/learn-ocaml-client /usr/bin

ENTRYPOINT ["dumb-init","learn-ocaml-client"]
ENTRYPOINT ["dumb-init","/usr/bin/learn-ocaml-client"]

LABEL org.opencontainers.image.title="learn-ocaml-client"
LABEL org.opencontainers.image.description="learn-ocaml command-line client"
Expand All @@ -68,7 +68,7 @@ WORKDIR /home/learn-ocaml

COPY --from=compilation /home/opam/install-prefix /usr

ENTRYPOINT ["dumb-init","learn-ocaml","--sync-dir=/sync","--repo=/repository"]
ENTRYPOINT ["dumb-init","/usr/bin/learn-ocaml","--sync-dir=/sync","--repo=/repository"]
CMD ["build","serve"]

LABEL org.opencontainers.image.title="learn-ocaml"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.test-client
@@ -1,7 +1,7 @@
# This Dockerfile is useful for testing purposes
# to ensure learn-ocaml-client can be built alone from learn-ocaml-client.opam

FROM ocaml/opam:alpine-3.13-ocaml-4.05 as compilation
FROM ocaml/opam:alpine-3.13-ocaml-4.12 as compilation
LABEL Description="learn-ocaml building" Vendor="OCamlPro"

WORKDIR learn-ocaml
Expand All @@ -13,7 +13,7 @@ RUN sudo chown -R opam:nogroup .
ENV OPAMYES true
RUN echo 'archive-mirrors: [ "https://opam.ocaml.org/cache" ]' >> ~/.opam/config \
&& opam repository set-url default http://opam.ocaml.org \
&& opam switch 4.05 \
&& opam switch 4.12 \
&& echo 'pre-session-commands: [ "sudo" "apk" "add" depexts ]' >> ~/.opam/config \
&& opam pin add -n -y -k path learn-ocaml-client . \
&& opam install learn-ocaml-client --deps-only
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Expand Up @@ -57,7 +57,7 @@ testrun: build install
learn-ocaml build --repo $(REPO) -j1
rm -rf www/css
ln -s ../static/css www
learn-ocaml serve
LEARNOCAML_SERVER_NOCACHE=1 learn-ocaml serve

docker-images: Dockerfile learn-ocaml.opam
@rm -rf docker
Expand Down Expand Up @@ -95,7 +95,7 @@ travis: # From https://stackoverflow.com/questions/21053657/how-to-run-travis-ci
static-binaries:
./scripts/static-build.sh

BINARIES = src/main/learnocaml_client.bc src/main/learnocaml_main.bc src/main/learnocaml_server_main.exe
BINARIES = src/main/learnocaml_client.bc.exe src/main/learnocaml_main.bc.exe src/main/learnocaml_server_main.exe

.PHONY: detect-libs
detect-libs:
Expand All @@ -104,6 +104,7 @@ detect-libs:
baseid="detect-libs.$$$$"; echo ...; \
$(MAKE) LINKING_MODE=dynamic OCAMLPARAM="_,verbose=1" > $$baseid.log 2>&1; \
for bin in $(BINARIES); do \
rm -f "_build/default/$$bin"; \
base=$${bin#src/main/}; base=$${base%.*}; \
grep -e "'$$bin'" $$baseid.log > $$baseid.$$base.log; \
printf "%s: " "$$base"; \
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/step-7.md
Expand Up @@ -34,7 +34,7 @@ exception OutOfRange of int
For the first graded function, we want to be sure the student function
returned both the right `Ok` output and the right exception with its
is correct argument. The predefined tester that compares both possible
results with `Pervasives.compare` function is called `test`. This is
results with `Stdlib.compare` function is called `test`. This is
obviously the default value of optional argument [~test].

```ocaml
Expand Down Expand Up @@ -192,7 +192,7 @@ let p_list l =
let t = List.fold_left (fun a x -> a && p x) true l in
if t then
(* Check that there is at least two different elements *)
let l = List.sort_uniq (Pervasives.compare) l in
let l = List.sort_uniq (Stdlib.compare) l in
if List.length l > 1 then true else false
else false

Expand All @@ -202,4 +202,4 @@ let exercise_2 =
~gen:0
~test:(test_eq_ok (fun x _ -> p_list x))
[10 ; 20]
```
```
2 changes: 1 addition & 1 deletion dune
Expand Up @@ -7,7 +7,7 @@
)

(env
(release (flags -safe-string -w +a-4-42-44-45-48-3)
(release (flags -safe-string -w +a-4-42-44-45-48-3-58)
(ocamlc_flags)
(ocamlopt_flags))
)
3 changes: 2 additions & 1 deletion dune-project
@@ -1,3 +1,4 @@
(lang dune 1.7)
(lang dune 2.3)
(name learn-ocaml)
(version 0.12)
(allow_approximate_merlin)
14 changes: 7 additions & 7 deletions learn-ocaml-client.opam
Expand Up @@ -21,24 +21,24 @@ depends: [
"asak"
"gg"
"vg"
"cohttp" {>= "1.0.0" & < "2.0.0"}
"cohttp-lwt-unix" {>= "1.0.0" & < "2.0.0"}
"cohttp" {>= "2.0.0"}
"cohttp-lwt-unix" {>= "2.0.0"}
"ssl" {= "0.5.5"}
"digestif" {>= "0.7.1"}
"dune" {>= "1.11.4" & <= "2.0.1"}
"dune"
"ezjsonm"
"lwt" {>= "4.0.0"}
"lwt_ssl"
"ocaml" {= "4.05.0"}
"ocaml" {= "4.12.0"}
"ocamlfind" {build}
"ocp-indent-nlfork"
"ocp-ocamlres" {>= "0.4"}
"ocplib-json-typed" {= "0.6"}
"ocplib-json-typed" {>= "0.7"}
"ipaddr" {= "2.8.0" }
"cstruct" {>= "3.3.0"}
"ppx_tools"
"ppx_sexp_conv" {= "v0.9.0"}
"ppx_fields_conv" {= "v0.9.0"}
"ppx_sexp_conv"
"ppx_fields_conv"
]
build: [
["dune" "build" "@install" "-p" name "-j" jobs]
Expand Down
107 changes: 107 additions & 0 deletions learn-ocaml-client.opam.locked
@@ -0,0 +1,107 @@
opam-version: "2.0"
name: "learn-ocaml-client"
version: "0.12"
synopsis: "The learn-ocaml client"
description: """\
This contains the binaries to interact with the learn-ocaml
platform from the command line."""
maintainer: "Yann Régis-Gianas"
authors: [
"Benjamin Canou (OCamlPro)"
"Çağdaş Bozman (OCamlPro)"
"Grégoire Henry (OCamlPro)"
"Louis Gesbert (OCamlPro)"
"Pierrick Couderc (OCamlPro)"
]
license: "MIT"
homepage: "https://github.com/ocaml-sf/learn-ocaml"
bug-reports: "https://github.com/ocaml-sf/learn-ocaml/issues"
depends: [
"angstrom" {= "0.15.0"}
"asak" {= "0.3"}
"astring" {= "0.8.5"}
"base" {= "v0.14.1"}
"base-bigarray" {= "base"}
"base-bytes" {= "base"}
"base-threads" {= "base"}
"base-unix" {= "base"}
"base64" {= "3.5.0"}
"bigarray-compat" {= "1.0.0"}
"bigstringaf" {= "0.8.0"}
"biniou" {= "1.2.1"}
"cmdliner" {= "1.0.4"}
"cohttp" {= "4.0.0"}
"cohttp-lwt" {= "4.0.0"}
"cohttp-lwt-unix" {= "4.0.0"}
"conduit" {= "1.3.0"}
"conduit-lwt" {= "1.3.0"}
"conduit-lwt-unix" {= "1.3.0"}
"conf-libssl" {= "3"}
"conf-pkg-config" {= "2"}
"conf-which" {= "1"}
"cppo" {= "1.6.7"}
"csexp" {= "1.5.1"}
"cstruct" {= "5.0.0"}
"digestif" {= "1.0.0"}
"dune" {= "2.9.0"}
"dune-configurator" {= "2.9.0"}
"easy-format" {= "1.3.2"}
"eqaf" {= "0.7"}
"ezjsonm" {= "1.1.0"}
"fieldslib" {= "v0.14.0"}
"fmt" {= "0.8.9"}
"gg" {= "0.9.3"}
"hex" {= "1.4.0"}
"ipaddr" {= "2.8.0"}
"jbuilder" {= "1.0+beta20.2"}
"js_of_ocaml" {= "3.9.0"}
"js_of_ocaml-compiler" {= "3.9.1"}
"js_of_ocaml-ppx" {= "3.9.0"}
"jsonm" {= "1.0.1"}
"logs" {= "0.7.0"}
"lwt" {= "5.4.1"}
"lwt_ssl" {= "1.1.3"}
"magic-mime" {= "1.1.3"}
"menhir" {= "20210419"}
"menhirLib" {= "20210419"}
"menhirSdk" {= "20210419"}
"mmap" {= "1.1.0"}
"num" {= "1.4"}
"ocaml" {= "4.12.0"}
"ocaml-compiler-libs" {= "v0.12.3"}
"ocaml-config" {= "2"}
"ocaml-migrate-parsetree" {= "1.8.0"}
"ocaml-options-vanilla" {= "1"}
"ocaml-syntax-shims" {= "1.0.0"}
"ocamlbuild" {= "0.14.0"}
"ocamlfind" {= "1.9.1"}
"ocp-indent-nlfork" {= "1.5.4"}
"ocp-ocamlres" {= "0.4"}
"ocplib-endian" {= "1.1"}
"ocplib-json-typed" {= "0.7.1"}
"omd" {= "1.3.1"}
"parsexp" {= "v0.14.1"}
"pprint" {= "20200410"}
"ppx_derivers" {= "1.2.1"}
"ppx_fields_conv" {= "v0.14.1"}
"ppx_sexp_conv" {= "v0.14.1"}
"ppx_tools" {= "6.3"}
"ppxlib" {= "0.15.0"}
"re" {= "1.9.0"}
"result" {= "1.5"}
"seq" {= "0.2.2"}
"sexplib" {= "v0.14.0"}
"sexplib0" {= "v0.14.0"}
"ssl" {= "0.5.5"}
"stdlib-shims" {= "0.3.0"}
"stringext" {= "1.6.0"}
"topkg" {= "1.0.3"}
"uchar" {= "0.0.2"}
"uri" {= "4.2.0"}
"uri-sexp" {= "4.2.0"}
"uutf" {= "1.0.2"}
"vg" {= "0.9.4"}
"yojson" {= "1.7.0"}
]
build: ["dune" "build" "@install" "-p" name "-j" jobs]
dev-repo: "git+https://github.com/ocaml-sf/learn-ocaml"
19 changes: 10 additions & 9 deletions learn-ocaml.opam
Expand Up @@ -17,15 +17,15 @@ depends: [
"base" {>= "v0.9.4"}
"base64"
"cmdliner"
"cohttp" {>= "1.0.0" & < "2.0.0"}
"cohttp-lwt" {>= "1.0.0" & < "2.0.0"}
"cohttp-lwt-unix" {>= "1.0.0" & < "2.0.0"}
"cohttp" {>= "2.0.0"}
"cohttp-lwt" {>= "2.0.0"}
"cohttp-lwt-unix" {>= "2.0.0"}
"conf-git"
"decompress" {= "0.8.1"}
"digestif" {>= "0.7.1"}
"dune" {>= "1.11.4"}
"easy-format" {>= "1.3.0" }
"ipaddr" {= "2.8.0" }
"ipaddr" {>= "2.8.0" }
"ezjsonm"
"js_of_ocaml" {>= "3.3.0"}
"js_of_ocaml-compiler" {>= "3.3.0"}
Expand All @@ -40,13 +40,14 @@ depends: [
"magic-mime"
"markup"
"markup-lwt"
"ocaml" {= "4.05.0"}
"ocaml" {= "4.12.0"}
"ocamlfind" {build}
"ocp-indent-nlfork"
"ocp-ocamlres" {>= "0.4"}
"ocplib-json-typed" {= "0.6"}
"odoc" {build & >= "1.3.0"}
"omd" {<= "1.3.1"}
"ocp-ocamlres" {= "0.4"}
"ocplib-json-typed" {>= "0.6"}
"ocplib-json-typed-browser" {>= "0.6"}
"odoc" {build}
"omd"
"pprint"
"ppx_cstruct"
"ppx_tools"
Expand Down