Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow HHVM LTS version specification #733

Merged
merged 16 commits into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions lib/travis/build/script/php.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ def export

def setup
super
unless hhvm?
if hhvm?
sh.cmd "phpenv global hhvm", assert: true
else
sh.cmd "phpenv global #{version} 2>/dev/null", assert: false
sh.if "$? -ne 0" do
install_php_on_demand(version)
end
sh.cmd "phpenv global #{version}", assert: true
end
sh.cmd "phpenv global #{version}", assert: true
sh.cmd "phpenv rehash", assert: false, echo: false, timing: false
composer_self_update
end
Expand Down Expand Up @@ -65,7 +67,14 @@ def version
end

def hhvm?
version.include?('hhvm')
version.start_with?('hhvm')
end

def hhvm_version
return unless hhvm?
if match_data = /-(\d+(?:\.\d+)*)$/.match(version)
match_data[1]
end
end

def nightly?
Expand All @@ -89,12 +98,19 @@ def update_hhvm
sh.if '"$(lsb_release -sc 2>/dev/null)"' do
sh.fold 'update.hhvm', ansi: :yellow do
sh.echo "Updating HHVM", ansi: :yellow
sh.if "! $(grep -r hhvm\\.com /etc/apt/sources* 2>/dev/null)" do
sh.cmd 'sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449'
sh.raw 'sudo find /etc/apt -type f -exec sed -e "/hhvm\\.com/d" -i.bak {} \;'

if hhvm_version
sh.raw "echo \"deb http://dl.hhvm.com/ubuntu $(lsb_release -sc)-lts-#{hhvm_version} main\" | sudo tee -a /etc/apt/sources.list >&/dev/null"
sh.raw 'sudo apt-get purge hhvm >&/dev/null'
else
# use latest
sh.cmd 'echo "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list'
end

sh.cmd 'sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449'
sh.cmd 'sudo apt-get update -qq'
sh.cmd 'sudo apt-get install -y hhvm', timing: true
sh.cmd "sudo apt-get install -y hhvm", timing: true, echo: true, assert: true
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions spec/build/script/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
it { should include_sexp [:cmd, 'sudo apt-get install hhvm-nightly -y 2>&1 >/dev/null'] }
end

describe 'installs specific hhvm version' do
before { data[:config][:php] = 'hhvm-3.12' }
it { should include_sexp [:cmd, 'sudo apt-get update -qq'] }
it { should include_sexp [:cmd, 'sudo apt-get install -y hhvm', timing: true, assert: true, echo: true] }
it { should include_sexp [:raw, "echo \"deb http://dl.hhvm.com/ubuntu $(lsb_release -sc)-lts-3.12 main\" | sudo tee -a /etc/apt/sources.list >&/dev/null"] }
end

describe 'when desired PHP version is not found' do
let(:version) { '7.0.0beta2' }
let(:data) { payload_for(:push, :php, config: { php: version }) }
Expand Down