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

Linux ARM support #577

Open
sandstrom opened this issue Mar 15, 2024 · 38 comments
Open

Linux ARM support #577

sandstrom opened this issue Mar 15, 2024 · 38 comments

Comments

@sandstrom
Copy link

sandstrom commented Mar 15, 2024

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
Copy link

dentarg commented Mar 15, 2024

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

@sandstrom
Copy link
Author

sandstrom commented Mar 15, 2024

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
Copy link

dentarg commented Mar 15, 2024

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
Copy link
Author

@dentarg Ah, got it!

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

@dentarg
Copy link

dentarg commented Mar 15, 2024

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
Copy link
Member

eregon commented Mar 15, 2024

It's the same as for any other new runner, we need access to the runner from the ruby organization to build binaries, see #494 (comment)
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
Copy link
Author

sandstrom commented Mar 15, 2024

@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
Copy link

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

@sandstrom
Copy link
Author

@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
Copy link
Member

eregon commented Mar 15, 2024

^ 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
Copy link

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
Copy link
Member

eregon commented Mar 16, 2024

@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
Copy link

Agreed and acknowledged @eregon

@hsbt
Copy link
Member

hsbt commented Mar 18, 2024

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

@schneems
Copy link

I'm working on this on the Heroku side right now heroku/docker-heroku-ruby-builder#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?

schneems added a commit to heroku/docker-heroku-ruby-builder that referenced this issue Mar 26, 2024
We shouldn't need Ruby installed on the runner, and again the container just to be able to build Ruby versions. This commit moves functionality that doesn't **need** to be in Ruby to bash. This is needed as ruby/setup-ruby does not currently work with ARM ruby/setup-ruby#577.
schneems added a commit to heroku/docker-heroku-ruby-builder that referenced this issue Mar 27, 2024
We shouldn't need Ruby installed on the runner, and again the container just to be able to build Ruby versions. This commit moves functionality that doesn't **need** to be in Ruby to bash. This is needed as ruby/setup-ruby does not currently work with ARM ruby/setup-ruby#577.
schneems added a commit to heroku/docker-heroku-ruby-builder that referenced this issue Apr 2, 2024
* Add AMD (x86_64) and ARM (aarch64) on Heroku-24

AMD/x86_64 is the architecture used for all prior base images. Heroku-24 (Ubuntu 24.04) base image is provided with support for ARM/aarch64 (think m1 Mac or graviton AWS server) support. This PR does several things:

- Introduces support for heroku-24 base image
- Build both arm64 and amd64 architecture binaries

* Use GHA arm runner beta

* Update ruby/setup-ruby to @v1 everywhere

Versions are different across the project, this commit synchronizes them all to v1 which is the latest.

* Move build scripts to bash

We shouldn't need Ruby installed on the runner, and again the container just to be able to build Ruby versions. This commit moves functionality that doesn't **need** to be in Ruby to bash. This is needed as ruby/setup-ruby does not currently work with ARM ruby/setup-ruby#577.

* Manually install docker

* Remove Ruby requirement on GHA for building binaries

Remove the Ruby requirement in the local runtime to build rubies. It is still needed on the stack image, but this allows us to decouple from ruby/setup-ruby which is itself blocked on building binaries. We still need it for running unit tests on CI.

- Remove Rake and Rakefile
- Update README to use bash commands
- Update all ci.yml and build_ruby.yml to use bash instead of Ruby

* Apply suggestions from code review

Co-authored-by: Colin Casey <[email protected]>

* Fix linting check in CI

* Remove docker file from root and ignore

It is copied in to root as needed and shouldn't be checked in.

* Apply suggestions from code review

Co-authored-by: Colin Casey <[email protected]>

---------

Co-authored-by: Colin Casey <[email protected]>
everplays added a commit to b4b-payments/setup-ruby that referenced this issue Apr 9, 2024
rel: ruby#577

example:

```yaml
jobs:
  tests:
    runs-on: ARM-2c-8r
    steps:
      - name: Install dependencies
        run: sudo apt-get -qq install -y --no-install-recommends build-essential libffi-dev libreadline-dev libyaml-dev libmysqlclient-dev > /dev/null
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up Ruby
        uses: b4b-payments/setup-ruby@arm-runners
        with:
          ruby-version: '3.2.2'
          bundler-cache: true
          should-install-with-ruby-build: true
      - name: Run tests
        run: bundle exec rake test
```
@everplays
Copy link

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: b4b-payments@e0facb5. 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
Copy link
Member

eregon commented Apr 9, 2024

@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
Copy link

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
Copy link
Member

hsbt commented Apr 19, 2024

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

@nobu
Copy link
Member

nobu commented Apr 30, 2024

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
Copy link
Member

eregon commented May 3, 2024

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

@eregon eregon changed the title ARM support Linux ARM support May 3, 2024
@npezza93
Copy link

npezza93 commented Jun 3, 2024

@eregon
Copy link
Member

eregon commented Jun 3, 2024

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
Copy link

xrl commented Jun 5, 2024

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

@dentarg
Copy link

dentarg commented Jun 5, 2024

Yes, see the above quote from the announcement

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jun 5, 2024

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
Copy link
Member

eregon commented Jun 5, 2024

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 (#577 (comment)).
@Steve-Glass Any chance to make that happen?

@flavorjones
Copy link

flavorjones commented Jun 5, 2024

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

This comment was marked as off-topic.

@NicoHinderling
Copy link

NicoHinderling commented Jun 26, 2024

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
Copy link

dentarg commented Jun 26, 2024

@NicoHinderling see #577 (comment)

@enescakir
Copy link

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 (#577 (comment)).

We encountered the same problem within our CI. We resolved it by manually installing Ruby into the toolcache. However, it would be beneficial to have arm64 support in setup-ruby. Additionally, ruby/ruby-builder and other builders require arm64 release packages.

At Ubicloud, we offer managed GitHub Actions runners with arm64 support. We're happy to offer 10,000 free minutes per month on our platform for the Ruby organization. @eregon If you're interested, please let me know. As Ruby users, we're delighted to back the Ruby organization.

@eregon
Copy link
Member

eregon commented Jul 4, 2024

We resolved it by manually installing Ruby into the toolcache.

Yes, this is the current solution (as the error message says), and then you can use setup-ruby in self-hosted mode (automatically detected).

At Ubicloud, we offer managed GitHub Actions runners with arm64 support. We're happy to offer 10,000 free minutes per month on our platform for the Ruby organization.

This wouldn't help, no, because of these reasons.

@testworksau
Copy link

@eregon
Copy link
Member

eregon commented Sep 4, 2024

#577 (comment)

So until arm64 runners are available for public repositories (https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories) there is nothing that can be done here.

@testworksau
Copy link

Ah, thanks @eregon I didn't realise there was a difference between a runner being GA and a runner being available for consumption (for free) by public repos.

@willnode
Copy link

willnode commented Oct 4, 2024

Just saying.. There are other build system that supports aarch64 by cross compiling.
https://github.com/indygreg/python-build-standalone/blob/main/.github/workflows/linux.yml

@testworksau
Copy link

Here's where GitHub are tracking the work to make ARM runners available for OSS projects:
github/roadmap#970

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

No branches or pull requests