-
Notifications
You must be signed in to change notification settings - Fork 0
/
.ocaml-gh
61 lines (49 loc) · 1.38 KB
/
.ocaml-gh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
export PROJECT=rea-ml
export GIT_DEPS=()
export [email protected]:polytypic/$PROJECT.git
export TEST_DIR=src/test/Rea
ocaml-gh-ci-before() {
extract-test-from-readme
extract-test-from-signature
generate-build-files
}
extract-test-from-readme() {
update-file-content \
"$TEST_DIR/Introduction.ml" \
"(* DO NOT EDIT! THIS IS AUTO EXTRACTED FROM THE README. *)
$(awk 'BEGIN {out=0}
/^```ocaml$/ {out=1}
/^```$/ {out=0}
/^[^`].*/ {if (out) print $0}' < README.md \
| (cd "$TEST_DIR" && opam exec -- ocamlformat --impl -))"
}
extract-test-from-signature() {
update-file-content \
"$TEST_DIR/Signature.ml" \
"(* DO NOT EDIT! THIS IS AUTO EXTRACTED FROM THE SIGNATURE. *)
[@@@ocaml.warning \"-32\"] (* Disable unused value warning. *)
$(awk 'BEGIN {out=0}
/^{\[$/ {out=1}
/^\]}$/ {out=0}
/^[^{\]].*/ {if (out) print $0}' < src/main/Rea/Rea.mli \
| (cd "$TEST_DIR" && opam exec -- ocamlformat --impl -))"
}
generate-build-files() {
update-file-content dune-project '(lang dune 3.3)'
local TEST_FILES
TEST_FILES=$(cd $TEST_DIR && echo *.ml)
update-file-content \
"$TEST_DIR/dune" \
"(tests
(names ${TEST_FILES//.ml/})
(libraries Rea))"
}
update-file-content() {
local FILE="$1"
local CONTENT="$2"
if ! [ -f "$FILE" ] || \
[ "$(cat "$FILE")" != "$CONTENT" ] ; then
echo "$CONTENT" > "$FILE"
fi
}