diff --git a/.github/workflows/gem_deploy_ouroborus.yml b/.github/workflows/gem_deploy_ouroborus.yml new file mode 100644 index 0000000..9e48044 --- /dev/null +++ b/.github/workflows/gem_deploy_ouroborus.yml @@ -0,0 +1,32 @@ +name: Publish Ouroborus Gem + +on: + push: + tags: + - 'ouroborus*' + +jobs: + publish-gem: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + + - name: Publish Ouroborus Gem to GitHub Registry + run: | + mkdir -p ~/.gem + echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" > ~/.gem/credentials + chmod 0600 ~/.gem/credentials + cd ouroborus + gem build ouroborus.gemspec + gem push --key github --host https://rubygems.pkg.github.com/${{ github.actor }} ouroborus-*.gem \ No newline at end of file diff --git a/ouroborus/lib/ouroborus/container.rb b/ouroborus/lib/ouroborus/container.rb index ca9c6fc..96fcc62 100644 --- a/ouroborus/lib/ouroborus/container.rb +++ b/ouroborus/lib/ouroborus/container.rb @@ -28,6 +28,7 @@ def initialize(name:, image:, tag: 'latest') @dockerArgs = Args.new @args = Args.new @daemon = true + @add_host = '' end def daemon? @@ -42,6 +43,19 @@ def daemon=(value) end end + + def add_host? + !@add_host.empty? + end + + def add_host=(value) + @add_host = value.to_s + end + + def teste + puts "teste >> exec branch jp" + end + def imgTag "#{@image}:#{@tag}" end @@ -58,6 +72,9 @@ def as_args else replaceable << "-i" end + if add_host? + replaceable << "--add-host=#{@add_host}" + end replaceable << @dockerArgs << "--name" << @name << imgTag << @args end @@ -142,7 +159,7 @@ def normalizeEnvValue(name, value = nil) def runCommand(cmd, &block) if block_given? then - yield cmd + yield cmd, :out else cmd end diff --git a/ouroborus/lib/ouroborus/executor.rb b/ouroborus/lib/ouroborus/executor.rb index b9120dc..d7bf988 100644 --- a/ouroborus/lib/ouroborus/executor.rb +++ b/ouroborus/lib/ouroborus/executor.rb @@ -2,50 +2,64 @@ module Ouroborus class Executor - def exec(cmd) + def exec(cmd, wrDepot = :out) puts cmd true end def willExec - return Proc.new { |cmd| - exec cmd + return Proc.new { |cmd, wrDepot| + exec cmd, wrDepot } end def wait false end + + def execWait(cmd, wrDepot = :out) + exec cmd, wrDepot + wait + end end class ShellExecutor < Executor def initialize(input = nil) @input = input + @wrDepotMap = {} end def <<(str) @wr.write str end - def exec(cmd) + def exec(cmd, wrDepot = :out) + @retValue = nil + #wrDepot = wrDepot + p wrDepot if @input.is_a? IO - @pid = spawn("#{cmd}", :in => @input) + @pid = spawn("#{cmd}", :in => @input, :out => wrDepot) else rd, wr = IO.pipe - @pid = spawn("#{cmd}", :in => rd) + @pid = spawn("#{cmd}", :in => rd, :out => wrDepot) if @input.nil? @wr = wr else wr.write(@input) end end + @wrDepotMap[@pid] = wrDepot unless wrDepot == :out + return @pid end def wait - unless @retValue.nil? + if @retValue.nil? Process.wait @pid - @retValue = $?.exitStatus + outWrDepot = @wrDepotMap.delete @pid + outWrDepot.close unless outWrDepot.nil? + @pid = nil + @retValue = $?.exitstatus end @retValue == 0 end diff --git a/ouroborus/lib/ouroborus/version.rb b/ouroborus/lib/ouroborus/version.rb index 08f964c..679a752 100644 --- a/ouroborus/lib/ouroborus/version.rb +++ b/ouroborus/lib/ouroborus/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Ouroborus - VERSION = "0.0.1" + VERSION = "0.0.3" end