Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Integration with use-ruby #1

Closed
eregon opened this issue Jan 2, 2020 · 18 comments
Closed

Integration with use-ruby #1

eregon opened this issue Jan 2, 2020 · 18 comments

Comments

@eregon
Copy link

eregon commented Jan 2, 2020

Hello, and thank you for this action!

I am the author of https://github.com/eregon/use-ruby-action and would like to see what it would take to make it work on Windows too.

The idea of that action is to reuse prebuilt binaries, so setting up Ruby is just download + add to PATH.
For Linux and macOS I use this repo which automatically compiles Ruby:
https://github.com/eregon/ruby-install-builder/

For fun I tried to run it on Windows with shell: bash (which uses the Git shell, so quite limited) but that failed early: https://github.com/eregon/ruby-install-builder/commit/ca7c2421117780dac91d309189e08dd41c8ef0ec/checks?check_suite_id=380675014

Looking at https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js I wonder which parts are needed. It looks quite complicated.
Of course, it would be most convenient if we can use the RubyInstaller2 binaries.

OTOH, do we need to install extra packages and update MSYS2?
That seems to take a while (1min16s in example), so I'd like to avoid it if possible.

@eregon
Copy link
Author

eregon commented Jan 2, 2020

cc @larskanis you might be interested in this.

@MSP-Greg
Copy link
Owner

MSP-Greg commented Jan 2, 2020

@eregon

I need to take a good look at what you've done. I looked earlier, but just a quick glance...

I set this up to work with Ruby 2.3 (RubyInstaller), the latest releases of Ruby 2.4 thru 2.6 (RubyInstaller2), and ruby-loco.

I do a bit of work with extension gems, in particular, CI on Windows, so I set this up mostly for that purpose. But, normal (Ruby only) gems don't need that.

One question I've wondered about is what versions of Ruby should be supported, both major/minor and within major/minor. RubyInstaller2 (@larskanis) has all the versions from 2.4 forward.

If this work goes public, I'm sure someone will want to test against 2.6.3, or 2.5.5, etc. That wasn't available on AppVeyor, but I believe it is on Travis (?)

@eregon
Copy link
Author

eregon commented Jan 2, 2020

On https://rubyinstaller.org/downloads/ I see there are packaged versions together with the DevKit.
This is probably the simplest since then it's more likely to just work.

However I only see .exe for that on the website and https://github.com/oneclick/rubyinstaller2/releases.
Is there a way to run the .exe installer from the command line (i.e., in GitHub Actions)?

@MSP-Greg
Copy link
Owner

MSP-Greg commented Jan 2, 2020

You can download the 7x files, there are three MSYS2 installs on Actions, one in each Windows Ruby. I symlink to one in the code here...

@eregon
Copy link
Author

eregon commented Jan 2, 2020

Thanks, I found

actions-ruby/action.yml

Lines 14 to 16 in 50b691d

msys2-loc:
description: 'base location of MSYS2 install'
default: 'C:\hostedtoolcache\windows\Ruby\2.6.3\x64\msys64'

But I guess that will break when GitHub updates Ruby 2.6 to 2.6.5 in the toolcache.
We could probably take the last entry of C:\hostedtoolcache\windows\Ruby though.

It might be better to not rely on the toolcache if possible, as it often changes.

Maybe we can run the installer in very silent mode, including ridkinstall and repackage the whole as a single or two archives:
https://github.com/oneclick/rubyinstaller2/wiki/FAQ#q-how-do-i-perform-a-silentunattended-install-with-the-rubyinstaller
Or if that's fast enough just run it directly in use-ruby.

@MSP-Greg
Copy link
Owner

MSP-Greg commented Jan 2, 2020

Re Windows, there have been users (other than Ruby users) who have asked for an MSYS2 install, I also asked for one.

I don't really know the best place to ask, and also whether they'll confirm anything.

It might be better to not rely on the toolcache if possible, as it often changes.

Actually, I don't believe it has been updated since the beta started. That's part of the reason all of this has happened.

@eregon
Copy link
Author

eregon commented Jan 2, 2020

actions/runner-images#30 seems the best issue I found so far regarding adding MSYS2 in the base image.

@MSP-Greg
Copy link
Owner

MSP-Greg commented Jan 2, 2020

@larskanis
Copy link

I didn't work with Github Actions so far. But install of the RubyInstaller exe files is pretty easy. There is also a daily build of RubyInstaller-head available with ruby-master and up-to-date MSYS2: https://github.com/oneclick/rubyinstaller2/releases/tag/rubyinstaller-head
The only thing to note is that the installer must be started per cmd. Otherwise it's running in the background and processing doesn't wait.

@eregon
Copy link
Author

eregon commented Jan 5, 2020

I tried a few approaches in https://github.com/eregon/ruby-install-builder/actions on branch windows2.
Downloading the installer and running it with cmd /c ruby-setup.exe /verysilent /dir=C:/Ruby26 seems to work well.
It takes about 17 seconds to install in GitHub Actions.
With the DevKit, that becomes 2 minutes to install (too long for CI I think).

I tried repackaging the installed Ruby+DevKit, and that gives a 300MB .tar.gz, which is kind of large.
Not sure how fast it would be to download and extract that on Windows.

The PATH in GitHub Actions seems quite messy and gem install json ends up working even without a DevKit with the original PATH (it finds some mingw installation). Filtering as done in this action seems a good idea. By default Ruby 2.5.5 is on PATH,which is kind of inconsistent with other OS where there is no ruby by default.

I think in the end I'll use an approach very similar to this action. @MSP-Greg is certainly more experienced than I am with Windows.

@MSP-Greg
Copy link
Owner

MSP-Greg commented Jan 5, 2020

@eregon

First of all, thank you for your work on this.

I've been using MSYS2 for a few years, also for building packages. I tried various ways to install it, and especially for a 'pure ruby' gem/repo, the time was just too long.

From my perspective, I've seen many issues raised since the Actions beta started, and with few exceptions, very few actions were taken to fix the issues.

When the CI doesn't even work with [ci skip] / [skip ci], I gotta wonder...

So, I'm waiting to see what happens. If they start making changes and moving things into GH repos, all the better. Otherwise, we need to think about how best to do it ourselves.

The main thing I'm wondering about is support for versions other than 'last teeny', and whether we need to support master 'pre' builds. Given that the logic for that sort of thing is messy, it would be best to support from the start (?)

@eregon
Copy link
Author

eregon commented Jan 5, 2020

FWIW I tried repackaging installed Ruby+DevKit as a .7z, that's 150MB (instead of 300MB .tar.gz, nice).
However it takes 1min25s to decompress, that's rather depressing:
https://github.com/eregon/ruby-install-builder/runs/374538859
I suppose that's mostly due to very slow disk IO on Windows?

So I guess the only fast way for now is to rely on the existing MSYS2 install in C:\hostedtoolcache\windows\Ruby\2.6.3\x64\msys6.

@MSP-Greg
Copy link
Owner

MSP-Greg commented Jan 5, 2020

Yeah, been there, done that. I'm hoping they add an MSYS2 install independent of the Ruby installs.

Everywhere I've seen discussion, they're very vague about any disk image updates.

JFYI, I added Ruby 2.7.0 here.

@larskanis
Copy link

@eregon You're right, switching to a different compression algorithm doesn't have a big impact on install speed. Windows is awfully slow at handling small files. RubyInstaller uses lzma2 compression.

Possibly my idea is ridiculous, because I didn't try Github Actions so far. But if I understood it right, it has RubyInstaller-Devkit 2.4, 2.5 and 2.6 preinstalled with full Devkit? So isn't it an option to just

mv c:/ruby26-x64/msys64 c:/

and install RubyInstaller-head without Devkit (or Ruby-Loco)? The msys64 folder is usually a totally standard MSYS2 setup with no specifics to any particular Ruby or RubyInstaller version. The only difference is that some pacman packages (gcc, autotools, etc) are preinstalled. If it's in c:/msys64 each RubyInstaller version will find and use it.

@MSP-Greg
Copy link
Owner

MSP-Greg commented Jan 5, 2020

@larskanis

You're idea is good, as it's what I'm doing in this repo. I'm just making a C:\msys64 symlink to the 2.6.3 DevKit, and then downloading your RI2 7z files. Ok, I'm using ruby-loco for master...

It also allows 2.3.3. Some extension gems will compile and test with MSYS2 built *.so files...

@eregon
Copy link
Author

eregon commented Jan 5, 2020

JFYI, I added Ruby 2.7.0 here.

Thanks! And thank you @larskanis for building it!

I got Ruby 2.4-2.7 working now in use-ruby-action with ruby/setup-ruby@101f62d.

It has similar logic as this action but simplified:
https://github.com/eregon/use-ruby-action/blob/101f62de1d2aff7846f52bf23989d934bd75874d/windows.js

And indeed it just reuses the MSYS2 from the hostedtoolcache, which means the whole action takes just 5 seconds to run: https://github.com/eregon/use-ruby-action/runs/374628258

Drawbacks are probably a slightly older MSYS2 than when using base: update in this action (but that takes 1 minute).

And currently bundler is not installed in those .7z archives, while it is for Ubuntu/macOS with https://github.com/eregon/ruby-install-builder/, I should fix that.

@MSP-Greg
Copy link
Owner

MSP-Greg commented Jan 5, 2020

And currently bundler is not installed in those .7z archives

Should be for Ruby 2.6 and later.

Not right now, but I'll have a look re adding the base, mingw & msys2 parameters. They are helpful, as a lot of devs aren't familiar with MSYS2. Obviously, they'd be ignored for other OS's...

Thanks, Greg

@eregon
Copy link
Author

eregon commented Jan 5, 2020

Should be for Ruby 2.6 and later.

Right, of course. But for Ruby <= 2.5 it's not there but I'd guess almost all Ruby CI jobs want it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants