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

Add Elm language support #934

Merged
merged 67 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
8d864ed
Add script/elm.rb
Jan 20, 2017
bf9d28d
Add elm to build processes.
Jan 20, 2017
c8456af
Add elm_spec.rb
Jan 20, 2017
889e7aa
Switch to using elm-use so we get elm-format as well.
Feb 6, 2017
e55e6b5
Validate elm-format before running tests.
Feb 8, 2017
e9d6f6d
Specify elm-use version bounds
Mar 2, 2017
59f0e85
Use NodeJs base class
Mar 2, 2017
bbd0617
Add .nvmrc to set default Node version
Mar 2, 2017
dcb800b
Fully qualify NodeJs
Mar 2, 2017
acc4839
Don't use .nvmrc
Mar 2, 2017
419515f
Add require node_js
Mar 2, 2017
4a51a94
Use echo: true instead of sh.echo
Mar 2, 2017
9f3c387
Shorten to just NodeJs
Mar 2, 2017
0a653d9
Fix requires
Mar 3, 2017
0e692ef
Update cache slug and fix test.
Mar 3, 2017
ca0e387
Install Node 6.10.0 by default.
Mar 3, 2017
d0dfc51
Put install_sysconfcpus behind a fold
Mar 3, 2017
22bc82a
Use double quotes for string interpolation
Mar 3, 2017
8478100
Upgrade to elm-use 1.1.1
Mar 3, 2017
b633a43
Configure default Node version.
Mar 24, 2017
7d44452
Use explicit default versions.
Jul 10, 2017
acd348f
Bump elm-test version to latest.
Feb 1, 2018
df042a8
Fix tests.
Feb 1, 2018
6556aa8
Merge branch 'master' into add-elm
Feb 1, 2018
b6697ff
Put Elm installation behind a fold
Feb 7, 2018
9e913d1
Fail fast on elm-format --validate
Feb 7, 2018
1b79807
Move install_sysconfcpus to setup
Feb 7, 2018
fd9ac9d
Merge branch 'master' into add-elm
Feb 9, 2018
71ace6a
Fix test.
Mar 31, 2018
1dd9541
Merge branch 'master' into add-elm
Mar 31, 2018
2ce9146
Merge branch 'master' into add-elm
Apr 17, 2018
fe072aa
Merge branch 'master' into add-elm
carlad Jul 27, 2018
b988cdc
Merge branch 'master' into add-elm
joepvd Jul 30, 2018
be4c9d0
Merge branch 'master' into add-elm
carlad Jul 30, 2018
577858f
Added banner stating community maintainers
Jul 31, 2018
41062dc
Merge branch 'master' into add-elm
Jul 31, 2018
777015b
Merge branch 'master' into add-elm
Aug 9, 2018
3a00078
Merge branch 'master' into add-elm
Aug 29, 2018
8ed6eb5
Merge pull request #1 from Kurren123/add-elm
Aug 30, 2018
b8f82df
Merge branch 'master' into add-elm
Aug 30, 2018
2f9fdc8
Merge branch 'master' into add-elm
Aug 30, 2018
1911751
Merge branch 'master' into add-elm
BanzaiMan Oct 25, 2018
9331c82
Merge branch 'master' into add-elm
carlad Nov 6, 2018
f069edf
Add methods to extract different version numbers.
Sep 3, 2018
9f43237
Account for Elm 0.19+ having only one binary.
Sep 3, 2018
70fe4ed
Cache ~/.elm
Sep 3, 2018
912e647
Only cache tests/ in Elm 0.19+
Sep 3, 2018
0f82be3
Rename config variables to :elm and :elm_test
Sep 3, 2018
0c84815
Bump default node version to 8.9.1
Sep 3, 2018
bc69eee
Default to Elm 0.19
Sep 3, 2018
ccdb739
elm-test now requires Node 6+
Nov 7, 2018
ea1a0e1
Print elm-format version number.
Nov 7, 2018
583dd23
Clarify comment
Nov 7, 2018
e2e610f
Replace `elm-use` with @elm-#{version} convention.
Nov 7, 2018
a00fe69
Merge branch 'master' into add-elm
Nov 7, 2018
74f7059
Have Elm default to current Node LTS
Nov 7, 2018
8a7d251
Remove unnecessary 'when' clause
Nov 7, 2018
4ea672b
Merge branch 'master' into add-elm
carlad Nov 8, 2018
5774d5e
Merge branch 'master' into add-elm
carlad Nov 8, 2018
3dc1e08
Merge branch 'master' into add-elm
meatballhat Nov 9, 2018
8a7fa8e
Merge branch 'master' into add-elm
Nov 11, 2018
4f47671
Merge branch 'master' into add-elm
Nov 20, 2018
2944552
vers2int -> travis_vers2int
Nov 20, 2018
f53ea8a
Use npm_install_global over npm_install
Nov 20, 2018
17d4a12
Add a blank line after announce
Nov 20, 2018
e386ff2
Add some colored echo statements
Nov 20, 2018
96e46d2
Move echoes inside sh.fold
Nov 20, 2018
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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.10.0

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

2 changes: 2 additions & 0 deletions lib/travis/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def by_lang(lang)
Script::ObjectiveC
when 'bash', 'sh', 'shell' then
Script::Generic
when 'elm' then
rtfeldman marked this conversation as resolved.
Show resolved Hide resolved
Script::Elm
else
name = lang.split('_').map { |w| w.capitalize }.join
Script.const_get(name, false) rescue Script::Ruby
Expand Down
1 change: 1 addition & 0 deletions lib/travis/build/addons/deploy/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Script
VERSIONED_RUNTIMES = %w(
d
dart
elm
elixir
ghc
go
Expand Down
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/csharp'
require 'travis/build/script/d'
require 'travis/build/script/dart'
require 'travis/build/script/elm'

This comment was marked as spam.

require 'travis/build/script/erlang'
require 'travis/build/script/elixir'
require 'travis/build/script/go'
Expand Down
113 changes: 113 additions & 0 deletions lib/travis/build/script/elm.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
module Travis
module Build
class Script
class Elm < NodeJs
DEFAULTS = {
elm_version: 'latest',
elm_test_version: 'latest'
}

def export
super
sh.export 'TRAVIS_ELM_VERSION', elm_version, echo: false
sh.export 'TRAVIS_ELM_TEST_VERSION', elm_test_version, echo: false
end

def configure
super

sh.if '! -d sysconfcpus/bin' do
install_sysconfcpus
end
end

def announce
super
sh.echo 'elm version:'
sh.cmd 'elm --version'

This comment was marked as spam.


sh.echo 'elm-test version:'
sh.cmd 'elm-test --version'

This comment was marked as spam.

end

def setup
super

install_elm
install_elm_test
end

def script
sh.cmd 'elm-format --validate .'

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

sh.cmd 'elm-test'
end

def setup_cache
if data.cache?(:elm)
sh.fold 'cache.elm' do
directory_cache.add '$HOME/.cache/elm-stuff', 'elm-stuff'

# some put their tests in ./test and others use ./tests
directory_cache.add '$HOME/.cache/elm-test-stuff', 'test/elm-stuff'
directory_cache.add '$HOME/.cache/elm-tests-stuff', 'tests/elm-stuff'

# we build sysconfcpus from source, so cache the result
directory_cache.add '$HOME/.cache/sysconfcpus-cache', 'sysconfcpus'
end
end
end

def cache_slug
super << '--elm-' << elm_version
end

private

def elm_version
config[:elm_version].to_s
end

def elm_test_version
config[:elm_test_version].to_s
end

def install_elm
BanzaiMan marked this conversation as resolved.
Show resolved Hide resolved
npm_install '-g elm-use@">=1.1.0 <2.0.0"'
sh.cmd 'elm-use #{elm_version}', retry: true

This comment was marked as spam.

This comment was marked as spam.


convert_binary_to_sysconfcpus 'elm'
convert_binary_to_sysconfcpus 'elm-make'
convert_binary_to_sysconfcpus 'elm-package'
convert_binary_to_sysconfcpus 'elm-format'
end

def install_elm_test
npm_install '-g elm-test@#{elm_test_version}'

This comment was marked as spam.


convert_binary_to_sysconfcpus 'elm-test'
end

def convert_binary_to_sysconfcpus(binary_name)
# Wrap the binary in a call to sysconfcpus -n 2
# to work around https://github.com/travis-ci/travis-ci/issues/6656
sh.mv "$(npm config get prefix)/bin/#{binary_name}", "$(npm config get prefix)/bin/#{binary_name}-old"

# Use printf instead of echo here.
# see https://github.com/rtfeldman/node-elm-compiler/pull/50
sh.cmd ('printf "#\041/bin/bash\n\necho \"Running ' + binary_name + ' with sysconfcpus -n 2\"\n\n$TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 ' + binary_name + '-old \"\$@\"" > $(npm config get prefix)/bin/' + binary_name)
sh.chmod '+x', "$(npm config get prefix)/bin/#{binary_name}"
end

def install_sysconfcpus
BanzaiMan marked this conversation as resolved.
Show resolved Hide resolved
# this is a prerequisite for the convert_binary_to_sysconfcpus method
# which provides an epic build time improvement - see https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142
sh.cmd 'git clone https://github.com/obmarg/libsysconfcpus.git', retry: true
sh.cd 'libsysconfcpus'
sh.cmd './configure --prefix=$TRAVIS_BUILD_DIR/sysconfcpus'
sh.cmd 'make && make install'
sh.cd '..'
end
end
end
end
end
39 changes: 39 additions & 0 deletions spec/build/script/elm_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'spec_helper'

describe Travis::Build::Script::Elm, :sexp do
let(:data) { payload_for(:push, :elm) }
let(:script) { described_class.new(data) }
subject { script.sexp }
it { store_example }

it_behaves_like 'compiled script' do
let(:code) { ['TRAVIS_LANGUAGE=elm'] }
let(:cmds) { ['elm-test'] }
end

it_behaves_like 'a build script sexp'

it 'sets TRAVIS_ELM_VERSION' do
should include_sexp [:export, ['TRAVIS_ELM_VERSION', 'latest']]
end

it 'sets TRAVIS_ELM_TEST_VERSION' do
should include_sexp [:export, ['TRAVIS_ELM_TEST_VERSION', 'latest']]
end

it 'announces elm version' do
should include_sexp [:cmd, 'elm --version', echo: true]
should include_sexp [:cmd, 'elm-test --version', echo: true]
end

describe 'script' do
it 'runs "elm-test"' do
should include_sexp [:cmd, 'elm-test', echo: true, timing: true]
end
end

describe '#cache_slug' do
subject { described_class.new(data).cache_slug }
it { is_expected.to eq("cache-#{CACHE_SLUG_EXTRAS}--elm-latest") }

This comment was marked as spam.

end
end