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

Add support for building on Windows / Cygwin #18

Open
fingolfin opened this issue Apr 6, 2021 · 5 comments
Open

Add support for building on Windows / Cygwin #18

fingolfin opened this issue Apr 6, 2021 · 5 comments

Comments

@fingolfin
Copy link
Member

Similar to issue #17, but probably more work, as one also needs a way to install a cygwin environment -- I hope that we can reuse some of the work done on gap-system/gap for this, though

@ssiccha
Copy link
Collaborator

ssiccha commented Apr 6, 2021

(I've had a long day so I might be talking nonsense here)

I'm not sure whether this is possible ATM. Composite actions do not support using if on a step-level, see this issue. So I don't know how we would figure out whether we have to use bash or cmd.

Wait, one can use shell: bash also when running on a windows machine? Nice, see here I'm putting this here so that I don't forget about it.

@fingolfin
Copy link
Member Author

fingolfin commented Jan 27, 2022

@wilfwilson has been very active on this. Some PRs that convert packages to using his work: gap-packages/ace#28 and gap-packages/datastructures#136

One concern about that is that it requires various custom versions of our GH actions, e.g. gap-actions/setup-gap@cygwin-v2 instead of gap-actions/setup-gap@v2. These are maintained in branches right now.

The main reason is that we can't use shell: bash in actions on Windows, as it gives us the "wrong" bash shell. You can see this on https://github.com/gap-actions/setup-gap/pull/22/files . This relies on the custom shell support in GH Actions workflow files, and right now that can't be controlled by e.g. env variables.

One way out might be to install a helper script bash.bat into a suitable directory in the PATH before bash.exe, which could look roughly like this (untested):

set CHERE_INVOKING=1
C:\cygwin64\bin\bash.exe --login -o igncr %*
exit /b %ERRORLEVEL%

So it would invoke the cygwin bash.exe with the right arguments, and also forward the exit code. Then we might be able to write shell: bash for cygwin, too.

@wilfwilson
Copy link
Contributor

Thanks for the summary of the current obstacles (which matches my understanding), and for suggesting a reasonable sounding solution! (Although, having battled with this stuff for a while, I wouldn't be surprised if it turns out to be unreasonably tricky!)

@fingolfin
Copy link
Member Author

I've just learned that one can prepend a dir to PATH via https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path which sounds as if it ought to work on Windows, too. Indeed, this is confirmed by this post

@fingolfin
Copy link
Member Author

fingolfin commented Nov 21, 2022

I just discovered https://github.com/cygwin/cygwin-install-action which I think has everything we need to get rid of our shell: C:\cygwin64\bin\bash.exe --login -o igncr '{0}' hack:

  1. running git config --global core.autocrlf input once at the start (e.g. as part of gap-actions/setup-cygwin) may be enough to get rid of the need for -o igncr
  2. alternatively, we could once at the start set igncr in the SHELLOPTS environment variable (this in turn can be done via echo "SHELLOPTS=igncr" >> $GITHUB_ENV though we may also wish to set additional options)
  3. it explains why CHERE_INVOKING has to be set: to "prevent the profile script from changing directory" at startup; perhaps we can document that with a comment?
  4. it may be possible for the setup-cygwin action to set this for all subsequent steps/actions via echo "CHERE_INVOKING=1" >> $GITHUB_ENV but this has to be tested
  5. these days we can prepend a directory to PATH by modifying the $GITHUB_PATH file; the quoted action does that, and we can do, via echo "C:\cygwin64\bin" >> $GITHUB_PATH
  6. apparently by setting the CYGWIN_NOWINPATH environment variable we can prevent the Cygwin bash from adding a bunch of non-cygwin dirs to its PATH? So echo CYGWIN_NOWINPATH=1 >> $GITHUB_ENV.

So to find out if this works, we ought to make a modified version of setup-cygwin that does all of this. Then try to use it with "stock" versions of the other actions.

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

No branches or pull requests

3 participants