From 6f8a8a493b765dcec966a2ff1159d31f034bae26 Mon Sep 17 00:00:00 2001 From: Richard Schneeman Date: Tue, 26 Sep 2023 09:56:38 -0500 Subject: [PATCH 1/5] Test heroku-20 on CI --- .github/workflows/ci.yml | 49 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93622da..1452820 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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}}]" From c4e545e5463b93a42c0e170457d1c9cc2a40f498 Mon Sep 17 00:00:00 2001 From: Richard Schneeman Date: Tue, 26 Sep 2023 10:36:36 -0500 Subject: [PATCH 2/5] Fix gem version command for preview releases --- Rakefile | 9 +++++---- lib/docker_command.rb | 5 +++++ spec/unit/docker_command_spec.rb | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 lib/docker_command.rb create mode 100644 spec/unit/docker_command_spec.rb diff --git a/Rakefile b/Rakefile index 1fbb523..7fda20b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__) require "ruby_version" require "changelog" +require "docker_command" require "fileutils" @@ -35,11 +36,11 @@ 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 diff --git a/lib/docker_command.rb b/lib/docker_command.rb new file mode 100644 index 0000000..0ae9437 --- /dev/null +++ b/lib/docker_command.rb @@ -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 diff --git a/spec/unit/docker_command_spec.rb b/spec/unit/docker_command_spec.rb new file mode 100644 index 0000000..124337e --- /dev/null +++ b/spec/unit/docker_command_spec.rb @@ -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 = %Q{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 = %Q{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 From ae7e01df689b50ce7313a46eaa955e3b8ee503cd Mon Sep 17 00:00:00 2001 From: Richard Schneeman Date: Tue, 26 Sep 2023 11:00:16 -0500 Subject: [PATCH 3/5] Fix test name --- spec/unit/changelog_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/changelog_spec.rb b/spec/unit/changelog_spec.rb index de8bc5a..588b4a4 100644 --- a/spec/unit/changelog_spec.rb +++ b/spec/unit/changelog_spec.rb @@ -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( From 58a0c48e31ff25ac3fcb2d5f8f81992c65e915b5 Mon Sep 17 00:00:00 2001 From: Richard Schneeman Date: Tue, 26 Sep 2023 11:00:24 -0500 Subject: [PATCH 4/5] Fix heroku-20 dockerfile --- dockerfiles/Dockerfile.heroku-20 | 1 + 1 file changed, 1 insertion(+) diff --git a/dockerfiles/Dockerfile.heroku-20 b/dockerfiles/Dockerfile.heroku-20 index fc15af7..eb6d251 100644 --- a/dockerfiles/Dockerfile.heroku-20 +++ b/dockerfiles/Dockerfile.heroku-20 @@ -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"] From 729f560175e417a07c296e283390c638ef5e0a4c Mon Sep 17 00:00:00 2001 From: Richard Schneeman Date: Tue, 26 Sep 2023 12:59:36 -0500 Subject: [PATCH 5/5] $ bundle exec standardrb --fix --- Rakefile | 3 +-- lib/docker_command.rb | 2 +- spec/unit/docker_command_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 7fda20b..8718663 100644 --- a/Rakefile +++ b/Rakefile @@ -36,10 +36,9 @@ end desc "Output the Rubygems version for a given binary" task :rubygems_version, [:version, :stack] do |t, args| - command = DockerCommand.gem_version_from_tar( stack: args[:stack], - ruby_version: RubyVersion.new(args[:version]), + ruby_version: RubyVersion.new(args[:version]) ) puts "Running: #{command}" pipe(command) diff --git a/lib/docker_command.rb b/lib/docker_command.rb index 0ae9437..95159ae 100644 --- a/lib/docker_command.rb +++ b/lib/docker_command.rb @@ -1,5 +1,5 @@ module DockerCommand - def self.gem_version_from_tar(ruby_version: , stack: ) + 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 diff --git a/spec/unit/docker_command_spec.rb b/spec/unit/docker_command_spec.rb index 124337e..aac2818 100644 --- a/spec/unit/docker_command_spec.rb +++ b/spec/unit/docker_command_spec.rb @@ -4,13 +4,13 @@ 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 = %Q{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"} + 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 = %Q{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"} + 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