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

Julia support #318

Closed
wants to merge 1 commit into from
Closed
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
Julia support
  • Loading branch information
Pontus Stenetorp committed Dec 10, 2014
commit 88c78ffdf38e77ffcdb742dffa19d98c5014bb0d
1 change: 1 addition & 0 deletions lib/travis/build/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
require 'travis/build/script/groovy'
require 'travis/build/script/generic'
require 'travis/build/script/haskell'
require 'travis/build/script/julia'
require 'travis/build/script/node_js'
require 'travis/build/script/objective_c'
require 'travis/build/script/perl'
Expand Down
106 changes: 106 additions & 0 deletions lib/travis/build/script/julia.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# vim:set ts=2 sw=2 sts=2 autoindent:

# Community maintainers:
#
# Tony Kelman <tony kelman net, @tkelman>
# Pontus Stenetorp <pontus stenetorp se, @ninjin>
# Elliot Saba <staticfloat gmail com, @staticfloat>
#
module Travis
module Build
class Script
class Julia < Script
DEFAULTS = {
julia: 'release',
}

def export
super

sh.export 'TRAVIS_JULIA_VERSION', config[:julia].to_s.shellescape,
echo: false
end

def setup
super

sh.echo 'Julia for Travis-CI is not officially supported, ' \
'but is community maintained.', ansi: :green
sh.echo 'Please file any issues using the following link',
ansi: :green
sh.echo ' https://github.com/travis-ci/travis-ci/issues' \
'/new?labels=julia', ansi: :green
sh.echo 'and mention \`@tkelman\`, \`@ninjin\` and ' \
'\`@staticfloat\` in the issue', ansi: :green

sh.echo 'Installing Julia', ansi: :yellow
case config[:os]
when 'linux'
sh.cmd 'mkdir -p ~/julia'
sh.cmd %Q{curl -s -L --retry 7 '#{julia_url}' } \
'| tar -C ~/julia -x -z --strip-components=1 -f -'
when 'osx'
sh.cmd %Q{curl -s -L -o julia.dmg '#{julia_url}'}
sh.cmd 'hdiutil mount -readonly julia.dmg'
sh.cmd 'cp -a /Volumes/Julia/*.app/Contents/Resources/julia ~/'
else
sh.failure "Operating system not supported: #{config[:os]}"
end
sh.cmd 'export PATH="${PATH}:${HOME}/julia/bin"'
end

def announce
super

sh.cmd "julia -e 'versioninfo()'"
sh.echo ''
end

def script
sh.echo 'Executing the default test script', ansi: :green
set_jl_pkg
# Check if the repository is a Julia package.
sh.if "-f src/${JL_PKG}.jl" do
sh.if '-a .git/shallow' do
sh.cmd 'git fetch --unshallow'
end
sh.cmd "julia -e 'Pkg.clone(pwd())'"
sh.cmd 'julia -e "Pkg.build(\"${JL_PKG}\")"'
sh.if '-f test/runtests.jl' do
sh.cmd 'julia --check-bounds=yes -e "Pkg.test(\"${JL_PKG}\")"'
end
end
end

private

def julia_url
case config[:julia]
when 'release'
version = 'stable'
when 'nightly'
version = 'download'
else
sh.failure "Unknown Julia version: #{config[:julia]}"
end
case config[:os]
when 'linux'
os = 'linux-x86_64'
when 'osx'
os = 'osx10.7+'
end
"https://status.julialang.org/#{version}/#{os}"
end

def set_jl_pkg
# Regular expression from: julia:base/pkg/entry.jl
urlregex = 'r"(?:^|[/\\\\])(\w+?)(?:\.jl)?(?:\.git)?$"'
jlcode = "println(match(#{urlregex}, readchomp(STDIN)).captures[1])"
shurl = "git remote -v | head -n 1 | cut -f 2 | cut -f 1 -d ' '"
sh.export 'JL_PKG', "$(#{shurl} | julia -e '#{jlcode}')",
echo: false
end
end
end
end
end
24 changes: 24 additions & 0 deletions spec/build/script/julia_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# vim:set ts=2 sw=2 sts=2 autoindent:

require 'spec_helper'

describe Travis::Build::Script::Julia, :sexp do
let(:data) { payload_for(:push, :julia) }
let(:script) { described_class.new(data) }
subject { script.sexp }

it_behaves_like 'a build script sexp'

it 'sets TRAVIS_JULIA_VERSION' do
should include_sexp [:export, ['TRAVIS_JULIA_VERSION', 'release']]
end

it 'downloads and installs Julia' do
should include_sexp [:cmd, %r(curl .*/stable/linux-x86_64), assert: true,
echo: true, timing: true]
end

it "announces `julia -e 'versioninfo()'`" do
should include_sexp [:cmd, "julia -e 'versioninfo()'", echo: true]
end
end