-
Notifications
You must be signed in to change notification settings - Fork 3
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
[#164] Improve Windows support #191
Conversation
178d3f8
to
65b4307
Compare
6c37585
to
6fa646f
Compare
6fa646f
to
74361a3
Compare
74361a3
to
2875291
Compare
Ok, now I need to think how to add case-sensetivity on Windows UPD: after rebase on #174, case sensetivity works correctly |
2875291
to
44eba48
Compare
81b8ab4
to
bfbe20a
Compare
44eba48
to
e6663ad
Compare
e6663ad
to
3d74654
Compare
3d74654
to
fcaebbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, leaving just a few minor comments.
I'll try to wrap my head around possible pitfalls for more and maybe will give another review later.
src/Xrefcheck/Command.hs
Outdated
@@ -47,7 +48,7 @@ findFirstExistingFile = \case | |||
if exists then pure (Just file) else findFirstExistingFile files | |||
|
|||
defaultAction :: Options -> IO () | |||
defaultAction Options{..} = do | |||
defaultAction Options{..} = withCP65001 $ do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Main.hs
module we use withUtf8
, which sort of tries to switch everything to UTF-8 so that the developer does not need to worry about all the changes that must be made.
How do you think, would it be justified to create an issue in their GitHub? (Actually, this is a Serokell's package, so it could be just an improvement suggestion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Created issue in that repo, also moved withCP65001
to Main to keep such things in one place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 👍
tests/Test/Xrefcheck/ConfigSpec.hs
Outdated
when (config /= defConfigText GitHub) $ | ||
-- On Windows, git clone can replace \n with \r\n in some files | ||
let removeCR = BS.filter (/= '\r') | ||
when (removeCR config /= removeCR (defConfigText GitHub)) $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use defConfigText
in xrefcheck dump-config
, will it be fine if we eventually print that text without \r
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked, this is not a problem for yaml parser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about the user that will try to open and edit that file? Won't they see everything displayed in one line (at least in some text editors)?
UPD: or maybe not in one line, rather without caret returns.
|
||
|
||
# When editing this action, make sure it can run without using cached folders. | ||
# Yes, it tries to install mingw-w64-x86_64-pcre twice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pacman does not feel too well? 🧌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just recorded my shell history, and then realized it's the way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a bit of torture to see a mention of some magic without an explanation of why it is needed / why it works 😅
On the other hand, if all the possible explanation is "doing it once fails with X error, but somehow repeat helps both locally and in CI, no one knows why", then maybe it's really not necessary to provide.
fdef5d0
to
156da98
Compare
Oh, looks like ci action fails because diff is now space-sensetive, so does not like cr-s. Locally on Windows everything passes (no cr-s) , for me it's still a question where and why cr-s appear. Luckily there is diff option specially for that |
I would take a more thorough look at this, as it may point to a real UX issue of xrefcheck that will rise for some users. I have two thoughts:
However judging by your symptops (as far as I got them correctly), I completely don't understand which of these points currently take place and which may need an adjustment. |
@Martoon-00 finally, I've got two results: |
bbdf5ee
to
1c22137
Compare
1c22137
to
e899d5d
Compare
@Martoon-00 Bad news: if the repository was cloned with crlf's, output files have extra caret returns e.g. |
The reason of this is
and
while nyan-interpolation produced strings have \r's when they are in source file. |
Awesome. Very nice investigation! I agree with your conclusions. Quite sad that this was produced by nyan-interpolation (suddenly, initially I would never suspect it). We will have to get it fixed there. |
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
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
e899d5d
to
109d1ce
Compare
@Martoon-00 interesting fact: |
Meeh, I see. Your solution to this sounds good. I have no other concerns. Just a few words on this farewell I guess: that was a pleasure to review the work of yours. In my feeling, it required fewer review iterations than on average as you did everything mostly perfectly from the beginning. It was comfortable to me how initiative you were and has far you were ready to go when new issues arose. And concerns with English were pretty minor IMO. |
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
fe7ec9b
to
fb77575
Compare
Description
When I tried to test
xrefcheck
on windows locally, I've found following problems:Problem: it requires some dynamic libraries to run, and
stack install
place them in directory that is not on PATH by defaultSolution: add this information and possible workarounds to README.md, create issue is stack
Problem: most Windows shells are not supporting utf8 by default. Sometimes printing of reports raise an error.
hPutChar: invalid argument (Invalid argument)
Solution: use function
withCP65001
fromcode-page
package whichsets correct codepage on Windows and do nothing on other OSs
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 linkto file in dir
a
We use OS-dependent file separators everywhere, so
e.g.
canonizeLocalRef "./a.md"="./a.md
"` on WindowsSolution: 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 WindowsAlso I've added github actions workflow that runs
stack test xrefcheck:xrefcheck-tests
and golden tests (this required modification of some tests)Related issue(s)
Fixes #164
✅ Checklist for your Pull Request
Ideally a PR has all of the checkmarks set.
If something in this list is irrelevant to your PR, you should still set this
checkmark indicating that you are sure it is dealt with (be that by irrelevance).
Related changes (conditional)
Tests
silently reappearing again.
Documentation
Public contracts
of Public Contracts policy.
and
Stylistic guide (mandatory)