Skip to content

Commit

Permalink
[PRD] GPU Support (#2069)
Browse files Browse the repository at this point in the history
  • Loading branch information
makemp authored and vitalie committed Aug 2, 2023
1 parent 48c0c26 commit b550246
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/travis/build/addons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
require 'travis/build/addons/hostname'
require 'travis/build/addons/hosts'
require 'travis/build/addons/mariadb'
require 'travis/build/addons/tensor_flow'
require 'travis/build/addons/blender'
require 'travis/build/addons/rethinkdb'
require 'travis/build/addons/postgresql'
require 'travis/build/addons/sauce_connect'
Expand Down
43 changes: 43 additions & 0 deletions lib/travis/build/addons/blender.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'shellwords'
require 'travis/build/addons/base'

module Travis
module Build
class Addons
class Blender < Base
ALLOWED_VERSIONS = %w[3.4.1].freeze

def after_prepare
sh.fold 'blender' do
if data.config[:os] != 'linux'
sh.echo 'Blender is only available for linux', ansi: :red
return
end

if version.nil?
sh.echo "Blender: Invalid version '#{raw_version}' given. Valid versions are: #{ALLOWED_VERSIONS.join(', ')}",
ansi: :red
return
end
sh.echo "Installing Blender version: #{version}", ansi: :yellow
sh.cmd 'CURL_USER_AGENT="Travis-CI $(curl --version | head -n 1)"', echo: true
sh.cmd 'mkdir ${TRAVIS_HOME}/blender', echo: true
sh.cmd "curl -A \"$CURL_USER_AGENT\" -sSf -L --retry 7 https://ftp.halifax.rwth-aachen.de/blender/release/Blender#{version[/\d+\.\d+/]}/blender-#{version}-linux-x64.tar.xz" \
' | tar xf - -J -C ${TRAVIS_HOME}/blender --strip-components 1', echo: true
sh.cmd 'PATH=$PATH:${TRAVIS_HOME}/blender', echo: true
end
end

private

def raw_version
config.to_s.strip.shellescape
end

def version
ALLOWED_VERSIONS.include?(raw_version) ? raw_version : nil
end
end
end
end
end
37 changes: 37 additions & 0 deletions lib/travis/build/addons/tensor_flow.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require 'shellwords'
require 'travis/build/addons/base'

module Travis
module Build
class Addons
class TensorFlow < Base
ALLOWED_VERSIONS = %w[0.12.1 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1
1.6.0 1.7.0 1.7.1 1.8.0 1.9.0 1.10.0 1.10.1 1.11.0 1.12.0 1.12.2 1.12.3
1.13.1 1.13.2 1.14.0 1.15.0 1.15.2 1.15.31.15.4 1.15.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.1.3
2.1.4 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.5.2
2.6.0rc0 2.6.0rc1 2.6.0rc2 2.6.0 2.6.1 2.6.2].freeze

def after_prepare
sh.fold 'tensor_flow' do
if version.nil?
sh.echo "Invalid version '#{raw_version}' given. Valid versions are: #{ALLOWED_VERSIONS.join(' ')}", ansi: :red
return
end
sh.echo "Installing TensorFlow version: #{version}", ansi: :yellow
sh.cmd "pip install tensorflow==#{version}", sudo: false
end
end

private

def raw_version
config.to_s.strip.shellescape
end

def version
ALLOWED_VERSIONS.include?(raw_version) ? raw_version : nil
end
end
end
end
end
3 changes: 2 additions & 1 deletion lib/travis/build/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ def configure
apply :update_glibc
apply :update_libssl
apply :clean_up_path
apply :fix_resolv_conf
# Issues with cache dns in Focal
# apply :fix_resolv_conf
apply :fix_etc_hosts
apply :fix_mvn_settings_xml
apply :no_ipv6_localhost
Expand Down
29 changes: 29 additions & 0 deletions spec/build/addons/blender_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'spec_helper'

describe Travis::Build::Addons::Blender, :sexp do
let(:script) { stub('script') }
let(:config) { '10.0' }
let(:data) { payload_for(:push, :ruby, config: { addons: { blender: config } }) }
let(:sh) { Travis::Shell::Builder.new }
let(:addon) { described_class.new(script, sh, Travis::Build::Data.new(data), config) }
subject { sh.to_sexp }
before { addon.after_prepare }

context 'when version is invalid' do
let(:config) { '2.112323' }

it do
should include_sexp [:echo, "Blender: Invalid version '2.112323' given. Valid versions are: 3.4.1", { ansi: :red }]
end
end

context 'when version is valid' do
let(:config) { '3.4.1' }

it { should include_sexp [:echo, 'Installing Blender version: 3.4.1', { ansi: :yellow }] }
it { should include_sexp [:cmd, 'CURL_USER_AGENT="Travis-CI $(curl --version | head -n 1)"', { echo: true }] }
xit { should include_sexp [:cmd, 'mkdir ${TRAVIS_HOME}/blender'], { echo: true } }
it { should include_sexp [:cmd, 'curl -A "$CURL_USER_AGENT" -sSf -L --retry 7 https://ftp.halifax.rwth-aachen.de/blender/release/Blender3.4/blender-3.4.1-linux-x64.tar.xz | tar xf - -J -C ${TRAVIS_HOME}/blender --strip-components 1', { echo: true }] }
it { should include_sexp [:cmd, 'PATH=$PATH:${TRAVIS_HOME}/blender', { echo: true }] }
end
end
25 changes: 25 additions & 0 deletions spec/build/addons/tensor_flow_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'spec_helper'

describe Travis::Build::Addons::TensorFlow, :sexp do
let(:script) { stub('script') }
let(:config) { '10.0' }
let(:data) { payload_for(:push, :ruby, config: { addons: { tensor_flow: config } }) }
let(:sh) { Travis::Shell::Builder.new }
let(:addon) { described_class.new(script, sh, Travis::Build::Data.new(data), config) }
subject { sh.to_sexp }
before { addon.after_prepare }

context 'when version is invalid' do
let(:config) { '2.112323' }

it do
should include_sexp [:echo, "Invalid version '2.112323' given. Valid versions are: 0.12.1 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.7.0 1.7.1 1.8.0 1.9.0 1.10.0 1.10.1 1.11.0 1.12.0 1.12.2 1.12.3 1.13.1 1.13.2 1.14.0 1.15.0 1.15.2 1.15.31.15.4 1.15.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.5.2 2.6.0rc0 2.6.0rc1 2.6.0rc2 2.6.0 2.6.1 2.6.2", { ansi: :red }] end
end

context 'when version is valid' do
let(:config) { '2.6.0' }

it { should include_sexp [:echo, 'Installing TensorFlow version: 2.6.0', { ansi: :yellow }] }
it { should include_sexp [:cmd, "pip install tensorflow==2.6.0"] }
end
end

0 comments on commit b550246

Please sign in to comment.