Skip to content

Commit b550246

Browse files
makempvitalie
authored and
vitalie
committed
[PRD] GPU Support (#2069)
1 parent 48c0c26 commit b550246

File tree

6 files changed

+138
-1
lines changed

6 files changed

+138
-1
lines changed

lib/travis/build/addons.rb

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
require 'travis/build/addons/hostname'
1414
require 'travis/build/addons/hosts'
1515
require 'travis/build/addons/mariadb'
16+
require 'travis/build/addons/tensor_flow'
17+
require 'travis/build/addons/blender'
1618
require 'travis/build/addons/rethinkdb'
1719
require 'travis/build/addons/postgresql'
1820
require 'travis/build/addons/sauce_connect'

lib/travis/build/addons/blender.rb

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
require 'shellwords'
2+
require 'travis/build/addons/base'
3+
4+
module Travis
5+
module Build
6+
class Addons
7+
class Blender < Base
8+
ALLOWED_VERSIONS = %w[3.4.1].freeze
9+
10+
def after_prepare
11+
sh.fold 'blender' do
12+
if data.config[:os] != 'linux'
13+
sh.echo 'Blender is only available for linux', ansi: :red
14+
return
15+
end
16+
17+
if version.nil?
18+
sh.echo "Blender: Invalid version '#{raw_version}' given. Valid versions are: #{ALLOWED_VERSIONS.join(', ')}",
19+
ansi: :red
20+
return
21+
end
22+
sh.echo "Installing Blender version: #{version}", ansi: :yellow
23+
sh.cmd 'CURL_USER_AGENT="Travis-CI $(curl --version | head -n 1)"', echo: true
24+
sh.cmd 'mkdir ${TRAVIS_HOME}/blender', echo: true
25+
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" \
26+
' | tar xf - -J -C ${TRAVIS_HOME}/blender --strip-components 1', echo: true
27+
sh.cmd 'PATH=$PATH:${TRAVIS_HOME}/blender', echo: true
28+
end
29+
end
30+
31+
private
32+
33+
def raw_version
34+
config.to_s.strip.shellescape
35+
end
36+
37+
def version
38+
ALLOWED_VERSIONS.include?(raw_version) ? raw_version : nil
39+
end
40+
end
41+
end
42+
end
43+
end
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require 'shellwords'
2+
require 'travis/build/addons/base'
3+
4+
module Travis
5+
module Build
6+
class Addons
7+
class TensorFlow < Base
8+
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
9+
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
10+
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
11+
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
12+
2.6.0rc0 2.6.0rc1 2.6.0rc2 2.6.0 2.6.1 2.6.2].freeze
13+
14+
def after_prepare
15+
sh.fold 'tensor_flow' do
16+
if version.nil?
17+
sh.echo "Invalid version '#{raw_version}' given. Valid versions are: #{ALLOWED_VERSIONS.join(' ')}", ansi: :red
18+
return
19+
end
20+
sh.echo "Installing TensorFlow version: #{version}", ansi: :yellow
21+
sh.cmd "pip install tensorflow==#{version}", sudo: false
22+
end
23+
end
24+
25+
private
26+
27+
def raw_version
28+
config.to_s.strip.shellescape
29+
end
30+
31+
def version
32+
ALLOWED_VERSIONS.include?(raw_version) ? raw_version : nil
33+
end
34+
end
35+
end
36+
end
37+
end

lib/travis/build/script.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ def configure
315315
apply :update_glibc
316316
apply :update_libssl
317317
apply :clean_up_path
318-
apply :fix_resolv_conf
318+
# Issues with cache dns in Focal
319+
# apply :fix_resolv_conf
319320
apply :fix_etc_hosts
320321
apply :fix_mvn_settings_xml
321322
apply :no_ipv6_localhost

spec/build/addons/blender_spec.rb

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'spec_helper'
2+
3+
describe Travis::Build::Addons::Blender, :sexp do
4+
let(:script) { stub('script') }
5+
let(:config) { '10.0' }
6+
let(:data) { payload_for(:push, :ruby, config: { addons: { blender: config } }) }
7+
let(:sh) { Travis::Shell::Builder.new }
8+
let(:addon) { described_class.new(script, sh, Travis::Build::Data.new(data), config) }
9+
subject { sh.to_sexp }
10+
before { addon.after_prepare }
11+
12+
context 'when version is invalid' do
13+
let(:config) { '2.112323' }
14+
15+
it do
16+
should include_sexp [:echo, "Blender: Invalid version '2.112323' given. Valid versions are: 3.4.1", { ansi: :red }]
17+
end
18+
end
19+
20+
context 'when version is valid' do
21+
let(:config) { '3.4.1' }
22+
23+
it { should include_sexp [:echo, 'Installing Blender version: 3.4.1', { ansi: :yellow }] }
24+
it { should include_sexp [:cmd, 'CURL_USER_AGENT="Travis-CI $(curl --version | head -n 1)"', { echo: true }] }
25+
xit { should include_sexp [:cmd, 'mkdir ${TRAVIS_HOME}/blender'], { echo: true } }
26+
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 }] }
27+
it { should include_sexp [:cmd, 'PATH=$PATH:${TRAVIS_HOME}/blender', { echo: true }] }
28+
end
29+
end

spec/build/addons/tensor_flow_spec.rb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'spec_helper'
2+
3+
describe Travis::Build::Addons::TensorFlow, :sexp do
4+
let(:script) { stub('script') }
5+
let(:config) { '10.0' }
6+
let(:data) { payload_for(:push, :ruby, config: { addons: { tensor_flow: config } }) }
7+
let(:sh) { Travis::Shell::Builder.new }
8+
let(:addon) { described_class.new(script, sh, Travis::Build::Data.new(data), config) }
9+
subject { sh.to_sexp }
10+
before { addon.after_prepare }
11+
12+
context 'when version is invalid' do
13+
let(:config) { '2.112323' }
14+
15+
it do
16+
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
17+
end
18+
19+
context 'when version is valid' do
20+
let(:config) { '2.6.0' }
21+
22+
it { should include_sexp [:echo, 'Installing TensorFlow version: 2.6.0', { ansi: :yellow }] }
23+
it { should include_sexp [:cmd, "pip install tensorflow==2.6.0"] }
24+
end
25+
end

0 commit comments

Comments
 (0)