Skip to content

Commit

Permalink
Faster builds by limiting visible CPUs
Browse files Browse the repository at this point in the history
As described in this elm compiler issue:
elm/compiler#1473
  • Loading branch information
davcamer committed Aug 12, 2018
1 parent 8c189ac commit a0878fd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,26 @@ 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
- node --version
- 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
13 changes: 13 additions & 0 deletions install_sysconfcpus
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion protoc-gen-elm/elm_tests/run_elm_tests
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit a0878fd

Please sign in to comment.