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

Hybrid Rust (outside) + Bash (inside) #47

Merged
merged 19 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

# However, request review from the language owner instead for files that are
# updated by Dependabot, to reduce team review request noise.
Gemfile.lock @schneems
Cargo.lock @schneems
53 changes: 53 additions & 0 deletions .github/workflows/build_jruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and upload JRuby runtime
run-name: "Build and upload JRuby ${{ inputs.jruby_version }}${{ inputs.dry_run && ' (dry run)' || '' }}"

on:
workflow_dispatch:
inputs:
jruby_version:
description: "The JRuby version to build, specified as X.Y.Z (i.e. 9.4.7.0)"
schneems marked this conversation as resolved.
Show resolved Hide resolved
type: string
required: true
dry_run:
description: "Skip deploying to S3 (e.g. for testing)"
type: boolean
default: false
required: false

permissions:
contents: read

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "us-east-1"
S3_BUCKET: "heroku-buildpack-ruby"

jobs:
build-and-upload:
runs-on: pub-hk-ubuntu-22.04-xlarge
strategy:
fail-fast: false
matrix:
base_image: ["heroku-20", "heroku-22", "heroku-24"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Cargo build
run: cargo build
- name: Output CHANGELOG
run: cargo run --bin jruby_changelog -- --version "${{inputs.jruby_version}}"
- name: Build Ruby
run: cargo run --bin jruby_build -- --version ${{inputs.jruby_version}} --base-image ${{matrix.base_image}} \
- name: Check Ruby
run: cargo run --bin jruby_check -- --version ${{inputs.jruby_version}} --base-image ${{matrix.base_image}} --arch amd64 | tee $GITHUB_STEP_SUMMARY
- 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}"
119 changes: 22 additions & 97 deletions .github/workflows/build_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,107 +24,32 @@ env:
S3_BUCKET: "heroku-buildpack-ruby"

jobs:
build-and-upload-heroku-20:
runs-on: pub-hk-ubuntu-22.04-xlarge
env:
STACK: "heroku-20"
build_ruby:
runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-22.04-arm-xlarge' || 'pub-hk-ubuntu-22.04-xlarge' }}
strategy:
matrix:
arch: ["amd64", "arm64"]
base_image: ["heroku-20", "heroku-22", "heroku-24"]
exclude:
- base_image: "heroku-20"
arch: "arm64"
- base_image: "heroku-22"
arch: "arm64"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Cargo build
run: cargo build
- 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_summary "$STACK" "${{inputs.ruby_version}}" | tee $GITHUB_STEP_SUMMARY
- 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-22:
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-22"
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_summary "$STACK" "${{inputs.ruby_version}}" | tee $GITHUB_STEP_SUMMARY
- 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_summary "$STACK" "${{inputs.ruby_version}}" amd64 | tee $GITHUB_STEP_SUMMARY
- 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
# AWS CLI (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 AWS CLI
run: | # https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
sudo apt-get install -y unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- 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_summary "$STACK" "${{inputs.ruby_version}}" arm64 | tee $GITHUB_STEP_SUMMARY
run: cargo run --bin ruby_changelog -- --version "${{inputs.ruby_version}}"
- name: Build Ruby
run: cargo run --bin ruby_build -- --version ${{inputs.ruby_version}} --base-image ${{matrix.base_image}} --arch ${{matrix.arch}}
- name: Check Ruby
run: cargo run --bin ruby_check -- --version ${{inputs.ruby_version}} --base-image ${{matrix.base_image}} --arch ${{matrix.arch}} | tee $GITHUB_STEP_SUMMARY
- name: Upload Ruby runtime archive to S3 dry run
if: (inputs.dry_run)
run: aws s3 sync ./builds "s3://${S3_BUCKET}" --dryrun
Expand Down
143 changes: 71 additions & 72 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,101 +5,100 @@ on:
- pull_request

jobs:
lint:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- name: Linting
run: bundle exec standardrb --no-fix
- name: Run ShellCheck
run: shellcheck *.sh -x

test:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: test
run: bundle exec rspec spec
- name: Update Rust toolchain
# Most of the time this will be a no-op, since GitHub releases new images every week
# which include the latest stable release of Rust, Rustup, Clippy and rustfmt.
run: rustup update
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Clippy
# Using --all-targets so tests are checked and --deny to fail on warnings.
# Not using --locked here and below since Cargo.lock is in .gitignore.
run: cargo clippy --all-targets --all-features -- --deny warnings
- name: rustfmt
run: cargo fmt -- --check
- name: Check docs
# Using RUSTDOCFLAGS until `cargo doc --check` is stabilised:
# https://github.com/rust-lang/cargo/issues/10025
run: RUSTDOCFLAGS="-D warnings" cargo doc --all-features --document-private-items --no-deps

integration_test:
runs-on: pub-hk-ubuntu-22.04-xlarge
strategy:
matrix:
stack: ["heroku-20", "heroku-22"]
version: ["3.1.4"]
unit-test:
runs-on: ubuntu-latest
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_summary "${{matrix.stack}}" "${{matrix.version}}" | tee $GITHUB_STEP_SUMMARY
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Run unit tests
run: cargo test --all-features

integration_test-heroku-24-amd:
runs-on: pub-hk-ubuntu-22.04-xlarge
ruby_integration_test:
runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-22.04-arm-medium' || 'ubuntu-latest' }}
strategy:
matrix:
stack: ["heroku-24"]
base_image: ["heroku-20", "heroku-22", "heroku-24"]
version: ["3.2.3"]
arch: ["arm64", "amd64"]
exclude:
- base_image: "heroku-20"
arch: "arm64"
- base_image: "heroku-22"
arch: "arm64"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Cargo build (to make test logs shorter)
run: cargo build
- 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_summary "${{matrix.stack}}" "${{matrix.version}}" amd64 | tee $GITHUB_STEP_SUMMARY
run: cargo run --bin ruby_changelog -- --version "${{matrix.version}}"
- name: Build Ruby
run: cargo run --bin ruby_build -- --version ${{matrix.version}} --base-image ${{matrix.base_image}} --arch ${{matrix.arch}}
- name: Check Ruby
run: cargo run --bin ruby_check -- --version ${{matrix.version}} --base-image ${{matrix.base_image}} --arch ${{matrix.arch}}

integration_test-heroku-24-arm:
runs-on: pub-hk-ubuntu-22.04-arm-large
jruby_integration_test:
runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-22.04-arm-medium' || 'ubuntu-latest' }}
strategy:
matrix:
stack: ["heroku-24"]
version: ["3.2.3"]
base_image: ["heroku-20", "heroku-22", "heroku-24"]
version: ["9.4.7.0"]
arch: ["arm64", "amd64"]
exclude:
- base_image: "heroku-20"
arch: "arm64"
- base_image: "heroku-22"
arch: "arm64"
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
# AWS CLI (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 AWS CLI
run: | # https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
sudo apt-get install -y unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- name: Verify AWS installed correctly
run: aws --version
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Cargo build (to make test logs shorter)
run: cargo build
- 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_summary "${{matrix.stack}}" "${{matrix.version}}" arm64 | tee $GITHUB_STEP_SUMMARY
run: cargo run --bin jruby_changelog -- --version "${{matrix.version}}"
- name: Build JRuby
run: cargo run --bin jruby_build -- --version ${{matrix.version}} --base-image ${{matrix.base_image}}
- name: Check JRuby
run: cargo run --bin jruby_check -- --version ${{matrix.version}} --base-image ${{matrix.base_image}} --arch ${{matrix.arch}}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
.bundle/
builds/
output/
cache/
vendor/
.DS_Store

test/fixtures/repos/*
Dockerfile

# Added by cargo
target/
cli/target
inside_docker/target
5 changes: 0 additions & 5 deletions .standard.yml

This file was deleted.

Loading
Loading