From a0878fd14f14e444ce98c4d8660ff853bb6fb3bf Mon Sep 17 00:00:00 2001 From: Dave Cameron Date: Sun, 12 Aug 2018 09:37:37 -0400 Subject: [PATCH] Faster builds by limiting visible CPUs As described in this elm compiler issue: https://github.com/elm/compiler/issues/1473 --- .travis.yml | 11 ++++++++++- install_sysconfcpus | 13 +++++++++++++ protoc-gen-elm/elm_tests/run_elm_tests | 8 +++++++- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 install_sysconfcpus diff --git a/.travis.yml b/.travis.yml index 093c78b..ed30fa3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,17 @@ addons: env: - TRAVIS_NODE_VERSION="v7.2.1" +cache: + directories: + - sysconfcpus + - protoc + before_install: - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION + - ./install_sysconfcpus + - ./install_protobuf install: - - ./install_protobuf - export PATH=$PATH:$PWD/protoc/bin - go get -t -v ./protoc-gen-elm - protoc --version @@ -22,5 +28,8 @@ install: - npm --version - npm install -g elm - npm install -g elm-test + - mv $(npm config get prefix)/bin/elm-make $(npm config get prefix)/bin/elm-make-old + - printf '%s\n\n' '#!/bin/bash' 'echo "Running elm-make with sysconfcpus -n 2"' '$TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 elm-make-old "$@"' > $(npm config get prefix)/bin/elm-make + - chmod +x $(npm config get prefix)/bin/elm-make script: ./run_tests diff --git a/install_sysconfcpus b/install_sysconfcpus new file mode 100755 index 0000000..efc0a2a --- /dev/null +++ b/install_sysconfcpus @@ -0,0 +1,13 @@ +#!/bin/bash + +set -ex + +echo "Install libsysconfcpus to compensate for slow elm builds" +# More at: https://github.com/elm/compiler/issues/1473 +if [ ! -d sysconfcpus/bin ]; then + git clone https://github.com/obmarg/libsysconfcpus.git + cd libsysconfcpus + ./configure --prefix=$TRAVIS_BUILD_DIR/sysconfcpus + make && make install + cd .. +fi diff --git a/protoc-gen-elm/elm_tests/run_elm_tests b/protoc-gen-elm/elm_tests/run_elm_tests index 898ce69..4d230fb 100755 --- a/protoc-gen-elm/elm_tests/run_elm_tests +++ b/protoc-gen-elm/elm_tests/run_elm_tests @@ -11,5 +11,11 @@ readonly ROOT="$(dirname "$0")" ( cd ${ROOT} - elm-test + # If sysconfcpus is on path, as on travis, then limit the number of + # visible CPUs to 1 to work around the elm problems with many CPUs. + if [ -x "$(command -v sysconfcpus)" ]; then + sysconfcpus -n 1 elm-test + else + elm-test + fi )