Skip to content

Commit

Permalink
Merge pull request travis-ci#1674 from travis-ci/ha-gcs-lang-archives
Browse files Browse the repository at this point in the history
Fetch language archives from GCS
  • Loading branch information
BanzaiMan authored Mar 15, 2019
2 parents 4c71d0b + 923b3e6 commit cdab8ec
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ before_script:
- bundle exec rake clean assets:precompile

script:
- bundle exec rake parallel:spec[1]
- bundle exec rspec spec
- bundle exec rake shfmt
- bundle exec rake assert_clean
- bundle exec rake shellcheck
- bundle exec rake assert_examples[parallel]
- bundle exec rake assert_examples

after_success: bundle exec codeclimate-test-reporter

Expand Down
1 change: 1 addition & 0 deletions lib/travis/build/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def sc_data
'TRAVIS_BUILD_INTERNAL_RUBY_REGEX',
'^ruby-(2\.[0-4]\.[0-9]|1\.9\.3)'
),
lang_archive_host: ENV.fetch('TRAVIS_LANGUAGE_ARCHIVE_HOST', 's3'),
librato: {
email: ENV.fetch(
'TRAVIS_BUILD_LIBRATO_EMAIL', ENV.fetch('LIBRATO_EMAIL', '')
Expand Down
15 changes: 14 additions & 1 deletion lib/travis/build/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,26 @@ def archive_url_for(bucket, version, lang = lang_name, ext = 'bz2')
sh.raw "travis_rel=$(sw_vers -productVersion)"
sh.raw "travis_rel_version=${travis_rel%*.*}"
end
lang = 'python' if lang.start_with?('py')
"archive_url=https://#{lang_archive_prefix(lang, bucket)}/binaries/${travis_host_os}/${travis_rel_version}/$(uname -m)/#{file_name}"
end

def lang_archive_prefix(lang, bucket)
custom_archive = ENV["TRAVIS_BUILD_LANG_ARCHIVES_#{lang}".upcase]
unless custom_archive.to_s.empty?
return custom_archive.output_safe
end

custom_archive.to_s.empty? ? "s3.amazonaws.com/#{bucket}" : custom_archive.output_safe
case Travis::Build.config.lang_archive_host
when 'gcs'
"storage.googleapis.com/travis-ci-language-archives/#{lang}"
when 's3'
"s3.amazonaws.com/#{bucket}"
when 'cdn'
"language-archives.travis-ci.com/#{lang}"
else
"s3.amazonaws.com/#{bucket}" # explicitly state default
end
end

def debug_build_via_api?
Expand Down
7 changes: 4 additions & 3 deletions lib/travis/build/script/shared/rvm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ module RVM
)

RVM_VERSION_ALIASES = {
'2.3' => '2.3.7',
'2.4' => '2.4.4',
'2.5' => '2.5.1'
'2.3' => '2.3.8',
'2.4' => '2.4.5',
'2.5' => '2.5.4',
'2.6' => '2.6.2',
}

RVM_GPG_KEY_IDS = %w(
Expand Down
1 change: 0 additions & 1 deletion spec/build/script/elixir_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,3 @@ def self.installs_required_otp_release(elixir_version, otp_release_wanted, otp_r
installs_required_otp_release('1.0.5', '18.0', '17.4')
installs_required_otp_release('1.0.5', 'R16B03-1', '17.4')
end

1 change: 0 additions & 1 deletion spec/build/script/erlang_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@
it { is_expected.to eq("cache-#{CACHE_SLUG_EXTRAS}--otp-R14B04") }
end
end

20 changes: 20 additions & 0 deletions spec/build/script/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@
expect(branch).to include_sexp [:raw, "archive_url=https://cdn.of.lots.of.python.stuff/binaries/${travis_host_os}/${travis_rel_version}/$(uname -m)/python-#{version}.tar.bz2"]
end
end

context 'and using gcs as language archive host' do
before :each do
@old_lang_archive_host = Travis::Build.config.lang_archive_host
Travis::Build.config.lang_archive_host = 'gcs'
end

after { Travis::Build.config.lang_archive_host = @old_lang_archive_host }

it "downloads archive" do
ENV['']
branch = sexp_find(sexp, [:then])
expect(branch).to include_sexp [:raw, "archive_url=https://storage.googleapis.com/travis-ci-language-archives/python/binaries/${travis_host_os}/${travis_rel_version}/$(uname -m)/python-#{version}.tar.bz2"]
end

it 'sets up pypy' do
data[:config][:python] = 'pypy-5.3.1'
should include_sexp [:raw, "archive_url=https://storage.googleapis.com/travis-ci-language-archives/python/binaries/${travis_host_os}/${travis_rel_version}/$(uname -m)/pypy-5.3.1.tar.bz2"]
end
end
end

it 'announces python --version' do
Expand Down
2 changes: 1 addition & 1 deletion spec/build/script/ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
it 'ensures rvm alias is defined' do
sexp = sexp_find(subject, [:if, "-z $(rvm alias list | grep ^2\\\\.3)"], [:then])
store_example(name: 'rvm-alias')
expect(sexp).to include_sexp [:cmd, "rvm alias create 2.3 ruby-2.3.7", assert: true, echo: true, timing: true]
expect(sexp).to include_sexp [:cmd, "rvm alias create 2.3 ruby-2.3.8", assert: true, echo: true, timing: true]
end
end

Expand Down

0 comments on commit cdab8ec

Please sign in to comment.