Skip to content

Commit

Permalink
Add tests for ruby.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Feb 21, 2024
1 parent 0add47d commit 5eb042f
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 10 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ test:
@docker build --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:node -f tests/node/Dockerfile .
@docker build --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:typescript -f tests/typescript/Dockerfile .
# TODO:
# @docker build --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:ruby -f tests/ruby/Dockerfile .
# @docker build --build-arg CACHE_INVALIDATE=${CACHE_INVALIDATE} -t metacall/distributable_linux_test:tsx -f tests/tsx/Dockerfile .
@echo "Done"

Expand Down
43 changes: 34 additions & 9 deletions source/metacall.scm
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ for any host, on any OS. TypeScript compiles to readable, standards-based JavaSc

; Set all environment variables for subsequent packages
(search-paths
(list (search-path-specification
(list
; MetaCall
(search-path-specification
(variable "LOADER_LIBRARY_PATH")
(files '("lib")))
(search-path-specification
Expand All @@ -461,21 +463,42 @@ for any host, on any OS. TypeScript compiles to readable, standards-based JavaSc
(variable "CONFIGURATION_PATH")
(file-type 'regular)
(files '("configurations/global.json")))
; Python
(search-path-specification
(variable "PYTHONTZPATH")
(files (list "share/zoneinfo")))
; PYTHONPATH is incompatible with Guix Python
; but we require it for tarball installation
(search-path-specification
(variable "PYTHONPATH")
(files (list (string-append
"lib/python"
(version-major+minor (package-version python-3))
"/site-packages"))))))

; TODO: Implement the rest of paths for development
; C_INCLUDE_PATH
; CPLUS_INCLUDE_PATH
; LIBRARY_PATH

(native-search-paths search-paths)
"/site-packages"))))
; NodeJS
(search-path-specification
(variable "NODE_PATH")
(files '("lib/node_modules")))
; Ruby
(search-path-specification
(variable "GEM_PATH")
(files (list (string-append "lib/ruby/vendor_ruby"))))
(search-path-specification
(variable "GEM_HOME")
(files (list (string-append "lib/ruby/vendor_ruby"))))
(search-path-specification
(variable "BUNDLE_PATH")
(files (list (string-append "lib/ruby/vendor_ruby"))))
; GCC
(search-path-specification
(variable "C_INCLUDE_PATH")
(files '("include")))
(search-path-specification
(variable "CPLUS_INCLUDE_PATH")
(files '("include/c++" "include")))
(search-path-specification
(variable "LIBRARY_PATH")
(files '("lib" "lib64")))))

; TODO:
;
Expand All @@ -487,6 +510,8 @@ for any host, on any OS. TypeScript compiles to readable, standards-based JavaSc
; (file-type 'regular)
; (files '(glibc-dynamic-linker)))

(native-search-paths search-paths)

(home-page "https://metacall.io/")
(synopsis "Inter-language foreign function interface call library")
(description "METACALL is a library that allows calling functions,
Expand Down
1 change: 0 additions & 1 deletion tests/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ ARG CACHE_INVALIDATE

RUN echo "Running tests ${CACHE_INVALIDATE}" \
&& source /gnu/etc/profile \
&& rm /gnu/store/4r7k7ipiaqkdf4lmnxwmbz0wx2yzygzc-python-3.10.7/lib/python3.10/site-packages/sitecustomize.py \
&& pip3 install metacall \
&& export LOADER_SCRIPT_PATH="/scripts/" \
&& printf 'load py script.py\ninspect\ncall test()\nexit' | metacallcli \
Expand Down
54 changes: 54 additions & 0 deletions tests/ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# MetaCall Distributable by Parra Studios
# Distributable infrastructure for MetaCall.
#
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

FROM busybox:1.31.1 AS ruby_test

# Image descriptor
LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \
copyright.address="[email protected]" \
maintainer.name="Vicente Eduardo Ferrer Garcia" \
maintainer.address="[email protected]" \
vendor="MetaCall Inc." \
version="0.1"

COPY out/tarball.tar.gz /

RUN cd / \
&& tar --no-same-owner --no-same-permissions -xzf tarball.tar.gz \
&& rm tarball.tar.gz

COPY tests/ruby/script.rb /scripts/
COPY tests/ruby/Gemfile /scripts/

WORKDIR /scripts

ARG CACHE_INVALIDATE

RUN echo "Running tests ${CACHE_INVALIDATE}" \
&& source /gnu/etc/profile \
&& gem install open-uri \
&& bundle install --verbose \
&& bundle config path \
&& export LOADER_SCRIPT_PATH="/scripts/" \
&& metacallcli script.rb
# \
# | grep \
# -e 'Hello World'

ENTRYPOINT ["sh", "-c"]
3 changes: 3 additions & 0 deletions tests/ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'xml-simple'
31 changes: 31 additions & 0 deletions tests/ruby/script.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env ruby

#
# MetaCall Distributable by Parra Studios
# Distributable infrastructure for MetaCall.
#
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'open-uri'

URI.open('http://www.ruby-lang.org/') {|f|
f.each_line {|line| p line}
}

# TODO: Ruby cannot find gems installed by bundle
#require 'xmlsimple'
#result = XmlSimple.xml_in(html)
#p result

0 comments on commit 5eb042f

Please sign in to comment.