Skip to content

Commit

Permalink
chore update tests and README, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jan 12, 2025
1 parent ae0dbc5 commit bbdf3d3
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 23 deletions.
9 changes: 0 additions & 9 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1131,15 +1131,6 @@ Here is a summary of the scenarios:
| Any


| 5
| Rails project
| Deploy project to packaged filesystem using `bundle install`
| `<mount_point>/local/<entry_point base name>`
| No
| One
| Any


| Error
| Error: Two or more `*.gem` files present
| -
Expand Down
24 changes: 18 additions & 6 deletions lib/tebako/codegen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ def deploy_crt_implib(opt, scm)
end

def deploy_mk(opt, scm)
case opt.mode
when "bundle"
deploy_mk_bundle(opt, scm)
when /runtime|both/
deploy_mk_stub(opt)
end
<<~SUBST
begin
#{deploy_mk_inner(opt, scm)}
rescue Tebako::Error => e
puts "tebako-packager failed: \#{e.message} [\#{e.error_code}]"
exit(e.error_code)
end
SUBST
end

def deploy_mk_bundle(opt, scm)
Expand All @@ -79,6 +81,15 @@ def deploy_mk_bundle(opt, scm)
SUBST
end

def deploy_mk_inner(opt, scm)
case opt.mode
when "bundle"
deploy_mk_bundle(opt, scm)
when /runtime|both/
deploy_mk_stub(opt)
end
end

def deploy_mk_stub(opt)
<<~SUBST
Tebako::Packager.deploy("#{opt.data_src_dir}", "#{opt.data_pre_dir}",
Expand All @@ -101,6 +112,7 @@ def deploy_rb(opt, scm)

def deploy_rq
<<~SUBST
require "#{File.join(__dir__, "error.rb")}"
require "#{File.join(__dir__, "package_descriptor.rb")}"
require "#{File.join(__dir__, "packager.rb")}"
require "#{File.join(__dir__, "ruby_version.rb")}"
Expand Down
4 changes: 2 additions & 2 deletions lib/tebako/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) 2023-2024 [Ribose Inc](https://www.ribose.com).
# Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
# All rights reserved.
# This file is a part of tebako
#
Expand All @@ -26,5 +26,5 @@
# POSSIBILITY OF SUCH DAMAGE.

module Tebako
VERSION = "0.12.0"
VERSION = "0.12.1"
end
8 changes: 4 additions & 4 deletions spec/codegen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,25 @@
end
end

describe "#deploy_mk" do
describe "#deploy_mk_inner" do
it 'calls deploy_mk_stub when mode is "both"' do
allow(options_manager).to receive(:mode).and_return("both")
allow(described_class).to receive(:deploy_mk_stub).and_return("mk_both_result")
result = described_class.deploy_mk(options_manager, scm)
result = described_class.deploy_mk_inner(options_manager, scm)
expect(result).to eq("mk_both_result")
end

it 'calls deploy_mk_stub when mode is "runtime"' do
allow(options_manager).to receive(:mode).and_return("runtime")
allow(described_class).to receive(:deploy_mk_stub).and_return("mk_stub_result")
result = described_class.deploy_mk(options_manager, scm)
result = described_class.deploy_mk_inner(options_manager, scm)
expect(result).to eq("mk_stub_result")
end

it "calls deploy_mk_bundle when mode by default" do
allow(options_manager).to receive(:mode).and_return("bundle")
allow(described_class).to receive(:deploy_mk_bundle).and_return("mk_bundle_result")
result = described_class.deploy_mk(options_manager, scm)
result = described_class.deploy_mk_inner(options_manager, scm)
expect(result).to eq("mk_bundle_result")
end
end
Expand Down
59 changes: 57 additions & 2 deletions spec/deploy_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
end

describe "#configure" do
let(:r_v) { "3.2.4" }
let(:r_v) { "3.2.6" }
let(:ruby_ver) { Tebako::RubyVersion.new(r_v) }
let(:cwd) { "/current/working/dir" }

Expand Down Expand Up @@ -174,7 +174,7 @@

describe "#check_entry_point" do
let(:entry_point_root) { "/project/entry_points" }
let(:r_v) { "3.2.4" }
let(:r_v) { "3.2.6" }
let(:ruby_ver) { Tebako::RubyVersion.new(r_v) }
let(:cwd) { "/current/working/dir" }

Expand Down Expand Up @@ -211,6 +211,61 @@
end
end

describe "#collect_and_deploy_gem" do
let(:gemspec) { "example.gemspec" }

before do
allow(deploy_helper).to receive(:puts)
allow(deploy_helper).to receive(:copy_files)
allow(deploy_helper).to receive(:check_entry_point)
allow(deploy_helper).to receive(:install_all_gems_or_fail)
allow(Dir).to receive(:chdir).and_yield
allow(Tebako::BuildHelpers).to receive(:run_with_capture_v)
end

it "copies files, builds gem, installs gems, and checks entry point" do
deploy_helper.send(:collect_and_deploy_gem, gemspec)

expect(deploy_helper).to have_received(:copy_files).with(deploy_helper.instance_variable_get(:@pre_dir))
expect(Tebako::BuildHelpers)
.to have_received(:run_with_capture_v)
.with([deploy_helper.gem_command, "build", gemspec])
expect(deploy_helper).to have_received(:install_all_gems_or_fail)
expect(deploy_helper).to have_received(:check_entry_point).with("bin")
end
end

describe "#collect_and_deploy_gem_and_gemfile" do
let(:gemspec) { "example.gemspec" }

before do
# Stub out console output and other helper methods
allow(deploy_helper).to receive(:puts)
allow(deploy_helper).to receive(:copy_files)
allow(deploy_helper).to receive(:check_entry_point)
allow(deploy_helper).to receive(:install_all_gems_or_fail)
allow(deploy_helper).to receive(:bundle_config)
# Stubs for external calls
allow(Dir).to receive(:chdir).and_yield
allow(Tebako::BuildHelpers).to receive(:run_with_capture_v)
end

it "copies files, runs bundler install, builds gem, installs gems, and checks entry point" do
deploy_helper.send(:collect_and_deploy_gem_and_gemfile, gemspec)

expect(deploy_helper).to have_received(:copy_files).with(deploy_helper.instance_variable_get(:@pre_dir))
expect(deploy_helper).to have_received(:bundle_config)
expect(Tebako::BuildHelpers)
.to have_received(:run_with_capture_v)
.with([deploy_helper.bundler_command, "install", "--jobs=#{deploy_helper.instance_variable_get(:@ncores)}"])
expect(Tebako::BuildHelpers)
.to have_received(:run_with_capture_v)
.with([deploy_helper.bundler_command, "exec", deploy_helper.gem_command, "build", gemspec])
expect(deploy_helper).to have_received(:install_all_gems_or_fail)
expect(deploy_helper).to have_received(:check_entry_point).with("bin")
end
end

describe "#configure_commands" do
context "when os_type is msys" do
before do
Expand Down

0 comments on commit bbdf3d3

Please sign in to comment.