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

Setup CI to run tests on Windows #164

Closed
dcastro opened this issue Sep 25, 2022 · 5 comments · Fixed by #191
Closed

Setup CI to run tests on Windows #164

dcastro opened this issue Sep 25, 2022 · 5 comments · Fixed by #191
Assignees
Milestone

Comments

@dcastro
Copy link
Member

dcastro commented Sep 25, 2022

Clarification and motivation

NB: we should probably do #165 first

We've been building and releasing windows binaries, but we haven't actually tested that they indeed work.

The readme also lists "Support for non-Unix systems" under the "For further work" section, so maybe we should invest some time into this.

The first thing to do is to setup a CI to run the haskell and bats tests on windows. GitHub Actions is probably the best way to set this up, see an example we can reuse here. The bats docs say it supports Windows, so this should be doable.

When this is up and running, we may (hopefully not) find some bugs, in which case we'll open more follow-up issues.

A few things that I think may be bugs:

  • Backwards slashes in local links: [a](b\c). Github and gitlab both interpret this as a link to a file named b%5Cc. But on a windows machine, will xrefcheck interpret this as a link to the file c in dir b?
  • This line expects rLink to be an "absolute reference" and begin with a /. Appending it to root with <> works on linux, but will this behave correctly on windows?
    AbsoluteLoc -> checkRef rAnchor (root <> toString rLink)

Acceptance criteria

  • We're using GitHub Actions to run the Haskell and Bats tests on Windows
  • We've created issues for any bugs that come up
@dcastro dcastro added this to the 0.3 milestone Sep 25, 2022
@Sorokin-Anton Sorokin-Anton self-assigned this Sep 28, 2022
@Sorokin-Anton
Copy link
Contributor

@dcastro I will try to run bats on my windows machine first, to see how bad things are, and then will try to learn how to add github actions. Am I right that windows machine will be hosted not on buildkite but on GitHub?

@dcastro
Copy link
Member Author

dcastro commented Sep 29, 2022

@dcastro I will try to run bats on my windows machine first, to see how bad things are, and then will try to learn how to add github actions.

Sounds like a good plan! 👍

Am I right that windows machine will be hosted not on buildkite but on GitHub?

Yes, GitHub Actions have their own runners.

@Sorokin-Anton
Copy link
Contributor

Sorokin-Anton commented Sep 30, 2022

@dcastro that's what I gotv when simply run xrefcheck on Windows:
(builded from source with stack, launched from powershell in vscode)

PS C:\Users\Anton\projects\xrefcheck> xrefcheck.exe --ignored tests/**/*
Configuration file not found, using default config for GitHub repositories


xrefcheck.exe: <stderr>: hPutChar: invalid argument (Invalid argument)

"Funny" thing is that I can not reproduce that, and now I see question marks or some codes instead of some non-ascii symbols.

I think maybe we should disable progress bar and output coloring (as in #185) by default on Windows using conditional compilation - this is working in vscode but not in standard porwershell or cmd, where output contains many lines like this:

Verifying ←[97mlocal: [←[0m←[94m←[0m←[91m←[0m←[97m■■■■■■■■■■←[0m←[97m←[0m ←[97m]←[0m←[2m←[97m?←[0m←[0m ←[93mexternal: [←Verifying ←[97mlocal: 

Interesting fact: if I launch GHCi in cmd, coloring works normally, so maybe we could fix it

Also symbols ✓, ➥ and ⛀ (which we use for reports) are displayed as questionmarks anywhere (even in vscode terminal), and when I try to print them in GHCi, I see this old message

ghci> putStrLn @Text "\10003"                                                                                           
*** Exception: <stdout>: hPutChar: invalid argument (invalid character) 

@Sorokin-Anton
Copy link
Contributor

I learned how to run bats inside so called Git Bash (mingw) , which looks like the only way to run them on windows, and almost all test s are failed, but for expected reasons

1: slashes in messages

   <   ➥  In file to-ignore\broken-link.md
   ---
   >   ➥  In file to-ignore/broken-link.md
  1. Differently displayes error messages in network-related libraries
   <      ⛂  InternalException (HostCannotConnect "localhost" [Network.Socket.connect: <socket: N>: failed (Connection refused (WSAECONNREFUSED)),Network.Socket.connect: <socket: N>: failed (Connection refused (WSAECONNREFUSED))])
   ---
   <      ⛂  ConnectionFailure Network.Socket.connect: <socket: N>: failed (Connection refused (WSAECONNREFUSED))
   ---

(Did not tested advanced things with relative links, i.e. #165 yet)

We want that tests to pass, so I think that we should always use / in reports , so tests that fails like in (1) will pass.
Or we can replace \ by / inside assert-diff function, bt I don't think it's a good idea.
And we need to use some regex for network-related tests

By the way, coloring and progress bar are displayed correctly in this shell, I think we can recommend it to xrefcheck-windows users since it comes with git. Also I think that I will need to discover how to launch it in github-actions

@Sorokin-Anton
Copy link
Contributor

Actually, stack test gives us a failure on Windows too, because canoniseLocalRefs strips toText ['.', pathSeparator]
@dcastro I think it should strip only ./, cause we are not supporting \ on Windows anyway
I can make a separate issue for that

Sorokin-Anton added a commit that referenced this issue Oct 5, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: test locally and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Sorokin-Anton added a commit that referenced this issue Oct 6, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: test locally and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Sorokin-Anton added a commit that referenced this issue Oct 6, 2022
Sorokin-Anton added a commit that referenced this issue Oct 6, 2022
Sorokin-Anton added a commit that referenced this issue Oct 6, 2022
Sorokin-Anton added a commit that referenced this issue Oct 6, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: test locally and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Sorokin-Anton added a commit that referenced this issue Oct 7, 2022
Sorokin-Anton added a commit that referenced this issue Oct 8, 2022
Sorokin-Anton added a commit that referenced this issue Oct 8, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: test locally and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Sorokin-Anton added a commit that referenced this issue Nov 9, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Some subproblems appear:

1.
Problem: CI build fails beacuse it needs `pcre` package
Solution: add it (somehow), see `install pacman dependencies`
in ci.yml

2.
Problem: Network errors displayed different on different platforms
Solution: collect output from both and use
`assert_diff expected_linux.gold || assert_diff expected_windows.gold`

3:
Problem: "Config matches" test is failing because checkout action
clone files with CRLF, and test assert equality of two ByteStrings
Solution: manually remove CR
Sorokin-Anton added a commit that referenced this issue Nov 10, 2022
Problem: xrefcheck uses utf8 symbols in reports, which are not supported
on most of Windows shells by default.
Sometimes they are printed as question marks (and it cause golden tests to fail)
and sometimes printing of them raise an error.

Solution: use function `withCP65001` from `code-page` package which
sets correct codepage on Windows and do nothing on other OSs
Sorokin-Anton added a commit that referenced this issue Nov 10, 2022
Problem: in markdown links, '/' should always be used as path separator ,
e.g. GitHub renderer is not threating link `[x](a\b.md)` as a link
to file in dir `a`
We use OS-dependent file separators everywhere, so
e.g. `canonizeLocalRef "./a.md"="./a.md`"` on Windows

Solution: replace '\' to '/' while constructing repo tree if needed
and then use only '/', preferring functions from `System.FilePath.Posix`.
We can do this, since 'a/b' and `a\b` are equivalent paths on Windows
Sorokin-Anton added a commit that referenced this issue Nov 10, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Some subproblems appear:

1.
Problem: CI build fails beacuse it needs `pcre` package
Solution: add it (somehow), see `install pacman dependencies`
in ci.yml

2.
Problem: Network errors displayed different on different platforms
Solution: collect output from both and use
`assert_diff expected_linux.gold || assert_diff expected_windows.gold`

3:
Problem: "Config matches" test is failing because checkout action
clone files with CRLF, and test assert equality of two ByteStrings
Solution: manually remove CR
Sorokin-Anton added a commit that referenced this issue Nov 10, 2022
Sorokin-Anton added a commit that referenced this issue Nov 26, 2022
Problem: xrefcheck uses utf8 symbols in reports, which are not supported
on most of Windows shells by default.
Sometimes they are printed as question marks (and it cause golden tests to fail)
and sometimes printing of them raise an error.

Solution: use function `withCP65001` from `code-page` package which
sets correct codepage on Windows and do nothing on other OSs
Sorokin-Anton added a commit that referenced this issue Nov 26, 2022
Problem: in markdown links, '/' should always be used as path separator ,
e.g. GitHub renderer is not threating link `[x](a\b.md)` as a link
to file in dir `a`
We use OS-dependent file separators everywhere, so
e.g. `canonizeLocalRef "./a.md"="./a.md`"` on Windows

Solution: replace '\' to '/' while constructing repo tree if needed
and then use only '/', preferring functions from `System.FilePath.Posix`.
We can do this, since 'a/b' and `a\b` are equivalent paths on Windows
Sorokin-Anton added a commit that referenced this issue Nov 26, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Some subproblems appear:

1.
Problem: CI build fails beacuse it needs `pcre` package
Solution: add it (somehow), see `install pacman dependencies`
in ci.yml

2.
Problem: Network errors displayed different on different platforms
Solution: collect output from both and use
`assert_diff expected_linux.gold || assert_diff expected_windows.gold`

3:
Problem: "Config matches" test is failing because checkout action
clone files with CRLF, and test assert equality of two ByteStrings
Solution: manually remove CR
Sorokin-Anton added a commit that referenced this issue Nov 26, 2022
Sorokin-Anton added a commit that referenced this issue Nov 26, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Some subproblems appear:

1.
Problem: CI build fails beacuse it needs `pcre` package
Solution: add it (somehow), see `install pacman dependencies`
in ci.yml

2.
Problem: Network errors displayed different on different platforms
Solution: collect output from both and use
`assert_diff expected_linux.gold || assert_diff expected_windows.gold`

3:
Problem: "Config matches" test is failing because checkout action
clone files with CRLF, and test assert equality of two ByteStrings
Solution: manually remove CR
Sorokin-Anton added a commit that referenced this issue Nov 29, 2022
Problem: xrefcheck uses utf8 symbols in reports, which are not supported
on most of Windows shells by default.
Sometimes they are printed as question marks (and it cause golden tests to fail)
and sometimes printing of them raise an error.

Solution: use function `withCP65001` from `code-page` package which
sets correct codepage on Windows and do nothing on other OSs
Sorokin-Anton added a commit that referenced this issue Nov 29, 2022
Problem: in markdown links, '/' should always be used as path separator ,
e.g. GitHub renderer is not threating link `[x](a\b.md)` as a link
to file in dir `a`
We use OS-dependent file separators everywhere, so
e.g. `canonizeLocalRef "./a.md"="./a.md`"` on Windows

Solution: replace '\' to '/' while constructing repo tree if needed
and then use only '/', preferring functions from `System.FilePath.Posix`.
We can do this, since 'a/b' and `a\b` are equivalent paths on Windows
Sorokin-Anton added a commit that referenced this issue Nov 29, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Some subproblems appear:

1.
Problem: CI build fails beacuse it needs `pcre` package
Solution: add it (somehow), see `install pacman dependencies`
in ci.yml

2.
Problem: Network errors displayed different on different platforms
Solution: collect output from both and use
`assert_diff expected_linux.gold || assert_diff expected_windows.gold`

3:
Problem: "Config matches" test is failing because checkout action
clone files with CRLF, and test assert equality of two ByteStrings
Solution: manually remove CR
Sorokin-Anton added a commit that referenced this issue Nov 30, 2022
Problem: we are not testing behavior of xrefcheck on Windows

Solution: and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Some subproblems appear:

1.
Problem: CI build fails beacuse it needs `pcre` package
Solution: add it (somehow), see `install pacman dependencies`
in ci.yml

2.
Problem: Network errors displayed different on different platforms
Solution: collect output from both and use
`assert_diff expected_linux.gold || assert_diff expected_windows.gold`

3:
Problem: "Config matches" test is failing because checkout action
clone files with CRLF, and test assert equality of two ByteStrings
Solution: manually remove CR
Sorokin-Anton added a commit that referenced this issue Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants