Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby support #148

Merged
merged 12 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
acceptance_tests:
working_directory: /go/src/github.com/gaia-pipeline/gaia
docker:
- image: gaiapipeline/circleci:0.0.2
- image: gaiapipeline/circleci:0.0.3
environment:
GO111MODULE: "on"
steps:
Expand Down
78 changes: 77 additions & 1 deletion .circleci/images/primary/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,83 @@ RUN git clone -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc /var/local/git
echo "--- installing grpc ---" && \
cd /var/local/git/grpc && \
make -j$(nproc) && make install && make clean && ldconfig
# --------------- Start C++ Part ---------------
# --------------- End C++ Part ---------------

# --------------- Start Ruby Part --------------
# skip installing gem documentation
RUN mkdir -p /usr/local/etc \
&& { \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc

ENV RUBY_MAJOR 2.5
ENV RUBY_VERSION 2.5.3
ENV RUBY_DOWNLOAD_SHA256 1cc9d0359a8ea35fc6111ec830d12e60168f3b9b305a3c2578357d360fcf306f
ENV RUBYGEMS_VERSION 3.0.1

# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
RUN set -ex \
\
&& buildDeps=' \
bison \
dpkg-dev \
libgdbm-dev \
ruby \
' \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& rm -rf /var/lib/apt/lists/* \
\
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
\
&& mkdir -p /usr/src/ruby \
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
&& rm ruby.tar.xz \
\
&& cd /usr/src/ruby \
\
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
# warning: Insecure world writable dir
&& { \
echo '#define ENABLE_PATH_CHECK 0'; \
echo; \
cat file.c; \
} > file.c.new \
&& mv file.c.new file.c \
\
&& autoconf \
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
&& ./configure \
--build="$gnuArch" \
--disable-install-doc \
--enable-shared \
&& make -j "$(nproc)" \
&& make install \
\
&& apt-get purge -y --auto-remove $buildDeps \
&& cd / \
&& rm -r /usr/src/ruby \
# make sure bundled "rubygems" is older than RUBYGEMS_VERSION (https://github.com/docker-library/ruby/issues/246)
&& ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))' \
&& gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/ \
# rough smoke test
&& ruby --version && gem --version && bundle --version

# install things globally, for great justice
# and don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
# path recommendation: https://github.com/bundler/bundler/pull/6469#issuecomment-383235438
ENV PATH $GEM_HOME/bin:$BUNDLE_PATH/gems/bin:$PATH
# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)
# --------------- End Ruby Part ---------------

# install additional deps
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand Down
32 changes: 31 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,36 @@ C++
}
}

Ruby
~~~~

.. code:: ruby

require 'rubysdk'

class Main
AwesomeJob = lambda do |args|
STDERR.puts "This output will be streamed back to gaia and will be displayed in the pipeline logs."

# An error occurred? Raise an exception and gaia will fail the pipeline.
# raise "Oh gosh! Something went wrong!"
end

def self.main
awesomejob = Interface::Job.new(title: "Awesome Job",
handler: AwesomeJob,
desc: "This job does something awesome.")

begin
RubySDK.Serve([awesomejob])
rescue => e
puts "Error occured: #{e}"
exit(false)
end
end
end


Pipelines are defined by jobs and a function usually represents a job. You can define as many jobs in your pipeline as you want.

Every function accepts arguments. Those arguments can be requested from the pipeline itself and the values passed back in from the UI.
Expand Down Expand Up @@ -270,7 +300,7 @@ The SDK implements the Gaia plugin gRPC interface and offers helper functions li

Which programming languages are supported?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We currently fully support Golang, Java, Python and C++.
We currently fully support Golang, Java, Python, C++ and Ruby.

When do you support programming language **XYZ**?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
78 changes: 77 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,83 @@ RUN git clone -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc /var/local/git
echo "--- installing grpc ---" && \
cd /var/local/git/grpc && \
make -j$(nproc) && make install && make clean && ldconfig
# --------------- Start C++ Part ---------------
# --------------- End C++ Part ---------------

# --------------- Start Ruby Part ---------------
# skip installing gem documentation
RUN mkdir -p /usr/local/etc \
&& { \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc

ENV RUBY_MAJOR 2.5
ENV RUBY_VERSION 2.5.3
ENV RUBY_DOWNLOAD_SHA256 1cc9d0359a8ea35fc6111ec830d12e60168f3b9b305a3c2578357d360fcf306f
ENV RUBYGEMS_VERSION 3.0.1

# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
RUN set -ex \
\
&& buildDeps=' \
bison \
dpkg-dev \
libgdbm-dev \
ruby \
' \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& rm -rf /var/lib/apt/lists/* \
\
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
\
&& mkdir -p /usr/src/ruby \
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
&& rm ruby.tar.xz \
\
&& cd /usr/src/ruby \
\
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
# warning: Insecure world writable dir
&& { \
echo '#define ENABLE_PATH_CHECK 0'; \
echo; \
cat file.c; \
} > file.c.new \
&& mv file.c.new file.c \
\
&& autoconf \
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
&& ./configure \
--build="$gnuArch" \
--disable-install-doc \
--enable-shared \
&& make -j "$(nproc)" \
&& make install \
\
&& apt-get purge -y --auto-remove $buildDeps \
&& cd / \
&& rm -r /usr/src/ruby \
# make sure bundled "rubygems" is older than RUBYGEMS_VERSION (https://github.com/docker-library/ruby/issues/246)
&& ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))' \
&& gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/ \
# rough smoke test
&& ruby --version && gem --version && bundle --version

# install things globally, for great justice
# and don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
# path recommendation: https://github.com/bundler/bundler/pull/6469#issuecomment-383235438
ENV PATH $GEM_HOME/bin:$BUNDLE_PATH/gems/bin:$PATH
# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)
# --------------- End Ruby Part ---------------

# install additional deps
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand Down
27 changes: 27 additions & 0 deletions docker/Dockerfile.ruby
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ruby:2.5.3-stretch

# Version and other variables which can be changed.
ENV GAIA_PORT=8080 \
GAIA_WORKER=2 \
GAIA_HOMEPATH=/data

# Directory for the binary
WORKDIR /app

# Copy gaia binary into docker image
COPY gaia-linux-amd64 /app

# Fix permissions
RUN chmod +x ./gaia-linux-amd64

# Set homepath as volume
VOLUME [ "${GAIA_HOMEPATH}" ]

# Expose port
EXPOSE ${GAIA_PORT}

# Copy entry point script
COPY docker-entrypoint.sh /usr/local/bin/

# Start gaia
ENTRYPOINT [ "docker-entrypoint.sh" ]
Binary file added frontend/client/assets/ruby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion frontend/client/views/overview/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export default {
return {
'outer-box-image-python': type === 'python',
'outer-box-image-cpp': type === 'cpp',
'outer-box-image': type !== 'python' && type !== 'cpp'
'outer-box-image-ruby': type === 'ruby',
'outer-box-image': type !== 'python' && type !== 'cpp' && type !== 'ruby'
}
},

Expand Down Expand Up @@ -276,6 +277,14 @@ export default {
transform: translate(-50%, -50%);
}

.outer-box-image-ruby {
position: absolute;
width: 50px;
height: 35px;
top: 43%;
left: 50%;
transform: translate(-50%, -50%);
}
.hoveraction:hover .outer-box-icon-image {
border-color: #4da2fc !important;
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/client/views/pipeline/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
<div class="pipelinetype" title="C++" v-tippy="{ arrow : true, animation : 'shift-away'}" v-on:click="createPipeline.pipeline.type = 'cpp'" v-bind:class="{ pipelinetypeactive: createPipeline.pipeline.type === 'cpp' }" data-tippy-hideOnClick="false">
<img src="~assets/cpp.png" class="typeimage">
</div>
<div class="pipelinetype" title="Ruby" v-tippy="{ arrow : true, animation : 'shift-away'}" v-on:click="createPipeline.pipeline.type = 'ruby'" v-bind:class="{ pipelinetypeactive: createPipeline.pipeline.type === 'ruby' }" data-tippy-hideOnClick="false">
<img src="~assets/ruby.png" class="typeimage">
</div>
<div class="pipelinetype" title="Node.js (not yet supported)" v-tippy="{ arrow : true, animation : 'shift-away'}" v-bind:class="{ pipelinetypeactive: createPipeline.pipeline.type === 'nodejs' }" data-tippy-hideOnClick="false">
<img src="~assets/nodejs.png" class="typeimage typeimagenotyetsupported">
</div>
Expand Down
6 changes: 6 additions & 0 deletions gaia.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const (
// PTypeCpp C++ plugin type
PTypeCpp PipelineType = "cpp"

// PTypeRuby ruby plugin type
PTypeRuby PipelineType = "ruby"

// CreatePipelineFailed status
CreatePipelineFailed CreatePipelineType = "failed"

Expand Down Expand Up @@ -97,6 +100,9 @@ const (

// TmpCppFolder is the name of the c++ temporary folder
TmpCppFolder = "cpp"

// TmpRubyFolder is the name of the ruby temporary folder
TmpRubyFolder = "ruby"
)

// User is the user object
Expand Down
40 changes: 37 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,46 +1,80 @@
module github.com/gaia-pipeline/gaia

require (
github.com/GeertJohan/go.rice v0.0.0-20170420135705-c02ca9a983da
github.com/GeertJohan/go.incremental v0.0.0-20161212213043-1172aab96510 // indirect
github.com/GeertJohan/go.rice v0.0.0-20181229193832-0af3f3b09a0a
github.com/akavel/rsrc v0.0.0-20170831122431-f6a15ece2cfd // indirect
github.com/alecthomas/gometalinter v2.0.12+incompatible // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/coreos/bbolt v1.3.0
github.com/cosiner/argv v0.0.1 // indirect
github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb
github.com/davidrjenni/reftools v0.0.0-20180914123528-654d0ba4f96d // indirect
github.com/derekparker/delve v1.1.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/emirpasic/gods v1.9.0
github.com/fatih/gomodifytags v0.0.0-20180914191908-141225bf62b6 // indirect
github.com/fatih/motion v0.0.0-20180408211639-218875ebe238 // indirect
github.com/gaia-pipeline/flag v1.7.4-pre
github.com/gaia-pipeline/protobuf v0.0.0-20180812091451-7be8a901b55a
github.com/golang/protobuf v1.1.0
github.com/google/go-github v15.0.0+incompatible
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135
github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf // indirect
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd
github.com/hashicorp/go-plugin v0.0.0-20180331002553-e8d22c780116
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/josharian/impl v0.0.0-20180228163738-3d0f908298c4 // indirect
github.com/jstemmer/gotags v1.4.1 // indirect
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1
github.com/kevinburke/ssh_config v0.0.0-20180317175531-9fc7bb800b55
github.com/kisielk/errcheck v1.2.0 // indirect
github.com/klauspost/asmfmt v1.2.0 // indirect
github.com/koron/iferr v0.0.0-20180615142939-bb332a3b1d91 // indirect
github.com/labstack/echo v3.3.5+incompatible
github.com/labstack/gommon v0.0.0-20180613044413-d6898124de91
github.com/mattn/go-colorable v0.0.9
github.com/mattn/go-isatty v0.0.3
github.com/mdempsky/gocode v0.0.0-20181226182234-be056ad32a5e // indirect
github.com/mitchellh/go-homedir v0.0.0-20180801233206-58046073cbff
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77
github.com/nicksnyder/go-i18n v1.10.0 // indirect
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229 // indirect
github.com/oklog/run v1.0.0
github.com/pelletier/go-buffruneio v0.2.0
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/peterh/liner v1.1.0 // indirect
github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967
github.com/rogpeppe/godef v1.1.1 // indirect
github.com/satori/go.uuid v1.2.0
github.com/sergi/go-diff v1.0.0
github.com/sirupsen/logrus v1.3.0 // indirect
github.com/spf13/cobra v0.0.3 // indirect
github.com/spf13/pflag v1.0.3 // indirect
github.com/src-d/gcfg v1.3.0
github.com/stamblerre/gocode v0.0.0-20181212030458-2f9d39d8f31d // indirect
github.com/stretchr/testify v1.3.0 // indirect
github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4
github.com/xanzy/ssh-agent v0.2.0
golang.org/x/crypto v0.0.0-20180808211826-de0752318171
github.com/zmb3/gogetdoc v0.0.0-20190107174152-de0ca1d07687 // indirect
golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045 // indirect
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect
golang.org/x/net v0.0.0-20180811021610-c39426892332
golang.org/x/oauth2 v0.0.0-20180724155351-3d292e4d0cdc
golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
golang.org/x/text v0.0.0-20180810153555-6e3c4e7365dd
golang.org/x/tools v0.0.0-20190116231616-b258f6da2383 // indirect
google.golang.org/appengine v1.1.0
google.golang.org/genproto v0.0.0-20180808183934-383e8b2c3b9e
google.golang.org/grpc v1.14.0
gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20180810215634-df19058c872c // indirect
gopkg.in/src-d/go-billy.v4 v4.2.0
gopkg.in/src-d/go-git.v4 v4.5.0
gopkg.in/warnings.v0 v0.1.2
gopkg.in/yaml.v2 v2.2.2
honnef.co/go/tools v0.0.0-20190109154334-5bcec433c8ea // indirect
)
Loading