Skip to content

Commit

Permalink
Add AMD (x86_64) and ARM (aarch64) on Heroku-24 (#38)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
schneems and colincasey authored Apr 2, 2024
1 parent 825c462 commit 66353f7
Show file tree
Hide file tree
Showing 21 changed files with 1,098 additions and 1,306 deletions.
105 changes: 75 additions & 30 deletions .github/workflows/build_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,21 @@ jobs:
STACK: "heroku-20"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
ruby-version: '3.1'
- name: Install dependencies
run: bundle install
uses: actions/checkout@v4
- name: Output CHANGELOG
run: bundle exec rake "changelog[${{inputs.ruby_version}}]"
run: bin/print_changelog "${{inputs.ruby_version}}"
- name: Build Docker image
run: bundle exec rake "generate_image[$STACK]"
- name: Generate Ruby Dockerfile
run: bundle exec rake "new[${{inputs.ruby_version}},$STACK]"
run: bin/activate_docker "$STACK"
- name: Build and package Ruby runtime
run: bash "rubies/$STACK/ruby-${{inputs.ruby_version}}.sh"
- name: Upload Ruby runtime archive to S3
run: bin/build_ruby "$STACK" "${{inputs.ruby_version}}"
- name: Verify ruby executable and output rubygems version
run: bin/print_gem_version "$STACK" "${{inputs.ruby_version}}"
- name: Upload Ruby runtime archive to S3 dry run
if: (inputs.dry_run)
run: aws s3 sync ./builds "s3://${S3_BUCKET}" --dryrun
- name: Upload Ruby runtime archive to S3 production
if: (!inputs.dry_run)
run: aws s3 sync ./builds "s3://${S3_BUCKET}"
- name: Output Rubygems version
run: bundle exec rake "rubygems_version[${{inputs.ruby_version}},$STACK]"

build-and-upload-heroku-22:
if: (!startsWith(inputs.ruby_version, '3.0')) # https://bugs.ruby-lang.org/issues/18658
Expand All @@ -58,23 +53,73 @@ jobs:
STACK: "heroku-22"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
ruby-version: '3.1'
- name: Install dependencies
run: bundle install
uses: actions/checkout@v4
- name: Output CHANGELOG
run: bundle exec rake "changelog[${{inputs.ruby_version}}]"
run: bin/print_changelog "${{inputs.ruby_version}}"
- name: Build Docker image
run: bundle exec rake "generate_image[$STACK]"
- name: Generate Ruby Dockerfile
run: bundle exec rake "new[${{inputs.ruby_version}},$STACK]"
run: bin/activate_docker "$STACK"
- name: Build and package Ruby runtime
run: bash "rubies/$STACK/ruby-${{inputs.ruby_version}}.sh"
- name: Upload Ruby runtime archive to S3
run: bin/build_ruby "$STACK" "${{inputs.ruby_version}}"
- name: Verify ruby executable and output rubygems version
run: bin/print_gem_version "$STACK" "${{inputs.ruby_version}}"
- name: Upload Ruby runtime archive to S3 dry run
if: (inputs.dry_run)
run: aws s3 sync ./builds "s3://${S3_BUCKET}" --dryrun
- name: Upload Ruby runtime archive to S3 production
if: (!inputs.dry_run)
run: aws s3 sync ./builds "s3://${S3_BUCKET}"

build-and-upload-heroku-24-amd:
if: (!startsWith(inputs.ruby_version, '3.0')) # https://bugs.ruby-lang.org/issues/18658
runs-on: pub-hk-ubuntu-22.04-xlarge
env:
STACK: "heroku-24"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Output CHANGELOG
run: bin/print_changelog "${{inputs.ruby_version}}"
- name: Build Docker image
run: bin/activate_docker "$STACK"
- name: Build and package Ruby runtime
run: bin/build_ruby "$STACK" "${{inputs.ruby_version}}"
- name: Verify ruby executable and output rubygems version
run: bin/print_gem_version "$STACK" "${{inputs.ruby_version}}" amd64
- name: Upload Ruby runtime archive to S3 dry run
if: (inputs.dry_run)
run: aws s3 sync ./builds "s3://${S3_BUCKET}" --dryrun
- name: Upload Ruby runtime archive to S3 production
if: (!inputs.dry_run)
run: aws s3 sync ./builds "s3://${S3_BUCKET}"

build-and-upload-heroku-24-arm:
if: (!startsWith(inputs.ruby_version, '3.0')) # https://bugs.ruby-lang.org/issues/18658
runs-on: pub-hk-ubuntu-22.04-arm-large
env:
STACK: "heroku-24"
steps:
- name: Checkout
uses: actions/checkout@v4
# Docker (and other tools) are not present on the early-access runners.
# We must install them manually: https://github.com/github-early-access/arm-runners-beta
- name: Install docker
run: |
bin/setup_docker_ci
sudo usermod -aG docker $USER
sudo apt-get install acl
sudo setfacl --modify user:$USER:rw /var/run/docker.sock
- name: Output CHANGELOG
run: bin/print_changelog "${{inputs.ruby_version}}"
- name: Build Docker image
run: bin/activate_docker "$STACK"
- name: Build and package Ruby runtime
run: bin/build_ruby "$STACK" "${{inputs.ruby_version}}"
- name: Verify ruby executable and output rubygems version
run: bin/print_gem_version "$STACK" "${{inputs.ruby_version}}" arm64
- name: Upload Ruby runtime archive to S3 dry run
if: (inputs.dry_run)
run: aws s3 sync ./builds "s3://${S3_BUCKET}" --dryrun
- name: Upload Ruby runtime archive to S3 production
if: (!inputs.dry_run)
run: aws s3 sync ./builds "s3://${S3_BUCKET}"
- name: Output Rubygems version
run: bundle exec rake "rubygems_version[${{inputs.ruby_version}},$STACK]"
73 changes: 55 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: 3.2
bundler-cache: true
- name: Linting
run: bundle exec standardrb
run: bundle exec standardrb --no-fix

test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
ruby-version: '3.2'
bundler-cache: true
- name: test
run: bundle exec rspec spec
Expand All @@ -39,20 +39,57 @@ jobs:
version: ["3.1.4"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
ruby-version: '3.1'
- name: Install dependencies
run: bundle install
uses: actions/checkout@v4
- name: Output CHANGELOG
run: bin/print_changelog "${{matrix.version}}"
- name: Build Docker image
run: bin/activate_docker "${{matrix.stack}}"
- name: Build and package Ruby runtime
run: bin/build_ruby "${{matrix.stack}}" "${{matrix.version}}"
- name: Verify ruby executable and output rubygems version
run: bin/print_gem_version "${{matrix.stack}}" "${{matrix.version}}"

integration_test-heroku-24-amd:
runs-on: pub-hk-ubuntu-22.04-xlarge
strategy:
matrix:
stack: ["heroku-24"]
version: ["3.2.3"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Output CHANGELOG
run: bin/print_changelog "${{matrix.version}}"
- name: Build Docker image
run: bin/activate_docker "${{matrix.stack}}"
- name: Build and package Ruby runtime
run: bin/build_ruby "${{matrix.stack}}" "${{matrix.version}}"
- name: Verify ruby executable and output rubygems version
run: bin/print_gem_version "${{matrix.stack}}" "${{matrix.version}}" amd64

integration_test-heroku-24-arm:
runs-on: pub-hk-ubuntu-22.04-arm-large
strategy:
matrix:
stack: ["heroku-24"]
version: ["3.2.3"]
steps:
- name: Checkout
uses: actions/checkout@v4
# Docker (and other tools) are not present on the early-access runners.
# We must install them manually: https://github.com/github-early-access/arm-runners-beta
- name: Install docker
run: |
bin/setup_docker_ci
sudo usermod -aG docker $USER
sudo apt-get install acl
sudo setfacl --modify user:$USER:rw /var/run/docker.sock
- name: Output CHANGELOG
run: bundle exec rake "changelog[${{matrix.version}}]"
run: bin/print_changelog "${{matrix.version}}"
- name: Build Docker image
run: bundle exec rake "generate_image[${{matrix.stack}}]"
- name: Generate Ruby Dockerfile
run: bundle exec rake "new[${{matrix.version}},${{matrix.stack}}]"
run: bin/activate_docker "${{matrix.stack}}"
- name: Build and package Ruby runtime
run: bash "rubies/${{matrix.stack}}/ruby-${{matrix.version}}.sh"
run: bin/build_ruby "${{matrix.stack}}" "${{matrix.version}}"
- name: Verify ruby executable and output rubygems version
run: bundle exec rake "rubygems_version[${{matrix.version}},${{matrix.stack}}]"
run: bin/print_gem_version "${{matrix.stack}}" "${{matrix.version}}" arm64
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ vendor/
.DS_Store

test/fixtures/repos/*
Dockerfile
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
source "https://rubygems.org"

gem "rake"
gem "aws-sdk"
gem "heroku_hatchet"
gem "webrick"
gem "nokogiri"
gem "rspec"
gem "standard"
Loading

0 comments on commit 66353f7

Please sign in to comment.