Browse Source

Merge pull request #662 from meriadec/optimize-ci

Optimize CI builds by caching dependencies
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
8087f5444e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      .circleci/config.yml
  2. 26
      scripts/hash-utils.sh
  3. 13
      scripts/install-ci-deps.sh
  4. 31
      scripts/postinstall.sh

13
.circleci/config.yml

@ -12,9 +12,18 @@ jobs:
- gh-pages
steps:
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- v1-yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run:
name: Dependencies
command: SKIP_REBUILD=1 yarn
name: Install Dependencies
command: bash scripts/install-ci-deps.sh
- save_cache:
name: Save Yarn Package Cache
key: v1-yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- node_modules/
- run:
name: Lint
command: yarn lint

26
scripts/hash-utils.sh

@ -0,0 +1,26 @@
#/bin/bash
function GET_HASH_PATH {
HASH_NAME=$1
echo "./node_modules/.cache/LEDGER_HASH_$HASH_NAME.hash"
}
function GET_HASH {
HASH_NAME=$1
HASH_PATH=`GET_HASH_PATH $HASH_NAME`
if [ ! -e "$HASH_PATH" ]; then
echo ''
else
HASH_CONTENT=`cat "$HASH_PATH"`
echo $HASH_CONTENT
fi
}
function SET_HASH {
HASH_NAME=$1
HASH_CONTENT=$2
echo "setting hash $HASH_NAME to $HASH_CONTENT"
HASH_PATH=`GET_HASH_PATH $HASH_NAME`
mkdir -p ./node_modules/.cache
echo $HASH_CONTENT > $HASH_PATH
}

13
scripts/install-ci-deps.sh

@ -0,0 +1,13 @@
#/bin/bash
source scripts/hash-utils.sh
PACKAGE_JSON_HASH=`md5sum package.json | cut -d ' ' -f 1`
CACHED_PACKAGE_JSON_HASH=`GET_HASH 'package.json'`
if [ "$CACHED_PACKAGE_JSON_HASH" == "$PACKAGE_JSON_HASH" ]; then
echo "> Skipping yarn install"
else
yarn install
SET_HASH 'package.json' $PACKAGE_JSON_HASH
fi

31
scripts/postinstall.sh

@ -1,33 +1,12 @@
#/bin/bash
function MAIN {
REBUILD_ELECTRON_NATIVE_DEPS
INSTALL_FLOW_TYPED
}
function GET_HASH_PATH {
HASH_NAME=$1
echo "./node_modules/.cache/LEDGER_HASH_$HASH_NAME.hash"
}
source scripts/hash-utils.sh
function GET_HASH {
HASH_NAME=$1
HASH_PATH=`GET_HASH_PATH $HASH_NAME`
if [ ! -e "$HASH_PATH" ]; then
echo ''
else
HASH_CONTENT=`cat "$HASH_PATH"`
echo $HASH_CONTENT
function MAIN {
if ! $CI; then
REBUILD_ELECTRON_NATIVE_DEPS
fi
}
function SET_HASH {
HASH_NAME=$1
HASH_CONTENT=$2
echo "setting hash $HASH_NAME to $HASH_CONTENT"
HASH_PATH=`GET_HASH_PATH $HASH_NAME`
mkdir -p ./node_modules/.cache
echo $HASH_CONTENT > $HASH_PATH
INSTALL_FLOW_TYPED
}
function INSTALL_FLOW_TYPED {

Loading…
Cancel
Save