ruby / setup-ruby

An action to download a prebuilt Ruby and add it to the PATH in 5 seconds
https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
MIT License
770 stars 241 forks source link

Linux ARM support #577

Open sandstrom opened 3 months ago

sandstrom commented 3 months ago

Now that Github Actions has ARM-runners (in private beta currently), it would be awesome if this action would support ARM too.

Right now, it seems to assume Github doesn't have ARM.

https://github.com/ruby/setup-ruby/blob/master/common.js#L165

Here is a signup link for the private beta:

https://resources.github.com/devops/accelerate-your-cicd-with-arm-and-gpu-runners-in-github-actions/

dentarg commented 3 months ago

What's needed to support it? Seems tricky to support it when the docs for it are still private?

sandstrom commented 3 months ago

Good question!

@dentarg If you would like to, I'm sure @lkfortuna (PM working with Github Actions) can get you into the beta, since this action is widely used.

dentarg commented 3 months ago

I was thinking in general, if you have access to the beta, you should be able to submit a PR to this repo to show what needs to be done?

I've been invited to the beta (but haven't gotten access to the docs), I actually just emailed her earlier today ;-)

sandstrom commented 3 months ago

@dentarg Ah, got it!

I would love to help out, but I don't know the details of this action well enough, sorry.

dentarg commented 3 months ago

Ever heard about "learning by doing"? :-)

If you don't dig in yourself here, don't expect any movement on this until after the private beta.

eregon commented 3 months ago

It's the same as for any other new runner, we need access to the runner from the ruby organization to build binaries, see https://github.com/ruby/setup-ruby/pull/494#issuecomment-1743537651 Until then linux-aarch64 will be detected as self-hosted, because there are no prebuilt Rubies for it available.

So @lkfortuna @Steve-Glass could you make these new beta linux-aarch64 runners available for the ruby organization? What would be the runs-on value?

sandstrom commented 3 months ago

@dentarg Yeah, I know πŸ˜„

I've learned a lot by doing things (self-thought), just that I haven't yet spent that much time with JS-based Github Actions.

I do contribute to a few open-source projects, but I have to pick, and currently my goal is to improve the ipaddress gem.

Out of curiosity, do you live in the Stockholm area, or elsewhere? πŸ‡ΈπŸ‡ͺ

Steve-Glass commented 3 months ago

@eregon - Thanks for reaching out. Let me bring this feedback to the team and we will get back to you next week.

sandstrom commented 3 months ago

@lkfortuna @Steve-Glass Somewhat off topic, but is there a reason why the setup-python and setup-node actions are managed by Github, but this action lives outside?

eregon commented 3 months ago

^ Because https://github.com/actions/setup-ruby was not actively maintained and provided too little functionality to be practical (e.g. no way to specify Ruby x.y.z, only latest x.y and only 3-4 versions available).

cb-krishnapatel commented 3 months ago

hi @eregon and chat, I came around this discussion with a similar requirement for arm-based ruby installation. but I'm using self-hosted runners and not GitHub provided. For the base OS, I rely on Ubuntu 20.04-arm64 OS. Ruby binaries for arm64 for ubuntu20.04 are also publicly available. Wouldn't using those for ruby setup in arm-based Ubuntu/Linux OS allow GitHub runners (in beta) to run?

eregon commented 3 months ago

@cb-krishnapatel The builds need to be tested automatically, so we need access to these runners and the builds must happen on GitHub runners to ensure it's exactly the same image with the same tweaks, packages installed, etc.

Regarding https://ubuntu.pkgs.org/20.04/ubuntu-main-arm64/ruby_2.7+1_arm64.deb.html (the system package), of course you can apt-get install ruby, but that will only give you the ruby version that Ubuntu 20.04 ships and no other.

cb-krishnapatel commented 3 months ago

Agreed and acknowledged @eregon

hsbt commented 3 months ago

FYI: I requested this to GitHub support for Arm runner as private beta on Ruby organization.

schneems commented 3 months ago

I'm working on this on the Heroku side right now https://github.com/heroku/docker-heroku-ruby-builder/pull/38. Having support for ARM from ruby/setup-ruby isn't a blocker there, but it's what prompted me to see if an issue was raised yet or not.

@hsbt have you heard back from the request?

everplays commented 2 months ago

I managed to get this action to work on GitHub's ARM-based runners. Initially, what I needed to edit in this action was relatively small but as there are no pre-built ruby for ARM architecture, I ended up having to add should-install-with-ruby-build option as well.

I guess, if we start building for ARM as well, the download urls can be:

https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-${version}-${platform}.tar.gz

where platform is ubuntu-22.04 or ubuntu-22.04-arm (not sure if we can name x64 version as ubuntu-22.04-x64. Probably, it'll break stuff).

Anyway, my changes can be seen here: https://github.com/b4b-payments/setup-ruby/commit/e0facb59cd8373d1983af06d925bada2e344bfa6. I'd be happy to make PRs for both repos if one of the maintainers weigh in to know the preferred way to approach this.

Gotchas:

The provided image (ubuntu-22.04) does not behave exactly as the ones that are currently in production for x64. A lot of packages are missing (expected as github has documented) but I had to do the following to get this action to install ruby:

          sudo mkdir -p /opt/hostedtoolcache
          sudo chown -R $USER /opt/hostedtoolcache

Basically, it looks like /opt/hostedtoolcache is not present which is a hardcoded value in this action.

eregon commented 2 months ago

@everplays While that diff is small it has the big disadvantage to have to compile CRuby from source every time (takes many minutes) and needing to manually install extra packages, and misses some other tweaks done in https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml.

Until the ruby organization has access to these new linux arm runners, I think there is nothing we can do. @Steve-Glass Any news on that front?

everplays commented 2 months ago

indeed, as I said, we'd need to alter ruby-builder repo to build the ARM binary as well. If someone weights in, I can make the changes for that repo too so a full build won't be necessary. :-)

hsbt commented 2 months ago

Unfortunately, ruby org couldn't enable ARM runner with private beta. We need to wait until GA status.

nobu commented 2 months ago

Recently, macos-latest seems to have become macos-14 running on M1. CIs using older versions of ruby are failing because they can't be downloaded.

eregon commented 1 month ago

@nobu Could you file a separate issue, with links to the failed workflows? This one is about linux-aarch64, not macOS.

npezza93 commented 3 weeks ago

Looks like these runners have moved into public beta: https://github.blog/changelog/2024-06-03-actions-arm-based-linux-and-windows-runners-are-now-in-public-beta/

eregon commented 3 weeks ago

From https://github.blog/2024-06-03-arm64-on-github-actions-powering-faster-more-efficient-build-systems/

We expect to begin offering Arm runners for open source projects by the end of the year.

So it looks like linux-arm64 runners won't be available as GitHub-Hosted runners for public repositories until then.

xrl commented 3 weeks ago

Is the paid-only status of ARM support a deal breaker for this project?

dentarg commented 3 weeks ago

Yes, see the above quote from the announcement

MSP-Greg commented 3 weeks ago

Is the paid-only status of ARM support a deal breaker for this project?

I think similar 'issues' happened with macOS ARM. GitHub/MSFT adds a new platform for 'Enterprise' customers, and later make it available to OSS projects.

The one problem is the CI infrastructure's 'dependencies' come from OSS orgs. Most of the Ruby CI infrastructure for Ubuntu and macOS is contained in the Ruby organization, but some of the Windows infrastructure is not...

eregon commented 3 weeks ago

The only way to add linux-aarch64 support earlier is if GitHub provides free linux-aarch64 runners for the ruby organization, like it was done for macos-arm64 with macos-arm-oss (https://github.com/ruby/setup-ruby/issues/577#issuecomment-2000066452). @Steve-Glass Any chance to make that happen?

flavorjones commented 3 weeks ago

It's possible to use qemu to run aarch64 and arm workloads on the normal linux runners. See https://github.com/flavorjones/ruby-c-extensions-explained/blob/main/.github/workflows/precompiled.yml#L172-L179 for an example of how this is done for many C extension projects.

The builds will be slower than bare metal (because it's an emulator) but the tests will run.

xrl commented 3 weeks ago

QEMU is so amazingly, painfully slow. And also a huge pain to set up.

NicoHinderling commented 5 days ago

Unfortunately, ruby org couldn't enable ARM runner with private beta. We need to wait until GA status.

πŸ‘‹ apologies, but any update here now that it's available? I'm unfortunately trying to still support an older ruby version with the new runners atm

dentarg commented 5 days ago

@NicoHinderling see https://github.com/ruby/setup-ruby/issues/577#issuecomment-2146164079