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

Test and fix heroku-20 #33

Merged
merged 5 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
49 changes: 24 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,27 @@ jobs:
run: bundle exec rspec spec

integration_test:
runs-on: pub-hk-ubuntu-22.04-xlarge
env:
STACK: "heroku-22"
TEST_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
- name: Output CHANGELOG
run: bundle exec rake "changelog[$TEST_VERSION]"
- name: Build Docker image
run: bundle exec rake "generate_image[$STACK]"
- name: Generate Ruby Dockerfile
run: bundle exec rake "new[$TEST_VERSION,$STACK]"
- name: Build and package Ruby runtime
run: bash "rubies/$STACK/ruby-$TEST_VERSION.sh"
- name: Verify ruby executable and output rubygems version
run: bundle exec rake "rubygems_version[$TEST_VERSION,$STACK]"


runs-on: pub-hk-ubuntu-22.04-xlarge
strategy:
matrix:
stack: ["heroku-20", "heroku-22"]
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
- name: Output CHANGELOG
run: bundle exec rake "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}}]"
- name: Build and package Ruby runtime
run: bash "rubies/${{matrix.stack}}/ruby-${{matrix.version}}.sh"
- name: Verify ruby executable and output rubygems version
run: bundle exec rake "rubygems_version[${{matrix.version}},${{matrix.stack}}]"
10 changes: 5 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "ruby_version"
require "changelog"
require "docker_command"

require "fileutils"

Expand Down Expand Up @@ -35,11 +36,10 @@ end

desc "Output the Rubygems version for a given binary"
task :rubygems_version, [:version, :stack] do |t, args|
stack = args[:stack]
ruby_version = args[:version]

# Extract the binary in a docker image and run `bin/gem -v` to output it's Rubygems version
command = "docker run -v $(pwd)/builds/#{stack}:/tmp/output hone/ruby-builder:#{stack} bash -c \"mkdir /tmp/unzipped && tar xzf /tmp/output/ruby-#{ruby_version}.tgz -C /tmp/unzipped && echo 'Rubygems version is: ' && /tmp/unzipped/bin/gem -v\""
command = DockerCommand.gem_version_from_tar(
stack: args[:stack],
ruby_version: RubyVersion.new(args[:version])
)
puts "Running: #{command}"
pipe(command)
end
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.heroku-20
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ ENV PATH="/root/.cargo/bin:${PATH}"
# output dir is mounted

ADD build.rb /tmp/build.rb
COPY lib/ /tmp/lib/
CMD ["ruby", "/tmp/build.rb", "/tmp/workspace", "/tmp/output", "/tmp/cache"]
5 changes: 5 additions & 0 deletions lib/docker_command.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module DockerCommand
def self.gem_version_from_tar(ruby_version:, stack:)
"docker run -v $(pwd)/builds/#{stack}:/tmp/output hone/ruby-builder:#{stack} bash -c \"mkdir /tmp/unzipped && tar xzf /tmp/output/#{ruby_version.tar_file_name_output} -C /tmp/unzipped && echo 'Rubygems version is: ' && /tmp/unzipped/bin/gem -v\""
end
end
2 changes: 1 addition & 1 deletion spec/unit/changelog_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "spec_helper"
require "changelog"

describe RubyVersion do
describe "Changelog output" do
it "prints changelog info for regular releases" do
io = StringIO.new
Changelog.new(
Expand Down
16 changes: 16 additions & 0 deletions spec/unit/docker_command_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "spec_helper"
require "docker_command"

describe DockerCommand do
it "Generates docker command for outputting rubygems versions" do
actual = DockerCommand.gem_version_from_tar(ruby_version: RubyVersion.new("3.1.4"), stack: "heroku-22")
expected = %{docker run -v $(pwd)/builds/heroku-22:/tmp/output hone/ruby-builder:heroku-22 bash -c "mkdir /tmp/unzipped && tar xzf /tmp/output/ruby-3.1.4.tgz -C /tmp/unzipped && echo 'Rubygems version is: ' && /tmp/unzipped/bin/gem -v"}
expect(actual).to eq(expected)
end

it "works with preview releases" do
actual = DockerCommand.gem_version_from_tar(ruby_version: RubyVersion.new("3.3.0-preview2"), stack: "heroku-22")
expected = %{docker run -v $(pwd)/builds/heroku-22:/tmp/output hone/ruby-builder:heroku-22 bash -c "mkdir /tmp/unzipped && tar xzf /tmp/output/ruby-3.3.0.tgz -C /tmp/unzipped && echo 'Rubygems version is: ' && /tmp/unzipped/bin/gem -v"}
expect(actual).to eq(expected)
end
end