Travis CI's caching archives all directories listed in the configuration and uploads them to Amazon S3. Cached contents are available to any build on the repository, including Pull Requests. For Python and Node.js projects, you could cache both
node_modules directories in every Travis CI build.
Here is an example of
sudo: false language: python python: - "2.7" node_js: 4 cache: directories: - $HOME/.cache/pip - $HOME/virtualenv/python2.7.9/lib/python2.7/site-packages - node_modules before_install: - pip install -U pip install: - pip install -r requirements.txt - pip install coverage --ignore-installed - npm install script: - coverage run manage.py test
In the case of mine, after applying these changes, the installation time of
npm reduces from 180 seconds to 5 seconds.
One thing should be mentioned here: Since we didn't specify any
bin folder in the configuration (and I don't think that's necessary), any execution file that being installed by
pip such as
django-admin.py will not exist in subsequent builds. If you need those commands, you could just force install them by adding
pip install some_package --ignore-installed.