From 8d864ed54920937fcb61819376dcc94e8705f5c2 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 19 Jan 2017 20:21:43 -0800 Subject: [PATCH 01/46] Add script/elm.rb --- lib/travis/build/script/elm.rb | 110 +++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 lib/travis/build/script/elm.rb diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb new file mode 100644 index 0000000000..bd889bd9cd --- /dev/null +++ b/lib/travis/build/script/elm.rb @@ -0,0 +1,110 @@ +module Travis + module Build + class Script + class Elm < Script + 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' + + sh.echo 'elm-test version:' + sh.cmd 'elm-test --version' + end + + def setup + super + + install_elm + install_elm_test + end + + def script + 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 + sh.cmd 'npm install -g elm@#{elm_version}', retry: true + + convert_binary_to_sysconfcpus 'elm' + convert_binary_to_sysconfcpus 'elm-make' + convert_binary_to_sysconfcpus 'elm-package' + end + + def install_elm_test + sh.cmd 'npm install -g elm-test@#{elm_test_version}', retry: true + + 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 + # 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 From bf9d28de90513264405a0135085ab722d3bac4d6 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 19 Jan 2017 20:21:51 -0800 Subject: [PATCH 02/46] Add elm to build processes. --- lib/travis/build.rb | 2 ++ lib/travis/build/addons/deploy/script.rb | 1 + lib/travis/build/script.rb | 1 + 3 files changed, 4 insertions(+) diff --git a/lib/travis/build.rb b/lib/travis/build.rb index a06187d890..9182def87d 100644 --- a/lib/travis/build.rb +++ b/lib/travis/build.rb @@ -38,6 +38,8 @@ def by_lang(lang) Script::ObjectiveC when 'bash', 'sh', 'shell' then Script::Generic + when 'elm' then + Script::Elm else name = lang.split('_').map { |w| w.capitalize }.join Script.const_get(name, false) rescue Script::Ruby diff --git a/lib/travis/build/addons/deploy/script.rb b/lib/travis/build/addons/deploy/script.rb index 039f7ef7b8..98e1a64f29 100644 --- a/lib/travis/build/addons/deploy/script.rb +++ b/lib/travis/build/addons/deploy/script.rb @@ -9,6 +9,7 @@ class Script VERSIONED_RUNTIMES = %w( d dart + elm elixir ghc go diff --git a/lib/travis/build/script.rb b/lib/travis/build/script.rb index 4f4347e334..5343eae800 100644 --- a/lib/travis/build/script.rb +++ b/lib/travis/build/script.rb @@ -18,6 +18,7 @@ require 'travis/build/script/csharp' require 'travis/build/script/d' require 'travis/build/script/dart' +require 'travis/build/script/elm' require 'travis/build/script/erlang' require 'travis/build/script/elixir' require 'travis/build/script/go' From c8456af39f8b43d5c154c34c94006ef8b7db2257 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 19 Jan 2017 21:01:47 -0800 Subject: [PATCH 03/46] Add elm_spec.rb --- spec/build/script/elm_spec.rb | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 spec/build/script/elm_spec.rb diff --git a/spec/build/script/elm_spec.rb b/spec/build/script/elm_spec.rb new file mode 100644 index 0000000000..296a11ce08 --- /dev/null +++ b/spec/build/script/elm_spec.rb @@ -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") } + end +end From 889e7aaa6234581c9df34bfbbc1bb7c9ea330a9f Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 5 Feb 2017 22:10:28 -0800 Subject: [PATCH 04/46] Switch to using elm-use so we get elm-format as well. --- lib/travis/build/script/elm.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index bd889bd9cd..b6405fccaf 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -71,11 +71,13 @@ def elm_test_version end def install_elm - sh.cmd 'npm install -g elm@#{elm_version}', retry: true + sh.cmd 'npm install -g elm-use@1.1.0', retry: true + sh.cmd 'elm-use #{elm_version}', retry: true 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 From e55e6b59506cae1ec0cc72765e9ad3a7e6e8eb5a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 7 Feb 2017 22:26:09 -0800 Subject: [PATCH 05/46] Validate elm-format before running tests. --- lib/travis/build/script/elm.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index b6405fccaf..6868323273 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -38,6 +38,7 @@ def setup end def script + sh.cmd 'elm-format --validate .' sh.cmd 'elm-test' end From e9d6f6ddd42f1fd6da9f90528306549f6acd8b5a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 1 Mar 2017 16:05:24 -0800 Subject: [PATCH 06/46] Specify elm-use version bounds --- lib/travis/build/script/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 6868323273..b425b9cd58 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -72,7 +72,7 @@ def elm_test_version end def install_elm - sh.cmd 'npm install -g elm-use@1.1.0', retry: true + sh.cmd 'npm install -g elm-use@">=1.1.0 <2.0.0"', retry: true sh.cmd 'elm-use #{elm_version}', retry: true convert_binary_to_sysconfcpus 'elm' From 59f0e85ab4b2e523924f0485106f830af52ca6ac Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 2 Mar 2017 11:27:16 -0800 Subject: [PATCH 07/46] Use NodeJs base class --- lib/travis/build/script/elm.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index b425b9cd58..a64ea97323 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -1,7 +1,7 @@ module Travis module Build class Script - class Elm < Script + class Elm < NodeJs DEFAULTS = { elm_version: 'latest', elm_test_version: 'latest' @@ -72,7 +72,7 @@ def elm_test_version end def install_elm - sh.cmd 'npm install -g elm-use@">=1.1.0 <2.0.0"', retry: true + npm_install '-g elm-use@">=1.1.0 <2.0.0"' sh.cmd 'elm-use #{elm_version}', retry: true convert_binary_to_sysconfcpus 'elm' @@ -82,7 +82,7 @@ def install_elm end def install_elm_test - sh.cmd 'npm install -g elm-test@#{elm_test_version}', retry: true + npm_install '-g elm-test@#{elm_test_version}' convert_binary_to_sysconfcpus 'elm-test' end From bbd0617d32d347b0c49f952afd0fda51ad31ea81 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 2 Mar 2017 11:27:28 -0800 Subject: [PATCH 08/46] Add .nvmrc to set default Node version --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000000..cf79bf90ee --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +6.10.0 From dcb800b87a1325e10de763bfc794c250c03e016f Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 2 Mar 2017 11:57:17 -0800 Subject: [PATCH 09/46] Fully qualify NodeJs --- lib/travis/build/script/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index a64ea97323..1724ab521c 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -1,7 +1,7 @@ module Travis module Build class Script - class Elm < NodeJs + class Elm < Travis::Build::Script::NodeJs DEFAULTS = { elm_version: 'latest', elm_test_version: 'latest' From acc4839fbeff99184806b88047b321504f51e452 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 2 Mar 2017 15:01:22 -0800 Subject: [PATCH 10/46] Don't use .nvmrc --- .nvmrc | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index cf79bf90ee..0000000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -6.10.0 From 419515f2f51b1144681dcdaae9df0af3c155f92e Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 2 Mar 2017 15:01:32 -0800 Subject: [PATCH 11/46] Add require node_js --- lib/travis/build/script/elm.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 1724ab521c..38039299f9 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -1,3 +1,5 @@ +require 'node_js' + module Travis module Build class Script From 4a51a9481d4f837204149ce7077d7d6171397790 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 2 Mar 2017 15:01:39 -0800 Subject: [PATCH 12/46] Use echo: true instead of sh.echo --- lib/travis/build/script/elm.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 38039299f9..cea6500bfe 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -25,11 +25,8 @@ def configure def announce super - sh.echo 'elm version:' - sh.cmd 'elm --version' - - sh.echo 'elm-test version:' - sh.cmd 'elm-test --version' + sh.cmd 'elm --version', echo: true + sh.cmd 'elm-test --version', echo: true end def setup From 9f3c387b64cb32341a05aab3b688fb2a40cebaeb Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 2 Mar 2017 15:02:28 -0800 Subject: [PATCH 13/46] Shorten to just NodeJs --- lib/travis/build/script/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index cea6500bfe..414f53e139 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -3,7 +3,7 @@ module Travis module Build class Script - class Elm < Travis::Build::Script::NodeJs + class Elm < NodeJs DEFAULTS = { elm_version: 'latest', elm_test_version: 'latest' From 0a653d9f89cf6596489fe0cd8f39b009196b4d69 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 2 Mar 2017 21:48:47 -0800 Subject: [PATCH 14/46] Fix requires --- lib/travis/build/script.rb | 2 +- lib/travis/build/script/elm.rb | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/travis/build/script.rb b/lib/travis/build/script.rb index 5343eae800..bf63127e26 100644 --- a/lib/travis/build/script.rb +++ b/lib/travis/build/script.rb @@ -18,7 +18,6 @@ require 'travis/build/script/csharp' require 'travis/build/script/d' require 'travis/build/script/dart' -require 'travis/build/script/elm' require 'travis/build/script/erlang' require 'travis/build/script/elixir' require 'travis/build/script/go' @@ -29,6 +28,7 @@ require 'travis/build/script/julia' require 'travis/build/script/nix' require 'travis/build/script/node_js' +require 'travis/build/script/elm' require 'travis/build/script/objective_c' require 'travis/build/script/perl' require 'travis/build/script/perl6' diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 414f53e139..9fb787a4ed 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -1,5 +1,3 @@ -require 'node_js' - module Travis module Build class Script From 0e692ef34d7a485523f63cfde78be4b4144da2c0 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 2 Mar 2017 21:53:21 -0800 Subject: [PATCH 15/46] Update cache slug and fix test. --- lib/travis/build/script/elm.rb | 2 +- spec/build/script/elm_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 9fb787a4ed..71be2393dc 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -55,7 +55,7 @@ def setup_cache end def cache_slug - super << '--elm-' << elm_version + super << '-elm-' << elm_version end private diff --git a/spec/build/script/elm_spec.rb b/spec/build/script/elm_spec.rb index 296a11ce08..0a44a5a542 100644 --- a/spec/build/script/elm_spec.rb +++ b/spec/build/script/elm_spec.rb @@ -34,6 +34,6 @@ describe '#cache_slug' do subject { described_class.new(data).cache_slug } - it { is_expected.to eq("cache-#{CACHE_SLUG_EXTRAS}--elm-latest") } + it { is_expected.to eq("cache-#{CACHE_SLUG_EXTRAS}--node--elm-latest") } end end From ca0e387ddcc0fd66816dda56caaaf543e33bf849 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 3 Mar 2017 06:17:11 -0800 Subject: [PATCH 16/46] Install Node 6.10.0 by default. --- lib/travis/build/script/elm.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 71be2393dc..c9be0daf86 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -2,11 +2,16 @@ module Travis module Build class Script class Elm < NodeJs + # Default NodeJS version to install + DEFAULT_VERSION = '6.10.0' + DEFAULTS = { elm_version: 'latest', elm_test_version: 'latest' } + ELM_TEST_REQUIRED_NODE_VERSION = '4.0.0' + def export super sh.export 'TRAVIS_ELM_VERSION', elm_version, echo: false @@ -79,9 +84,17 @@ def install_elm end def install_elm_test - npm_install '-g elm-test@#{elm_test_version}' - - convert_binary_to_sysconfcpus 'elm-test' + sh.if "$(vers2int $(echo `node --version` | tr -d 'v')) -lt $(vers2int #{ELM_TEST_REQUIRED_NODE_VERSION})" do + sh.echo "Node.js version $(node --version) does not meet requirement for elm-test." \ + " Please use Node.js #{ELM_TEST_REQUIRED_NODE_VERSION} or later.", ansi: :red + end + sh.else do + sh.if "-z \"$(command -v elm-test)\"" do + npm_install '-g elm-test@#{elm_test_version}' + + convert_binary_to_sysconfcpus 'elm-test' + end + end end def convert_binary_to_sysconfcpus(binary_name) From d0dfc51c86b1845e3cdff13fdc043364e452b611 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 3 Mar 2017 06:17:39 -0800 Subject: [PATCH 17/46] Put install_sysconfcpus behind a fold --- lib/travis/build/script/elm.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index c9be0daf86..7a1323aeca 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -109,13 +109,15 @@ def convert_binary_to_sysconfcpus(binary_name) end def install_sysconfcpus - # 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 '..' + sh.fold 'sysconfcpus' do + # 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 From 22bc82a32d8a9b3b02ef4f5932be3bc33817b5ff Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 3 Mar 2017 06:18:35 -0800 Subject: [PATCH 18/46] Use double quotes for string interpolation --- lib/travis/build/script/elm.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 7a1323aeca..1ede28e8aa 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -75,7 +75,7 @@ def elm_test_version def install_elm npm_install '-g elm-use@">=1.1.0 <2.0.0"' - sh.cmd 'elm-use #{elm_version}', retry: true + sh.cmd "elm-use #{elm_version}", retry: true convert_binary_to_sysconfcpus 'elm' convert_binary_to_sysconfcpus 'elm-make' @@ -90,7 +90,7 @@ def install_elm_test end sh.else do sh.if "-z \"$(command -v elm-test)\"" do - npm_install '-g elm-test@#{elm_test_version}' + npm_install "-g elm-test@#{elm_test_version}" convert_binary_to_sysconfcpus 'elm-test' end From 8478100eaca39d3f7974918419e3348ee9c8cde9 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 3 Mar 2017 11:04:40 -0800 Subject: [PATCH 19/46] Upgrade to elm-use 1.1.1 --- lib/travis/build/script/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 1ede28e8aa..661b95ca41 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -74,7 +74,7 @@ def elm_test_version end def install_elm - npm_install '-g elm-use@">=1.1.0 <2.0.0"' + npm_install '-g elm-use@">=1.1.1 <2.0.0"' sh.cmd "elm-use #{elm_version}", retry: true convert_binary_to_sysconfcpus 'elm' From b633a4332f80ec13b01cf7dd35e25c4196cc0477 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 23 Mar 2017 22:18:04 -0700 Subject: [PATCH 20/46] Configure default Node version. --- lib/travis/build/script/elm.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 661b95ca41..3edca49057 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -3,7 +3,7 @@ module Build class Script class Elm < NodeJs # Default NodeJS version to install - DEFAULT_VERSION = '6.10.0' + DEFAULT_NODE_VERSION = '6.10.0' DEFAULTS = { elm_version: 'latest', @@ -21,6 +21,8 @@ def export def configure super + config[:node_js] ||= DEFAULT_NODE_VERSION + sh.if '! -d sysconfcpus/bin' do install_sysconfcpus end From 7d444528d82596c0f08d97ff6a2f91d5aa49c46a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 9 Jul 2017 22:44:55 -0400 Subject: [PATCH 21/46] Use explicit default versions. --- lib/travis/build/script/elm.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 3edca49057..8f6668d9a4 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -6,8 +6,8 @@ class Elm < NodeJs DEFAULT_NODE_VERSION = '6.10.0' DEFAULTS = { - elm_version: 'latest', - elm_test_version: 'latest' + elm_version: '0.18.0', + elm_test_version: '0.18.7' } ELM_TEST_REQUIRED_NODE_VERSION = '4.0.0' From acd348fa0f37fa243268490b97a245dca4dff6b9 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 1 Feb 2018 07:11:42 -0500 Subject: [PATCH 22/46] Bump elm-test version to latest. --- lib/travis/build/script/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 8f6668d9a4..b8a120a976 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -7,7 +7,7 @@ class Elm < NodeJs DEFAULTS = { elm_version: '0.18.0', - elm_test_version: '0.18.7' + elm_test_version: '0.18.12' } ELM_TEST_REQUIRED_NODE_VERSION = '4.0.0' From df042a84273e9cfaddd2b08c3b3beadbbebb71c2 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 1 Feb 2018 07:16:16 -0500 Subject: [PATCH 23/46] Fix tests. --- spec/build/script/elm_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/build/script/elm_spec.rb b/spec/build/script/elm_spec.rb index 0a44a5a542..737a447dda 100644 --- a/spec/build/script/elm_spec.rb +++ b/spec/build/script/elm_spec.rb @@ -14,11 +14,11 @@ it_behaves_like 'a build script sexp' it 'sets TRAVIS_ELM_VERSION' do - should include_sexp [:export, ['TRAVIS_ELM_VERSION', 'latest']] + should include_sexp [:export, ['TRAVIS_ELM_VERSION', Travis::Build::Script::Elm::DEFAULTS[:elm_version]]] end it 'sets TRAVIS_ELM_TEST_VERSION' do - should include_sexp [:export, ['TRAVIS_ELM_TEST_VERSION', 'latest']] + should include_sexp [:export, ['TRAVIS_ELM_TEST_VERSION', Travis::Build::Script::Elm::DEFAULTS[:elm_test_version]]] end it 'announces elm version' do @@ -34,6 +34,6 @@ describe '#cache_slug' do subject { described_class.new(data).cache_slug } - it { is_expected.to eq("cache-#{CACHE_SLUG_EXTRAS}--node--elm-latest") } + it { is_expected.to eq("cache-#{CACHE_SLUG_EXTRAS}--node--elm-#{Travis::Build::Script::Elm::DEFAULTS[:elm_version]}") } end end From b6697ff5bbe8de4ef3a044fe312cdb5e56a9a384 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 7 Feb 2018 18:01:01 -0500 Subject: [PATCH 24/46] Put Elm installation behind a fold --- lib/travis/build/script/elm.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index b8a120a976..bff074efd5 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -37,8 +37,10 @@ def announce def setup super - install_elm - install_elm_test + sh.fold 'install.elm' do + install_elm + install_elm_test + end end def script From 9e913d1f01d43fa138ce25e988971d1f9261ad64 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 7 Feb 2018 18:01:13 -0500 Subject: [PATCH 25/46] Fail fast on elm-format --validate --- lib/travis/build/script/elm.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index bff074efd5..44029003d1 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -44,8 +44,7 @@ def setup end def script - sh.cmd 'elm-format --validate .' - sh.cmd 'elm-test' + sh.cmd 'elm-format --validate . && elm-test' end def setup_cache From 1b7980728851f5f193b002cca45d07804ffabdef Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 7 Feb 2018 18:03:16 -0500 Subject: [PATCH 26/46] Move install_sysconfcpus to setup --- lib/travis/build/script/elm.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 44029003d1..1d373f4278 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -22,10 +22,6 @@ def configure super config[:node_js] ||= DEFAULT_NODE_VERSION - - sh.if '! -d sysconfcpus/bin' do - install_sysconfcpus - end end def announce @@ -37,6 +33,10 @@ def announce def setup super + sh.if '! -d sysconfcpus/bin' do + install_sysconfcpus + end + sh.fold 'install.elm' do install_elm install_elm_test From 71ace6a19c3c8be7f5a86859aec57b84cc94e724 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 30 Mar 2018 22:31:01 -0400 Subject: [PATCH 27/46] Fix test. --- spec/build/script/elm_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/build/script/elm_spec.rb b/spec/build/script/elm_spec.rb index 737a447dda..10b3633811 100644 --- a/spec/build/script/elm_spec.rb +++ b/spec/build/script/elm_spec.rb @@ -27,8 +27,8 @@ end describe 'script' do - it 'runs "elm-test"' do - should include_sexp [:cmd, 'elm-test', echo: true, timing: true] + it 'runs `elm-test` and `elm-format`' do + should include_sexp [:cmd, 'elm-format --validate . && elm-test', echo: true, timing: true] end end From 577858f7bc3e17d6046566ffb4ca0a7d901ff150 Mon Sep 17 00:00:00 2001 From: "DESKTOP-C2QRME4\\Kurren Nischal" Date: Tue, 31 Jul 2018 16:41:31 +0100 Subject: [PATCH 28/46] Added banner stating community maintainers --- lib/travis/build/script/elm.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 1d373f4278..597f07015a 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -33,6 +33,16 @@ def announce def setup super + sh.echo 'Elm 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=community:elm', ansi: :green + sh.echo 'and mention \`@avh4\`, \`@lukewestby\`, \`@stoeffel\` and \`@rtfeldman\`' \ + ' in the issue', ansi: :green + + sh.if '! -d sysconfcpus/bin' do install_sysconfcpus end From f069edfc6956ac373f0414c4376dbc8ccd0f7781 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 3 Sep 2018 19:00:32 -0400 Subject: [PATCH 29/46] Add methods to extract different version numbers. --- lib/travis/build/script/elm.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 597f07015a..dd92b6991c 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -82,6 +82,22 @@ def elm_version config[:elm_version].to_s end + def elm_version_number(index) + elm_version.split(".")[index] + end + + def elm_major_version + elm_version_number 0 + end + + def elm_minor_version + elm_version_number 1 + end + + def elm_patch_version + elm_version_number 2 + end + def elm_test_version config[:elm_test_version].to_s end From 9f43237d619e285316dadc5dd410449c5e0d5b2d Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 3 Sep 2018 19:01:06 -0400 Subject: [PATCH 30/46] Account for Elm 0.19+ having only one binary. --- lib/travis/build/script/elm.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index dd92b6991c..90dd9a37a4 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -107,9 +107,14 @@ def install_elm sh.cmd "elm-use #{elm_version}", retry: true convert_binary_to_sysconfcpus 'elm' - convert_binary_to_sysconfcpus 'elm-make' - convert_binary_to_sysconfcpus 'elm-package' - convert_binary_to_sysconfcpus 'elm-format' + + # Beginning with Elm 0.19, there's one `elm` binary and that's it. + # In that case, there won't be any files to convert here! + if elm_major_version == 0 && elm_minor_version <= 18 + convert_binary_to_sysconfcpus 'elm-make' + convert_binary_to_sysconfcpus 'elm-package' + convert_binary_to_sysconfcpus 'elm-format' + end end def install_elm_test From 70fe4edbac30677019eaf4c71e990f11b9983084 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 3 Sep 2018 19:07:51 -0400 Subject: [PATCH 31/46] Cache ~/.elm --- lib/travis/build/script/elm.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 90dd9a37a4..90a8113d6c 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -60,6 +60,9 @@ def script def setup_cache if data.cache?(:elm) sh.fold 'cache.elm' do + # Cache the ~/.elm directory. + directory_cache.add '$HOME/.cache/elm', '$HOME/.elm' + directory_cache.add '$HOME/.cache/elm-stuff', 'elm-stuff' # some put their tests in ./test and others use ./tests From 912e64758ff7341beec33f6e0fbe2d4648fda856 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 3 Sep 2018 19:10:41 -0400 Subject: [PATCH 32/46] Only cache tests/ in Elm 0.19+ --- lib/travis/build/script/elm.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 90a8113d6c..559d249090 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -65,8 +65,13 @@ def setup_cache 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' + if elm_major_version == 0 && elm_minor_version <= 18 + # In Elm 0.18, some put their tests in ./test instead of ./tests + directory_cache.add '$HOME/.cache/elm-test-stuff', 'test/elm-stuff' + end + + # In Elm 0.18+, all tests must live in tests/ (whereas previously + # tests/ was allowed, but so was test/) directory_cache.add '$HOME/.cache/elm-tests-stuff', 'tests/elm-stuff' # we build sysconfcpus from source, so cache the result From 0f82be371d3951d47428c356566c902ea401bce9 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 3 Sep 2018 19:12:58 -0400 Subject: [PATCH 33/46] Rename config variables to :elm and :elm_test See https://github.com/travis-ci/travis-build/pull/934\#issuecomment-418031168 --- lib/travis/build/script/elm.rb | 8 ++++---- spec/build/script/elm_spec.rb | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 559d249090..d1dd94ec1f 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -6,8 +6,8 @@ class Elm < NodeJs DEFAULT_NODE_VERSION = '6.10.0' DEFAULTS = { - elm_version: '0.18.0', - elm_test_version: '0.18.12' + elm: '0.18.0', + elm_test: '0.18.12' } ELM_TEST_REQUIRED_NODE_VERSION = '4.0.0' @@ -87,7 +87,7 @@ def cache_slug private def elm_version - config[:elm_version].to_s + config[:elm].to_s end def elm_version_number(index) @@ -107,7 +107,7 @@ def elm_patch_version end def elm_test_version - config[:elm_test_version].to_s + config[:elm_test].to_s end def install_elm diff --git a/spec/build/script/elm_spec.rb b/spec/build/script/elm_spec.rb index 10b3633811..05dce0c447 100644 --- a/spec/build/script/elm_spec.rb +++ b/spec/build/script/elm_spec.rb @@ -14,11 +14,11 @@ it_behaves_like 'a build script sexp' it 'sets TRAVIS_ELM_VERSION' do - should include_sexp [:export, ['TRAVIS_ELM_VERSION', Travis::Build::Script::Elm::DEFAULTS[:elm_version]]] + should include_sexp [:export, ['TRAVIS_ELM_VERSION', Travis::Build::Script::Elm::DEFAULTS[:elm]]] end it 'sets TRAVIS_ELM_TEST_VERSION' do - should include_sexp [:export, ['TRAVIS_ELM_TEST_VERSION', Travis::Build::Script::Elm::DEFAULTS[:elm_test_version]]] + should include_sexp [:export, ['TRAVIS_ELM_TEST_VERSION', Travis::Build::Script::Elm::DEFAULTS[:elm_test]]] end it 'announces elm version' do @@ -34,6 +34,6 @@ describe '#cache_slug' do subject { described_class.new(data).cache_slug } - it { is_expected.to eq("cache-#{CACHE_SLUG_EXTRAS}--node--elm-#{Travis::Build::Script::Elm::DEFAULTS[:elm_version]}") } + it { is_expected.to eq("cache-#{CACHE_SLUG_EXTRAS}--node--elm-#{Travis::Build::Script::Elm::DEFAULTS[:elm]}") } end end From 0c84815f33b094df46fc6c2faf9e08ce660b69ef Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 3 Sep 2018 19:15:22 -0400 Subject: [PATCH 34/46] Bump default node version to 8.9.1 --- lib/travis/build/script/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index d1dd94ec1f..48094c6f05 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -3,7 +3,7 @@ module Build class Script class Elm < NodeJs # Default NodeJS version to install - DEFAULT_NODE_VERSION = '6.10.0' + DEFAULT_NODE_VERSION = '8.9.1' DEFAULTS = { elm: '0.18.0', From bc69eeeec1b844933b7169cc37d573836af4bf12 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 3 Sep 2018 19:16:11 -0400 Subject: [PATCH 35/46] Default to Elm 0.19 --- lib/travis/build/script/elm.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 48094c6f05..0970d5a6e5 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -6,8 +6,8 @@ class Elm < NodeJs DEFAULT_NODE_VERSION = '8.9.1' DEFAULTS = { - elm: '0.18.0', - elm_test: '0.18.12' + elm: '0.19.0', + elm_test: '0.19.0' } ELM_TEST_REQUIRED_NODE_VERSION = '4.0.0' From ccdb739c3c28f80c3dc66c9dd010d811301d4dc5 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 6 Nov 2018 20:22:08 -0500 Subject: [PATCH 36/46] elm-test now requires Node 6+ --- lib/travis/build/script/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 0970d5a6e5..2ec395639f 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -10,7 +10,7 @@ class Elm < NodeJs elm_test: '0.19.0' } - ELM_TEST_REQUIRED_NODE_VERSION = '4.0.0' + ELM_TEST_REQUIRED_NODE_VERSION = '6.0.0' def export super From ea1a0e101af3f7310cb9a6d0be761e5a5d3052e8 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 6 Nov 2018 20:22:36 -0500 Subject: [PATCH 37/46] Print elm-format version number. --- lib/travis/build/script/elm.rb | 4 ++++ spec/build/script/elm_spec.rb | 1 + 2 files changed, 5 insertions(+) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 2ec395639f..027b5e95e7 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -28,6 +28,10 @@ def announce super sh.cmd 'elm --version', echo: true sh.cmd 'elm-test --version', echo: true + + # elm-format doesn't have --version, + # but the first line of `elm-format --help` prints the version + sh.cmd 'elm-format --help | head -n 1', echo: true end def setup diff --git a/spec/build/script/elm_spec.rb b/spec/build/script/elm_spec.rb index 05dce0c447..0e60a0a5ff 100644 --- a/spec/build/script/elm_spec.rb +++ b/spec/build/script/elm_spec.rb @@ -24,6 +24,7 @@ it 'announces elm version' do should include_sexp [:cmd, 'elm --version', echo: true] should include_sexp [:cmd, 'elm-test --version', echo: true] + should include_sexp [:cmd, 'elm-format --help | head -n 1', echo: true] end describe 'script' do From 583dd23c043fa6f672c03de46be7f681a8008d9a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 6 Nov 2018 20:23:24 -0500 Subject: [PATCH 38/46] Clarify comment --- lib/travis/build/script/elm.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 027b5e95e7..8a425d5533 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -74,8 +74,8 @@ def setup_cache directory_cache.add '$HOME/.cache/elm-test-stuff', 'test/elm-stuff' end - # In Elm 0.18+, all tests must live in tests/ (whereas previously - # tests/ was allowed, but so was test/) + # In Elm 0.18+, all tests live in tests/ by default + # (whereas previously tests/ was allowed, but so was test/) directory_cache.add '$HOME/.cache/elm-tests-stuff', 'tests/elm-stuff' # we build sysconfcpus from source, so cache the result From e2e610fed8377fc96a5acb636a314326ed4f0867 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 6 Nov 2018 20:23:36 -0500 Subject: [PATCH 39/46] Replace `elm-use` with @elm-#{version} convention. Now you can `npm install` (for example) elm-test@elm-0.19.0, which installs the latest version of elm-test that is compatible with elm 0.19.0. This version tagging convention is consistent across `elm`, `elm-test`, and `elm-format`, so `elm-use` is no longer necessary! --- lib/travis/build/script/elm.rb | 18 +++++++++++++++--- spec/build/script/elm_spec.rb | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 8a425d5533..a965c578de 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -7,7 +7,8 @@ class Elm < NodeJs DEFAULTS = { elm: '0.19.0', - elm_test: '0.19.0' + elm_test: '0.19.0', + elm_format: '0.19.0' } ELM_TEST_REQUIRED_NODE_VERSION = '6.0.0' @@ -16,6 +17,7 @@ def export super sh.export 'TRAVIS_ELM_VERSION', elm_version, echo: false sh.export 'TRAVIS_ELM_TEST_VERSION', elm_test_version, echo: false + sh.export 'TRAVIS_ELM_FORMAT_VERSION', elm_format_version, echo: false end def configure @@ -54,6 +56,7 @@ def setup sh.fold 'install.elm' do install_elm install_elm_test + install_elm_format end end @@ -114,9 +117,12 @@ def elm_test_version config[:elm_test].to_s end + def elm_format_version + config[:elm_format].to_s + end + def install_elm - npm_install '-g elm-use@">=1.1.1 <2.0.0"' - sh.cmd "elm-use #{elm_version}", retry: true + npm_install "-g elm@elm-#{elm_version}" convert_binary_to_sysconfcpus 'elm' @@ -129,6 +135,12 @@ def install_elm end end + def install_elm_format + npm_install "-g elm-format@elm-#{elm_format_version}" + + convert_binary_to_sysconfcpus 'elm-format' + end + def install_elm_test sh.if "$(vers2int $(echo `node --version` | tr -d 'v')) -lt $(vers2int #{ELM_TEST_REQUIRED_NODE_VERSION})" do sh.echo "Node.js version $(node --version) does not meet requirement for elm-test." \ diff --git a/spec/build/script/elm_spec.rb b/spec/build/script/elm_spec.rb index 0e60a0a5ff..e2213db730 100644 --- a/spec/build/script/elm_spec.rb +++ b/spec/build/script/elm_spec.rb @@ -21,6 +21,10 @@ should include_sexp [:export, ['TRAVIS_ELM_TEST_VERSION', Travis::Build::Script::Elm::DEFAULTS[:elm_test]]] end + it 'sets TRAVIS_ELM_FORMAT_VERSION' do + should include_sexp [:export, ['TRAVIS_ELM_FORMAT_VERSION', Travis::Build::Script::Elm::DEFAULTS[:elm_format]]] + end + it 'announces elm version' do should include_sexp [:cmd, 'elm --version', echo: true] should include_sexp [:cmd, 'elm-test --version', echo: true] From 74f7059eab2e893a5cea513c06846070403feebe Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 7 Nov 2018 12:02:18 -0500 Subject: [PATCH 40/46] Have Elm default to current Node LTS --- lib/travis/build/script/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index a965c578de..560a799a9a 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -3,7 +3,7 @@ module Build class Script class Elm < NodeJs # Default NodeJS version to install - DEFAULT_NODE_VERSION = '8.9.1' + DEFAULT_NODE_VERSION = '10.13.0' DEFAULTS = { elm: '0.19.0', From 8a7d251486d6df9d6f1e95a72188eef5f7cd32aa Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 7 Nov 2018 12:03:11 -0500 Subject: [PATCH 41/46] Remove unnecessary 'when' clause --- lib/travis/build.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/travis/build.rb b/lib/travis/build.rb index be1d36c3a5..beef932b38 100644 --- a/lib/travis/build.rb +++ b/lib/travis/build.rb @@ -49,8 +49,6 @@ def by_lang(lang) Script::ObjectiveC when 'bash', 'sh', 'shell', 'minimal' then Script::Generic - when 'elm' then - Script::Elm else name = lang.split('_').map { |w| w.capitalize }.join Script.const_get(name, false) rescue Script::Ruby From 294455217d26c8a01fe8aa979fa5e5a8127ead9c Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 20 Nov 2018 04:47:19 +0100 Subject: [PATCH 42/46] vers2int -> travis_vers2int --- lib/travis/build/script/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 560a799a9a..2e942d47fb 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -142,7 +142,7 @@ def install_elm_format end def install_elm_test - sh.if "$(vers2int $(echo `node --version` | tr -d 'v')) -lt $(vers2int #{ELM_TEST_REQUIRED_NODE_VERSION})" do + sh.if "$(travis_vers2int $(echo `node --version` | tr -d 'v')) -lt $(travis_vers2int #{ELM_TEST_REQUIRED_NODE_VERSION})" do sh.echo "Node.js version $(node --version) does not meet requirement for elm-test." \ " Please use Node.js #{ELM_TEST_REQUIRED_NODE_VERSION} or later.", ansi: :red end From f53ea8a36a6ee1ab463e482bcd1bdd5e1f182708 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 20 Nov 2018 04:33:59 +0100 Subject: [PATCH 43/46] Use npm_install_global over npm_install --- lib/travis/build/script/elm.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 2e942d47fb..22551d7c4e 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -6,9 +6,9 @@ class Elm < NodeJs DEFAULT_NODE_VERSION = '10.13.0' DEFAULTS = { - elm: '0.19.0', - elm_test: '0.19.0', - elm_format: '0.19.0' + elm: 'elm0.19.0', + elm_test: 'elm0.19.0', + elm_format: 'elm0.19.0' } ELM_TEST_REQUIRED_NODE_VERSION = '6.0.0' @@ -98,7 +98,7 @@ def elm_version end def elm_version_number(index) - elm_version.split(".")[index] + elm_version.gsub(/[a-zA-Z]/, "").split(".")[index] end def elm_major_version @@ -121,8 +121,12 @@ def elm_format_version config[:elm_format].to_s end + def npm_install_global(package_name, package_version) + sh.cmd "npm install -g #{package_name}@#{package_version}" + end + def install_elm - npm_install "-g elm@elm-#{elm_version}" + npm_install_global 'elm', elm_version convert_binary_to_sysconfcpus 'elm' @@ -136,7 +140,7 @@ def install_elm end def install_elm_format - npm_install "-g elm-format@elm-#{elm_format_version}" + npm_install_global 'elm-format', elm_format_version convert_binary_to_sysconfcpus 'elm-format' end @@ -148,7 +152,7 @@ def install_elm_test end sh.else do sh.if "-z \"$(command -v elm-test)\"" do - npm_install "-g elm-test@#{elm_test_version}" + npm_install_global 'elm-test', elm_test_version convert_binary_to_sysconfcpus 'elm-test' end From 17d4a121f4d18126b59a902eac364b8711395d63 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 20 Nov 2018 05:09:44 +0100 Subject: [PATCH 44/46] Add a blank line after announce --- lib/travis/build/script/elm.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 22551d7c4e..1d8611e5f5 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -34,6 +34,8 @@ def announce # elm-format doesn't have --version, # but the first line of `elm-format --help` prints the version sh.cmd 'elm-format --help | head -n 1', echo: true + + sh.echo '' # A blank line visually separates this from the next cmd end def setup From e386ff219defbe58bbe931cc0b66b57e866d818c Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 20 Nov 2018 05:09:57 +0100 Subject: [PATCH 45/46] Add some colored echo statements --- lib/travis/build/script/elm.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 1d8611e5f5..76697aa58d 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -55,6 +55,7 @@ def setup install_sysconfcpus end + sh.echo 'Installing elm, elm-test, and elm-format', ansi: :green sh.fold 'install.elm' do install_elm install_elm_test @@ -173,6 +174,7 @@ def convert_binary_to_sysconfcpus(binary_name) end def install_sysconfcpus + sh.echo 'Installing sysconfcpus', ansi: :green sh.fold 'sysconfcpus' do # 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 From 96e46d27e9a75ddec3cda2ed6afc8d0bd12e5d73 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 20 Nov 2018 16:06:44 +0100 Subject: [PATCH 46/46] Move echoes inside sh.fold --- lib/travis/build/script/elm.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/build/script/elm.rb b/lib/travis/build/script/elm.rb index 76697aa58d..96dab636a5 100644 --- a/lib/travis/build/script/elm.rb +++ b/lib/travis/build/script/elm.rb @@ -55,8 +55,8 @@ def setup install_sysconfcpus end - sh.echo 'Installing elm, elm-test, and elm-format', ansi: :green sh.fold 'install.elm' do + sh.echo 'Installing elm, elm-test, and elm-format', ansi: :green install_elm install_elm_test install_elm_format @@ -174,8 +174,8 @@ def convert_binary_to_sysconfcpus(binary_name) end def install_sysconfcpus - sh.echo 'Installing sysconfcpus', ansi: :green sh.fold 'sysconfcpus' do + sh.echo 'Installing sysconfcpus', ansi: :green # 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