-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |