diff --git a/lib/travis/build/addons.rb b/lib/travis/build/addons.rb index 80f4c2069b..26db9b7ab6 100644 --- a/lib/travis/build/addons.rb +++ b/lib/travis/build/addons.rb @@ -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' diff --git a/lib/travis/build/addons/blender.rb b/lib/travis/build/addons/blender.rb new file mode 100644 index 0000000000..b4e9cb5a5b --- /dev/null +++ b/lib/travis/build/addons/blender.rb @@ -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 \ No newline at end of file diff --git a/lib/travis/build/addons/tensor_flow.rb b/lib/travis/build/addons/tensor_flow.rb new file mode 100644 index 0000000000..800b3943de --- /dev/null +++ b/lib/travis/build/addons/tensor_flow.rb @@ -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 diff --git a/lib/travis/build/script.rb b/lib/travis/build/script.rb index 07c6f78614..6dfc429f87 100644 --- a/lib/travis/build/script.rb +++ b/lib/travis/build/script.rb @@ -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 diff --git a/spec/build/addons/blender_spec.rb b/spec/build/addons/blender_spec.rb new file mode 100644 index 0000000000..281dc61459 --- /dev/null +++ b/spec/build/addons/blender_spec.rb @@ -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 diff --git a/spec/build/addons/tensor_flow_spec.rb b/spec/build/addons/tensor_flow_spec.rb new file mode 100644 index 0000000000..7441464236 --- /dev/null +++ b/spec/build/addons/tensor_flow_spec.rb @@ -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