From 371c8b8a1ca7d0a4799fecc8b8c70ea2df1f7383 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 15 Apr 2015 21:32:39 -0700 Subject: [PATCH] chore(travis): add npm/install-dependencies.sh step in preparation for caching --- .travis.yml | 10 ++++++++++ tools/npm/install-dependencies.sh | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 tools/npm/install-dependencies.sh diff --git a/.travis.yml b/.travis.yml index d2d63b591b..162cb0b10d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,12 +28,22 @@ before_install: - ./scripts/ci/install_dart.sh ${DART_CHANNEL} ${ARCH} - sh -e /etc/init.d/xvfb start - if [[ -e SKIP_TRAVIS_TESTS ]]; then { cat SKIP_TRAVIS_TESTS ; exit 0; } fi + +install: + # Check the size of caches + - du -sh ./node_modules || true + # Install npm dependecies and ensure that npm cache is not stale + - tools/npm/install-dependencies.sh + before_script: - mkdir -p $LOGS_DIR + script: - ./scripts/ci/build_and_test.sh ${MODE} + after_script: - ./scripts/ci/print-logs.sh + notifications: webhooks: urls: diff --git a/tools/npm/install-dependencies.sh b/tools/npm/install-dependencies.sh new file mode 100755 index 0000000000..1851d4ea6a --- /dev/null +++ b/tools/npm/install-dependencies.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +SHRINKWRAP_FILE=npm-shrinkwrap.json +SHRINKWRAP_CACHED_FILE=node_modules/npm-shrinkwrap.cached.json + +if diff -q $SHRINKWRAP_FILE $SHRINKWRAP_CACHED_FILE; then + echo 'No shrinkwrap changes detected. npm install will be skipped...'; +else + echo 'Blowing away node_modules and reinstalling npm dependencies...' + rm -rf node_modules + npm install + cp $SHRINKWRAP_FILE $SHRINKWRAP_CACHED_FILE + echo 'npm install successful!' +fi