Skip to content

Commit

Permalink
Change elixir installation process
Browse files Browse the repository at this point in the history
Resolves travis-ci/travis-ci#3269

If the desired Elixir version is not installed already,
pull down package from s3.hex.pm, and set up Elixir runtime
as kiex expects.

'kiex list' does not make network calls to GitHub, so that
we should not reach GitHub's API rate limit.
  • Loading branch information
BanzaiMan committed Jun 3, 2015
1 parent 4926ac7 commit 8303de7
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/travis/build/script/elixir.rb
Expand Up @@ -6,6 +6,8 @@ class Elixir < Erlang
elixir: '1.0.2',
otp_release: '17.4'
}
KIEX_ELIXIR_HOME = '$HOME/.kiex/elixirs/'
KIEX_MIX_HOME = '$HOME/.kiex/mix/'

def export
super
Expand All @@ -14,15 +16,19 @@ def export

def announce
super
sh.fold "kiex" do
sh.cmd "kiex list | grep -F #{elixir_version} >/dev/null", echo: false
sh.if "$? -eq 0" do
sh.echo "Using Elixir #{elixir_version}", ansi: :yellow
end
sh.else do
sh.echo "Installing Elixir #{elixir_version}", ansi: :yellow
sh.cmd "travis_retry kiex install #{elixir_version} && kiex use #{elixir_version}", assert: true, timing: true

sh.fold "elixir" do
sh.cmd "kiex list | grep #{Regexp.escape(elixir_version).shellescape}", echo: false, assert: false
sh.if "$? != 0" do
sh.echo "Installing Elixir #{elixir_version}"
sh.cmd "wget http://s3.hex.pm/builds/elixir/v#{elixir_version}.zip", assert: true, timing: true
sh.cmd "unzip -d #{KIEX_ELIXIR_HOME}/elixir-#{elixir_version} v#{elixir_version}.zip 2>&1 > /dev/null", echo: false
sh.cmd "echo 'export ELIXIR_VERSION=#{elixir_version}
export PATH=#{KIEX_ELIXIR_HOME}elixir-#{elixir_version}/bin:$PATH
export MIX_ARCHIVES=#{KIEX_MIX_HOME}elixir-#{elixir_version}' > #{KIEX_ELIXIR_HOME}elixir-#{elixir_version}.env"
end

sh.cmd "kiex use #{elixir_version}"
end
sh.cmd "elixir --version"
end
Expand Down

0 comments on commit 8303de7

Please sign in to comment.