Skip to content

Instantly share code, notes, and snippets.

@maxnowack
Created April 20, 2018 09:38
Show Gist options
  • Save maxnowack/620911b1845c8607d3e5572bdbdb874f to your computer and use it in GitHub Desktop.
Save maxnowack/620911b1845c8607d3e5572bdbdb874f to your computer and use it in GitHub Desktop.
CircleCI Meteor Caching
version: 2
jobs:
unit-tests:
working_directory: ~/app
docker:
- image: circleci/node:latest
environment:
# lang settings required for Meteor's Mongo
LANG: C.UTF-8
LANGUAGE: C.UTF-8
LC_ALL: C.UTF-8
LC_NUMERIC: en_US.UTF-8
METEOR_BIN_TMP_DIR: /home/circleci/build-temp/
METEOR_BIN_TMP_FILE: meteor-bin-temp
steps:
- checkout
- restore_cache:
key: build-temp-{{ checksum ".meteor/release" }}-{{ checksum ".circleci/config.yml" }}
- restore_cache:
key: meteor-release-{{ checksum ".meteor/release" }}-{{ checksum ".meteor/versions" }}-{{ checksum ".circleci/config.yml" }}
- restore_cache:
key: meteor-packages
- restore_cache:
key: npm-packages-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}
- run:
name: restore cached meteor binary
command: |
if [ -e ~/build-temp/meteor-bin ]
then
echo "Cached Meteor bin found, restoring it."
sudo cp ~/build-temp/meteor-bin /usr/local/bin/meteor
else
echo "No cached Meteor bin found."
fi
- run:
name: install meteor
command: |
# only install meteor if bin isn't found
command -v meteor >/dev/null 2>&1 || curl https://install.meteor.com | /bin/sh
- run:
name: check versions
command: |
echo "Meteor version:"
# this forces Meteor to download whatever release your project is using
meteor --version
which meteor
echo "Meteor node version:"
meteor node -v
echo "Meteor npm version:"
meteor npm -v
- run:
name: copy meteor bin to build cache
command: |
mkdir -p ~/build-temp
cp /usr/local/bin/meteor ~/build-temp/meteor-bin
- save_cache:
key: build-temp-{{ checksum ".meteor/release" }}-{{ checksum ".circleci/config.yml" }}
paths:
- ~/build-temp
- run:
name: install npm packages
command: meteor npm i
- save_cache:
key: npm-packages-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}
paths:
- ./node_modules/
- ~/.npm/
- run:
name: run tests
command: meteor npm run test
- save_cache:
key: meteor-release-{{ checksum ".meteor/release" }}-{{ checksum ".meteor/versions" }}-{{ checksum ".circleci/config.yml" }}
paths:
- ~/.meteor
- save_cache:
key: meteor-packages-{{ epoch }}
paths:
- .meteor/local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment