Skip to content

Commit bce87d9

Browse files
authored
Forgot to reactivate windows CI test (#192)
GitHub Action checks out code on windows on CRLF. This PR tried many methods of just using CRLF or converting to LF. Tips: - `print_endline` and multiline strings on windows ocaml fork use CRLF. `open_in_bin` + `really_input_string` too (!) - `dos2unix` hangs when used inside `test.sh` but doesn't hang inside `ci.yml`. - `cat` and `pipe` don't change line ending. - use `cat -A` to check for line endings visibly. Life saving debugger. - `sed "s/\r\n/\n/g"` apparently doesn't work on CI windows... - `git checkout` + `ocaml-env` bug (?) fdopen/opam-repository-mingw#92 Whichever method of directly using CRLF doesn't work because of the last issue; it's likely that I'm being dumb... So right now we set git to checkout using LF, let our native code output to CRLF, then instead of `dos2unix` or `sed`, use a perl one-liner in `test.sh` to convert those back into LF for comparison.
1 parent 0b468ad commit bce87d9

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

.github/workflows/ci.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ jobs:
2222
build: eval $(opam env) && cd analysis && make test
2323
artifact-folder: linux
2424
- os: windows-latest
25-
build: |
26-
cd analysis
27-
# git checkout converted these to windows newline. Convert back to unix newline here
28-
dos2unix test.sh tests/src/*.res tests/src/*.resi
29-
& $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make
25+
build: "cd analysis && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make test"
3026
artifact-folder: win32
3127

3228
runs-on: ${{matrix.os}}
3329

3430
steps:
31+
# needed for Windows testing
32+
- name: Set git to use LF
33+
run: |
34+
git config --global core.autocrlf false
35+
git config --global core.eol lf
36+
3537
- uses: actions/checkout@v2.3.4
3638

3739
- name: Cache OCaml's opam

analysis/test.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
function exp {
2-
echo "$(dirname $1)/expected/$(basename $1).txt"
3-
}
4-
51
for file in tests/src/*.{res,resi}; do
6-
./rescript-editor-analysis.exe test $file &> $(exp $file)
2+
output="$(dirname $file)/expected/$(basename $file).txt"
3+
./rescript-editor-analysis.exe test $file &> $output
4+
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
5+
if [ "$RUNNER_OS" == "Windows" ]; then
6+
perl -pi -e 's/\r\n/\n/g' -- $output
7+
fi
78
done
89

910
warningYellow='\033[0;33m'

0 commit comments

Comments
 (0)