forked from toadharvard/asm-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_latest.sh
executable file
·82 lines (72 loc) · 1.76 KB
/
build_latest.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#/bin/sh -x
#set -ex
if [ $# -eq 0 ]
then
echo "No arguments supplied"
exit 1
fi
STRAT=
if [ "$1" = "build" ]; then
STRAT="$1"
elif [ "$1" = "test" ]; then
STRAT="$1"
else
echo "bad argument $1"
exit 1
fi
rm -fr _opam
#export OPAMSWITCH=4.10.0
eval $(opam env)
opam switch
which ocamlc
which ocaml
echo -e "section_start:`date +%s`:Detecting project to build\r\e[0K run the tests"
LASTDIR=`./detect_latest.sh`
if [ "$LASTDIR" = "." ]; then
git diff --name-only HEAD HEAD~1
echo "DO NOTHING"
else
cd $LASTDIR
if test -f build.sbt; then
# Skipping CIing of Scala projects
exit 0
fi
sh ../mylint.sh $LASTDIR
eval $(opam env)
if [ "$STRAT" = "build" ]; then
#[ -d _opam ] || cp -r ~/.opam/4.10 _opam
#sudo apt install m4 -y
#opam update
opam install --deps-only -t -y .
if [ $? != 0 ]; then
echo "Installing dependencies failed"
exit 1
fi
echo -e "section_start:`date +%s`:Formatting...\r\e[0KFormatting..."
dune build @fmt
if [ $? = 0 ]; then
echo "Formatting OK"
else
echo "Formatting is not decent. Either intergrate ocamlformat to VsCode"
echo " or apply it manualy before every commit https://dune.readthedocs.io/en/stable/formatting.html"
exit 1
fi
echo -e "section_start:`date +%s`:Building...\r\e[0KBuilding..."
dune build
if [ $? = 0 ]; then
echo "Running $STRAT in $LASTDIR finished\n"
else
exit 1
fi
else
echo -e "section_start:`date +%s`:Installing dependencies\r\e[0KInstalling dependencies..."
opam install --deps-only -t -y .
echo -e "section_start:`date +%s`:Testing...\r\e[0K Testing..."
dune runtest
if [ $? = 0 ]; then
echo "Running $STRAT in $LASTDIR finished\n"
else
exit 1
fi
fi
fi