Skip to content

Commit

Permalink
test: create tests for separate runtime/application packaging feature
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Dec 18, 2024
1 parent a79683f commit ceed09f
Show file tree
Hide file tree
Showing 24 changed files with 1,372 additions and 74 deletions.
4 changes: 3 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ test_task_template: &TEST_TASK_TEMPLATE
testset-1_script: |
RUBY_VER=3.2.5 tests/scripts/functional-tests.sh
testset-1-app_script: |
RUBY_VER=3.3.5 tests/scripts/functional-tests-app.sh
testset-2_script: |
RUBY_VER=3.2.5 ruby tests-2/tebako-test.rb
checkout-packed-mn_script: |
git clone https://github.com/metanorma/packed-mn.git packed-mn
Expand Down
9 changes: 7 additions & 2 deletions .github/actions/setup-tebako/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,15 @@ runs:
if: runner.os == 'macOS'
shell: bash
run: |
pushd $(mktemp -d)
brew update
if [ ! -f Brewfile ]; then
pushd $(mktemp -d)
curl https://raw.githubusercontent.com/tamatebako/tebako/refs/heads/main/Brewfile > Brewfile
brew bundle -f
popd
popd
else
brew bundle -f
fi
echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH
- name: Install pacman packages
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,62 @@ jobs:
with:
upload: "${{ steps.shall-upload.outputs.upload }}"

tests-1-app:
needs: setup
name: tests-1-app alpine-${{ matrix.env.ALPINE_VER }} Ruby ${{ matrix.package_ruby_ver }} CC ${{ matrix.env.CC }}
runs-on: ubuntu-latest
container:
image: alpine:${{ matrix.env.ALPINE_VER }}
strategy:
fail-fast: false
matrix:
env:
- { CC: gcc, CXX: g++, ALPINE_VER: "3.17" }
- { CC: clang, CXX: clang++, ALPINE_VER: "3.17" }
package_ruby_ver: [ '3.1.6', '3.2.5', '3.3.4', '3.3.5' ]
env: ${{ matrix.env }}
steps:
- name: Install packages
run: |
apk --no-cache --upgrade add git bash
git config --global --add safe.directory $PWD
- name: Checkout tebako packaging environment
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true

- name: Setup ci environment
uses: ./.github/actions/setup-tebako
with:
cache: off
cc: ${{ env.CC }}
cxx: ${{ env.CXX }}
install: off
verbose: ${{ env.VERBOSE }}

- name: Setup development environment
uses: ./.github/actions/setup-tebako-development
with:
path: deps
os: alpine-${{ matrix.env.ALPINE_VER }}
cc: ${{ env.CC }}
version: ${{ env.CACHE_VER }}

- name: Checkout shell test framework
uses: actions/checkout@v4
with:
repository: kward/shunit2
path: ${{github.workspace}}/tests/shunit2
fetch-depth: 1

- name: Run tebako tests (set no. 1) for separately packaged application
shell: bash
run: |
bundle install
RUBY_VER=${{ matrix.package_ruby_ver }} tests/scripts/functional-tests-app.sh
tests-2:
needs: setup
name: tests-2 alpine-${{ matrix.env.ALPINE_VER }} Ruby ${{ matrix.package_ruby_ver }} CC ${{ matrix.env.CC }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gem-test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ concurrency:
cancel-in-progress: true

env:
CACHE_VER: 12
CACHE_VER: 15
DEBIAN_FRONTEND: "noninteractive"
TZ: "Etc/UTC"
# show cmake output
Expand Down
57 changes: 52 additions & 5 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ concurrency:
cancel-in-progress: true

env:
CACHE_VER: 11
CACHE_VER: 15
VERBOSE: no

jobs:
Expand Down Expand Up @@ -116,8 +116,6 @@ jobs:

package_ruby_ver: [ '3.1.6', '3.2.5', '3.3.5' ]
ruby_ver: ['3.2.5']
include:
- { env: { os: macos-14, xcode: 15.4 }, ruby_ver: '3.3.4', package_ruby_ver: '3.3.4' }
steps:
- name: Checkout tebako packaging environment
uses: actions/checkout@v4
Expand Down Expand Up @@ -157,6 +155,57 @@ jobs:
upload: "${{ steps.shall-upload.outputs.upload }}"
verbose: ${{ env.VERBOSE }}

tests-1-app:
needs: setup
name: tests-1-app package Ruby ${{ matrix.package_ruby_ver }} on ${{ matrix.env.os }}, XCode ${{ matrix.env.xcode }}, Ruby ${{ matrix.ruby_ver }}
runs-on: ${{ matrix.env.os }}
strategy:
fail-fast: false
matrix:
env:
- { os: macos-13, xcode: 14.3.1 }
- { os: macos-14, xcode: 15.4 }
- { os: macos-15, xcode: 16.1 }

package_ruby_ver: [ '3.3.5' ]
ruby_ver: ['3.2.5']
steps:
- name: Checkout tebako packaging environment
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true

- name: Setup ci environment
uses: ./.github/actions/setup-tebako
with:
cache: off
install: off
ruby_version: ${{ matrix.ruby_ver }}
xcode: ${{ matrix.env.xcode }}
verbose: ${{ env.VERBOSE }}

- name: Setup development environment
uses: ./.github/actions/setup-tebako-development
with:
path: deps
os: ${{ matrix.env.os }}
cc: ruby-${{ matrix.ruby_ver }}-XCode-${{ matrix.env.xcode }}
version: ${{ env.CACHE_VER }}

- name: Checkout shell test framework
uses: actions/checkout@v4
with:
repository: kward/shunit2
path: ${{github.workspace}}/tests/shunit2
fetch-depth: 1

- name: Run tebako tests (set no. 1) for separately packaged application
shell: bash
run: |
bundle install
RUBY_VER=${{ matrix.package_ruby_ver }} tests/scripts/functional-tests-app.sh
tests-2:
needs: setup
name: tests-2 package Ruby ${{ matrix.package_ruby_ver }} on ${{ matrix.env.os }}, XCode ${{ matrix.env.xcode }}, Ruby ${{ matrix.ruby_ver }}
Expand All @@ -171,8 +220,6 @@ jobs:
- { os: macos-15, xcode: 16.1 }
package_ruby_ver: [ '3.1.6', '3.2.5', '3.3.5' ]
ruby_ver: ['3.2.5']
include:
- { env: { os: macos-14, xcode: 15.4 }, ruby_ver: '3.3.4', package_ruby_ver: '3.3.4' }
steps:
- name: Checkout tebako packaging environment
uses: actions/checkout@v4
Expand Down
51 changes: 50 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ on:
- .github/workflows/macos.yml
- .github/workflows/windows-msys.yml
- .cirrus.yml
- Brewfile
- Brewfile
workflow_dispatch:

concurrency:
Expand Down Expand Up @@ -155,6 +155,55 @@ jobs:
with:
upload: "${{ steps.shall-upload.outputs.upload }}"

tests-1-app:
needs: setup
name: tests-1-app ${{ matrix.env.os }} Ruby ${{ matrix.package_ruby_ver }} CC ${{ matrix.env.CC }}
runs-on: ${{ matrix.env.os }}
strategy:
fail-fast: false
matrix:
package_ruby_ver: [ '2.7.8', '3.0.7', '3.1.6', '3.2.5', '3.3.5' ]
env:
- { os: ubuntu-20.04, CC: gcc-10, CXX: g++-10 }
- { os: ubuntu-20.04, CC: clang-12, CXX: clang++-12 }
env: ${{ matrix.env }}
steps:
- name: Checkout tebako packaging environment
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true

- name: Setup ci environment
uses: ./.github/actions/setup-tebako
with:
cache: off
cc: ${{ env.CC }}
cxx: ${{ env.CXX }}
install: off
verbose: ${{ env.VERBOSE }}

- name: Setup development environment
uses: ./.github/actions/setup-tebako-development
with:
path: deps
os: ${{ matrix.env.os }}
cc: ${{ env.CC }}
version: ${{ env.CACHE_VER }}

- name: Checkout shell test framework
uses: actions/checkout@v4
with:
repository: kward/shunit2
path: ${{github.workspace}}/tests/shunit2
fetch-depth: 1

- name: Run tebako tests (set no. 1) for separately packaged application
shell: bash
run: |
bundle install
RUBY_VER=${{ matrix.package_ruby_ver }} tests/scripts/functional-tests-app.sh
tests-2:
needs: setup
name: tests-2 ${{ matrix.env.os }} Ruby ${{ matrix.package_ruby_ver }} CC ${{ matrix.env.CC }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/windows-msys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:

tests-1:
needs: setup
name: tests-1 windows-msys [${{ matrix.env.sys }}, Ruby ${{ matrix.package_ruby_ver }} CC ${{ matrix.env.CC }}]
name: tests-1${{ matrix.script }} windows-msys [${{ matrix.env.sys }}, Ruby ${{ matrix.package_ruby_ver }} CC ${{ matrix.env.CC }}]
runs-on: windows-latest
strategy:
fail-fast: false
Expand All @@ -150,6 +150,7 @@ jobs:
CC: gcc
CXX: g++
package_ruby_ver: [ '3.1.6', '3.2.5', '3.3.5' ]
script: ['', '-app']
env: ${{ matrix.env }}

defaults:
Expand Down Expand Up @@ -218,7 +219,7 @@ jobs:
fetch-depth: 1

- name: Run tebako tests (set no. 1)
run: RUBY_VER=${{ matrix.package_ruby_ver }} tests/scripts/functional-tests.sh
run: RUBY_VER=${{ matrix.package_ruby_ver }} tests/scripts/functional-tests${{ matrix.script }}.sh

tests-2:
needs: setup
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ tebako_test.log
tests-actions/
.environment.version
*.tebako
tebako-runtime

# rspec
.rspec_status
Expand Down
5 changes: 3 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,12 @@ this parameter defines Ruby version that will be packaged (optional, defaults to
`3.1.6`)

`project-root`::
a folder at the host source file system where project files are located
a folder at the host source file system where project files are located.
This parameter is not required if the operation mode is 'runtime'.

`entry-point`::
an executable file (binary executable or script) that shall be started when
packaged file is called
packaged file is called. This parameter is not required if the operation mode is 'runtime'.

`output`::
the output file name (optional, defaults to `<current folder>/<entry point base name>`
Expand Down
31 changes: 24 additions & 7 deletions lib/tebako/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
module Tebako
DEFAULT_TEBAFILE = ".tebako.yml"
# Tebako packager front-end
class Cli < Thor
class Cli < Thor # rubocop:disable Metrics/ClassLength
package_name "Tebako"
class_option :prefix, type: :string, aliases: "-p", required: false,
desc: "A path to tebako packaging environment, '~/.tebako' ('$HOME/.tebako') by default"
Expand Down Expand Up @@ -82,28 +82,35 @@ def hash
#{" " * 65}# If this parameter is not set, the application will start in the current directory of the host file system.
DESC

REF_DESCRIPTION = <<~DESC
"Referenced tebako run-time package; 'tebako-runtime' by default".
This option specifies the tebako runtime to be used by the application on Windows and if mode is 'application' only .
DESC

RGP_DESCRIPTION = <<~DESC
Activates removal a reference to GLIBC_PRIVATE version of libpthread from tebako package. This allows Linux Gnu packages to run against versions of
#{" " * 65}# libpthread that differ from the version used for packaging. For example, package created at Ubuntu 20 system can be used on Ubuntu 22. This option works on Gnu Linux with
#{" " * 65}# Gnu toolchain only (not for LLVM/clang). The feature is exeprimental, we may consider other approach in the future.
Current working directory for packaged application. This directory shall be specified relative to root.
#{" " * 65}# If this parameter is not set, the application will start in the current directory of the host file system.
DESC

desc "press", "Press tebako image"
method_option :cwd, type: :string, aliases: "-c", required: false, desc: CWD_DESCRIPTION
method_option :"entry-point", type: :string, aliases: ["-e", "--entry"], required: true,
desc: "Ruby application entry point"
method_option :"log-level", type: :string, aliases: "-l", required: false, enum: %w[error warn debug trace],
desc: "Tebako memfs logging level, 'error' by default"
method_option :output, type: :string, aliases: "-o", required: false,
desc: "Tebako package file name, entry point base file name in the current folder by default"
method_option :root, type: :string, aliases: "-r", required: true, desc: "Root folder of the Ruby application"
method_option :"entry-point", type: :string, aliases: ["-e", "--entry"], required: false,
desc: "Ruby application entry point"
method_option :root, type: :string, aliases: "-r", required: false, desc: "Root folder of the Ruby application"
method_option :Ruby, type: :string, aliases: "-R", required: false,
enum: Tebako::RubyVersion::RUBY_VERSIONS.keys,
desc: "Tebako package Ruby version, #{Tebako::RubyVersion::DEFAULT_RUBY_VERSION} by default"
method_option :patchelf, aliases: "-P", type: :boolean, desc: RGP_DESCRIPTION
method_option :mode, type: :string, aliases: "-m", required: false, enum: %w[bundle both runtime application],
desc: "Tebako press mode, 'bundle' by default"
method_option :ref, type: :string, aliases: "-u", required: false, desc: REF_DESCRIPTION

def press
validate_press_options
(om, cm) = bootstrap

do_press(om)
Expand Down Expand Up @@ -159,6 +166,16 @@ def options
end
end

no_commands do
def validate_press_options
return unless options["mode"] != "runtime"

opts = ""
opts += " '--root'" if options["root"].nil?
opts += " '--entry-point'" if options["entry-point"].nil?
raise Thor::Error, "No value provided for required options #{opts}" unless opts.empty?
end
end
no_commands do
include Tebako::CliHelpers
end
Expand Down
9 changes: 5 additions & 4 deletions lib/tebako/cli_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ module Tebako
# Cli helpers
module CliHelpers
def do_press(options_manager)
puts options_manager.press_announce
scenario_manager = Tebako::ScenarioManager.new(options_manager.root, options_manager.fs_entrance)
puts options_manager.press_announce(scenario_manager.msys?)

if options_manager.mode == "both" || options_manager.mode == "runtime" || options_manager.mode == "bundle"
do_press_runtime(options_manager, scenario_manager)
end

if options_manager.mode == "both" || options_manager.mode == "application"
do_press_application(options_manager, scenario_manager)
end

if options_manager.mode == "both" || options_manager.mode == "runtime" || options_manager.mode == "bundle"
do_press_runtime(options_manager, scenario_manager)
end
true
end

Expand Down
Loading

0 comments on commit ceed09f

Please sign in to comment.