segmentio / golines

A golang formatter that fixes long lines
MIT License
925 stars 59 forks source link

Add testing with GitHub Actions #62

Closed telemachus closed 2 years ago

telemachus commented 2 years ago

So, good news: no hackery needed for the Windows test failures. It turns out that git was the cause. When git checks out files on Windows, it defaults to changing line endings (!). You can override that default with a .gitattributes file, and that's what I did here. (See, https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings for more discussion.) That may have one negative side-effect, but I think it's relatively minor. From that same page:

When you set the core.autocrlf option or commit a .gitattributes file, you may find that Git reports changes to files that you have not modified. Git has changed line endings to match your new configuration.

I think that would only happen to people who have already downloaded the source on Windows. If it comes up, the fix is described on that same page.

I set up the tests to run on 1.16, 1.17, and 1.18. You may not want all three, but that's easy to change.

Let me know if there's anything else you'd like me to change. You can see the test runs and logs in my branch if you want.

yolken commented 2 years ago

Nice, LGTM!

yolken commented 2 years ago

Also, thanks for digging into the Windows newline issue. I've never done any development on Windows, so I have no idea how things work on that side of the world or how I would go about diagnosing this problem.

telemachus commented 2 years ago

Also, thanks for digging into the Windows newline issue. I've never done any development on Windows, so I have no idea how things work on that side of the world or how I would go about diagnosing this problem.

You're very welcome. I also don't work at all with Windows, and I ended up learning more about git from this problem. If you're ever curious (or need something to put you to sleep), I wrote a short blog post about it all to help me remember in the future and gather resources if I run into this again.