From 36222b6e5880e361026ddf0bc7af3c2e5a64e3bb Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 4 Dec 2018 03:59:54 -0800 Subject: [PATCH] Cache Elasticsearch on Travis --- .travis.yml | 6 ++++-- test/ci/before_install.sh | 17 ----------------- test/ci/install_elasticsearch.sh | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 19 deletions(-) delete mode 100755 test/ci/before_install.sh create mode 100755 test/ci/install_elasticsearch.sh diff --git a/.travis.yml b/.travis.yml index 1f7e436..352c6f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,11 @@ services: - redis-server script: bundle exec rake test before_install: - - gem install bundler - psql -c 'CREATE DATABASE searchkick_test;' -U postgres || true - - ./test/ci/before_install.sh + - ./test/ci/install_elasticsearch.sh +cache: + directories: + - $HOME/elasticsearch env: - ELASTICSEARCH_VERSION=6.5.0 jdk: oraclejdk8 diff --git a/test/ci/before_install.sh b/test/ci/before_install.sh deleted file mode 100755 index d182341..0000000 --- a/test/ci/before_install.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -e - -gem install bundler - -if [[ $ELASTICSEARCH_VERSION == 1* ]]; then - curl -L -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-$ELASTICSEARCH_VERSION.tar.gz -elif [[ $ELASTICSEARCH_VERSION == 2* ]]; then - curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/$ELASTICSEARCH_VERSION/elasticsearch-$ELASTICSEARCH_VERSION.tar.gz -else - curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_VERSION.tar.gz -fi -tar -xvf elasticsearch-$ELASTICSEARCH_VERSION.tar.gz -cd elasticsearch-$ELASTICSEARCH_VERSION/bin -./elasticsearch -d -wget -O- --waitretry=1 --tries=60 --retry-connrefused -v http://127.0.0.1:9200/ diff --git a/test/ci/install_elasticsearch.sh b/test/ci/install_elasticsearch.sh new file mode 100755 index 0000000..d80fefe --- /dev/null +++ b/test/ci/install_elasticsearch.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -e + +CACHE_DIR=$HOME/elasticsearch/$ELASTICSEARCH_VERSION + +if [ ! -d "$CACHE_DIR" ]; then + if [[ $ELASTICSEARCH_VERSION == 1* ]]; then + URL=https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-$ELASTICSEARCH_VERSION.tar.gz + elif [[ $ELASTICSEARCH_VERSION == 2* ]]; then + URL=https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/$ELASTICSEARCH_VERSION/elasticsearch-$ELASTICSEARCH_VERSION.tar.gz + else + URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_VERSION.tar.gz + fi + + wget $URL + tar xvfz elasticsearch-$ELASTICSEARCH_VERSION.tar.gz + mv elasticsearch-$ELASTICSEARCH_VERSION $CACHE_DIR +else + echo "Elasticsearch cached" +fi + +cd $CACHE_DIR +bin/elasticsearch -d +wget -O- --waitretry=5 --tries=12 --retry-connrefused -v http://127.0.0.1:9200/ -- libgit2 0.21.0