Skip to content

Commit ccb0589

Browse files
committed
Run OCaml format check as part of CI tests
1 parent b1f60f8 commit ccb0589

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ format:
7575
dune build @fmt --auto-promote
7676

7777
checkformat:
78-
dune build @fmt
78+
node scripts/check_format.sh
7979

8080
clean-gentype:
8181
make -C jscomp/gentype_tests/typescript-react-example clean

scripts/check_format.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
warningYellow='\033[0;33m'
4+
successGreen='\033[0;32m'
5+
reset='\033[0m'
6+
7+
case "$(uname -s)" in
8+
Darwin|Linux)
9+
echo "Checking code formatting..."
10+
if opam exec -- dune build @fmt; then
11+
printf "${successGreen}✅ OCaml code formatting ok.${reset}\n"
12+
else
13+
printf "${warningYellow}⚠️ OCaml code formatting issues found.${reset}\n"
14+
exit 1
15+
fi
16+
;;
17+
*)
18+
# Does not work on Windows
19+
echo "OCaml code formatting check skipped for this platform."
20+
esac

scripts/ciTest.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ async function runTests() {
9090
cwd: path.join(__dirname, ".."),
9191
stdio: [0, 1, 2],
9292
});
93+
94+
cp.execSync("bash scripts/check_format.sh", {
95+
cwd: path.join(__dirname, ".."),
96+
stdio: [0, 1, 2],
97+
});
9398
}
9499
}
95100

scripts/test_syntax.sh

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,3 @@ fi
115115

116116
rm -r temp/
117117
popd
118-
119-
# Check format (does not work on Windows)
120-
case "$(uname -s)" in
121-
Darwin|Linux)
122-
echo "Checking code formatting..."
123-
if opam exec -- dune build @fmt; then
124-
printf "${successGreen}✅ Code formatting ok.${reset}\n"
125-
else
126-
printf "${warningYellow}⚠️ Code formatting failed.${reset}\n"
127-
exit 1
128-
fi
129-
;;
130-
esac

0 commit comments

Comments
 (0)