diff --git a/.github/workflows/tutorial.yml b/.github/workflows/tutorial.yml index 3dba9b4..5fd64dd 100644 --- a/.github/workflows/tutorial.yml +++ b/.github/workflows/tutorial.yml @@ -31,7 +31,7 @@ jobs: - name: Package 1_hello_world run: | - tebako press --root=tutorial/1_hello_world/sample --entry=hello_world.rb + tebako press --root=tutorial/1_hello_world/hellow_world.sample --entry=hello_world.rb - name: Run packaged 1_hello_world application run: | @@ -40,7 +40,7 @@ jobs: - name: Package 1_hello_world with a difefrent name run: | - tebako press --root=tutorial/1_hello_world/sample --entry=hello_world.rb --output=lesson-1 + tebako press --root=tutorial/1_hello_world/hellow_world.sample --entry=hello_world.rb --output=lesson-1 - name: Run packaged 1_hello_world application with a different name run: | @@ -52,6 +52,14 @@ jobs: # Cannot run this sample since GH Actions does not allow such websocket connection to the outside world + - name: Package 2_scenarios gemspec and gemfile sample + run: | + tebako press -r tutorial/2_scenarios/gemspec_and_gemfile.sample -e tebako-table-cli -o table.tebako + + - name: Run packaged 2_scenarios gemspec and gemfile sample + run: | + ./table.tebako + - name: Package 2_scenarios gemspec sample run: | tebako press -r tutorial/2_scenarios/gemspec.sample -e tebako-table-cli -o table.tebako @@ -60,10 +68,14 @@ jobs: run: | ./table.tebako - - name: Package 2_scenarios gemspec and gemfile sample + - name: Package 2_scenarios gem sample run: | - tebako press -r tutorial/2_scenarios/gemspec_and_gemfile.sample -e tebako-table-cli -o table.tebako + mkdir -p tutorial/2_scenarios/gem.sample + pushd tutorial/2_scenarios/gemspec.sample + gem build tebako-table.gemspec -o ../gem.sample/tebako-test-0.0.2.gem + popd + tebako press -r tutorial/2_scenarios/gem.sample -e tebako-table-cli -o table.tebako - - name: Run packaged 2_scenarios gemspec and gemfile sample + - name: Run packaged 2_scenarios gems sample run: | ./table.tebako diff --git a/.gitignore b/.gitignore index bb92950..6a9ea43 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,5 @@ log # Tutorila hello_world source_filesystem/ -*.tebako \ No newline at end of file +*.tebako +gem.sample/ \ No newline at end of file diff --git a/tutorial/1_hello_world/Lesson-1.adoc b/tutorial/1_hello_world/Lesson-1.adoc index f0464e9..e4f53a2 100644 --- a/tutorial/1_hello_world/Lesson-1.adoc +++ b/tutorial/1_hello_world/Lesson-1.adoc @@ -59,7 +59,7 @@ Now we can package it with Tebako: [source,sh] ---- -tebako press --root=sample --entry=hello_world.rb +tebako press --root=hellow_world.sample --entry=hello_world.rb ---- This command uses two mandatory parameters: `--root` and `--entry`. @@ -103,7 +103,7 @@ We can use `--output` to specify the name of the package: [source,sh] ---- -tebako press --root=sample --entry=hello_world.rb --output=lesson-1 +tebako press --root=hellow_world.sample --entry=hello_world.rb --output=lesson-1 ---- This command creates an executable file `lesson-1` that contains the runtime, the Ruby library files, and the application. diff --git a/tutorial/1_hello_world/sample/hello_world.rb b/tutorial/1_hello_world/hello_world.sample/hello_world.rb similarity index 100% rename from tutorial/1_hello_world/sample/hello_world.rb rename to tutorial/1_hello_world/hello_world.sample/hello_world.rb diff --git a/tutorial/2_scenarios/Lesson-2.adoc b/tutorial/2_scenarios/Lesson-2.adoc index 8411bdc..d605c0a 100644 --- a/tutorial/2_scenarios/Lesson-2.adoc +++ b/tutorial/2_scenarios/Lesson-2.adoc @@ -83,8 +83,6 @@ We will use the following gem specification (`gemfile.sample/tebako-table.gemsp [source,Ruby] ---- -# frozen_string_literal: true - require_relative "lib/version" Gem::Specification.new do |s| @@ -103,14 +101,20 @@ Gem::Specification.new do |s| end ---- +trivial Gemfile + +[source,Ruby] +---- +source "https://rubygems.org" +gemspec +---- + and three source files -1. `gemfile.sample/exe/tebako-table-cli` +1. `gemspec_and_gemfile.sample/exe/tebako-table-cli` [source,Ruby] ---- -# frozen_string_literal: true - $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "tebako-table" @@ -118,11 +122,10 @@ instance = Test::TebakoTable.new instance.run ---- -2. `gemfile.sample/lib/tebako-table.rb` +2. `gemspec_and_gemfile.sample/lib/tebako-table.rb` [source,Ruby] ---- -# frozen_string_literal: true require "text-table" require_relative "version" @@ -148,60 +151,90 @@ module Test end ---- -3. `gemfile.sample/lib/version.rb` +3. `gemspec_and_gemfile.sample/lib/version.rb` [source,Ruby] ---- -# frozen_string_literal: true - module Test VERSION = "0.0.2" end ---- -Press command is the same: +Press command does not change: [source,sh] ---- -tebako press -r gemspec.sample -e tebako-table-cli -o table.tebako +tebako press -r gemspec_and_gemfile.sample -e tebako-table-cli -o table.tebako ---- -but deployment scenario is different: -[source,sh] +but now Tebako recognizes that it packages a gem and applies diffent deployment scenario: + +[source] ---- -- Running init script ... creating packaging environment at /Users/runner/.tebako/o/s -- Running deploy script ... installing tebako-runtime gem ... @ /Users/runner/.tebako/o/s/bin/gem install tebako-runtime --no-document --install-dir /Users/runner/.tebako/o/s/lib/ruby/gems/3.2.0 - ... Collecting gem from gemspec /Users/runner/work/tebako-samples/tebako-samples/tutorial/2_scenarios/gemspec.sample/tebako-table.gemspec - ... @ /Users/runner/.tebako/o/s/bin/gem build /Users/runner/work/tebako-samples/tebako-samples/tutorial/2_scenarios/gemspec.sample/tebako-table.gemspec + ... collecting gem from gemspec /Users/runner/work/tebako-samples/tebako-samples/tutorial/2_scenarios/gemspec_and_gemfile.sample/tebako-table.gemspec and Gemfile + ... @ /Users/runner/.tebako/o/s/bin/bundle config set --local build.ffi --disable-system-libffi + ... @ /Users/runner/.tebako/o/s/bin/bundle config set --local build.nokogiri --no-use-system-libraries + ... @ /Users/runner/.tebako/o/s/bin/bundle config set --local force_ruby_platform false + *** It may take a long time for a big project. It takes REALLY long time on Windows *** + ... @ /Users/runner/.tebako/o/s/bin/bundle install --jobs=3 + ... @ /Users/runner/.tebako/o/s/bin/bundle exec /Users/runner/.tebako/o/s/bin/gem build + /Users/runner/work/tebako-samples/tebako-samples/tutorial/2_scenarios/gemspec_and_gemfile.sample/tebako-table.gemspec ... installing /Users/runner/.tebako/o/r/tebako-test-0.0.2.gem - ... @ /Users/runner/.tebako/o/s/bin/gem install /Users/runner/.tebako/o/r/tebako-test-0.0.2.gem --no-document --install-dir /Users/runner/.tebako/o/s/lib/ruby/gems/3.2.0 --bindir /Users/runner/.tebako/o/s/bin + ... @ /Users/runner/.tebako/o/s/bin/gem install /Users/runner/.tebako/o/r/tebako-test-0.0.2.gem --no-document + --install-dir /Users/runner/.tebako/o/s/lib/ruby/gems/3.2.0 --bindir /Users/runner/.tebako/o/s/bin ... target entry point will be at /__tebako_memfs__/bin/tebako-table-cli + ... stripping the output ---- Tebako now installs the gem to its Ruby environment and assumes that the entry point is the wrapper created by gem command in the `binary` directory. Note that entrypoint script shall be explicitly specified as one of gem executables. -== Packaging a gem with gemfile dependencies +== Packaging a gem without bundle +Tebako also supports gems defined without Gemfile (not bundled). We can copy the previous example, specify dependencies in gemspec, +remove Gemfile and do tebako packaging + +[source,sh] +---- +tebako press -r gemspec.sample -e tebako-table-cli -o table.tebako +---- + +[source] +---- -- Running init script - ... creating packaging environment at /home/maxirmx/.tebako/o/s + ... creating packaging environment at /Users/runner/.tebako/o/s -- Running deploy script ... installing tebako-runtime gem - ... @ /home/maxirmx/.tebako/o/s/bin/gem install tebako-runtime --no-document --install-dir /home/maxirmx/.tebako/o/s/lib/ruby/gems/3.2.0 - ... collecting gem from gemspec /home/maxirmx/Projects/tebako-samples/tutorial/2_scenarios/gemspec_and_gemfile.sample/tebako-table.gemspec and Gemfile - ... @ /home/maxirmx/.tebako/o/s/bin/bundle config set --local build.ffi --disable-system-libffi - ... @ /home/maxirmx/.tebako/o/s/bin/bundle config set --local build.nokogiri --no-use-system-libraries - ... @ /home/maxirmx/.tebako/o/s/bin/bundle config set --local force_ruby_platform false - *** It may take a long time for a big project. It takes REALLY long time on Windows *** - ... @ /home/maxirmx/.tebako/o/s/bin/bundle install --jobs=16 - ... @ /home/maxirmx/.tebako/o/s/bin/bundle exec /home/maxirmx/.tebako/o/s/bin/gem build /home/maxirmx/Projects/tebako-samples/tutorial/2_scenarios/gemspec_and_gemfile.sample/tebako-table.gemspec - ... installing /home/maxirmx/.tebako/o/r/tebako-test-0.0.2.gem - ... @ /home/maxirmx/.tebako/o/s/bin/gem install /home/maxirmx/.tebako/o/r/tebako-test-0.0.2.gem --no-document --install-dir /home/maxirmx/.tebako/o/s/lib/ruby/gems/3.2.0 --bindir /home/maxirmx/.tebako/o/s/lib + ... @ /Users/runner/.tebako/o/s/bin/gem install tebako-runtime --no-document --install-dir /Users/runner/.tebako/o/s/lib/ruby/gems/3.2.0 + ... collecting gem from gemspec /Users/runner/work/tebako-samples/tebako-samples/tutorial/2_scenarios/gemspec.sample/tebako-table.gemspec + ... @ /Users/runner/.tebako/o/s/bin/gem build /Users/runner/work/tebako-samples/tebako-samples/tutorial/2_scenarios/gemspec.sample/tebako-table.gemspec + ... installing /Users/runner/.tebako/o/r/tebako-test-0.0.2.gem + ... @ /Users/runner/.tebako/o/s/bin/gem install /Users/runner/.tebako/o/r/tebako-test-0.0.2.gem --no-document + --install-dir /Users/runner/.tebako/o/s/lib/ruby/gems/3.2.0 --bindir /Users/runner/.tebako/o/s/bin ... target entry point will be at /__tebako_memfs__/bin/tebako-table-cli - ... stripping the output +---- + +This approach is faster but may fail for gems with native extensions since Tebako won't have enough control to correctly configure them. +We primarily support it for backwords compatibility. + +== Packaging built gem + +Tebako can also package a gem or gems, i.e.: one or several `*.gem` files + +[source,sh] +---- +mkdir -p gem.sample +pushd gemspec.sample +gem build tebako-table.gemspec -o ../gem.sample/tebako-test-0.0.2.gem +popd +tebako press -r gem.sample -e tebako-table-cli -o table.tebako +---- + == Live example diff --git a/tutorial/2_scenarios/gemspec.sample/exe/tebako-table-cli b/tutorial/2_scenarios/gemspec.sample/exe/tebako-table-cli old mode 100644 new mode 100755 index 0e14c49..c9e6387 --- a/tutorial/2_scenarios/gemspec.sample/exe/tebako-table-cli +++ b/tutorial/2_scenarios/gemspec.sample/exe/tebako-table-cli @@ -1,3 +1,4 @@ +#!/home/tebako/bin/ruby # frozen_string_literal: true # Tebako tutorial: Lesson 2 diff --git a/tutorial/2_scenarios/gemspec_and_gemfile.sample/exe/tebako-table-cli b/tutorial/2_scenarios/gemspec_and_gemfile.sample/exe/tebako-table-cli old mode 100644 new mode 100755 index 0e14c49..c9e6387 --- a/tutorial/2_scenarios/gemspec_and_gemfile.sample/exe/tebako-table-cli +++ b/tutorial/2_scenarios/gemspec_and_gemfile.sample/exe/tebako-table-cli @@ -1,3 +1,4 @@ +#!/home/tebako/bin/ruby # frozen_string_literal: true # Tebako tutorial: Lesson 2