Skip to content

Commit

Permalink
fix(CI): update Travis-CI
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink committed Nov 20, 2019
1 parent 39afc56 commit 7a3088f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
# Once openjdk/oraclejdk dependencies are resolved, change to dist: xenial
dist: trusty
dist: bionic
notifications:
email: false
node_js:
Expand All @@ -11,23 +10,21 @@ matrix:
fast_finish: true
env:
matrix:
- ES_VERSION=5.6.12
- ES_VERSION=5.6.12 JDK_VERSION=oraclejdk8
- ES_VERSION=5.6.12 JDK_VERSION=oraclejdk11
- ES_VERSION=6.8.4 JDK_VERSION=oraclejdk8
- ES_VERSION=6.8.4 JDK_VERSION=oraclejdk11
jdk:
- oraclejdk8
- oraclejdk11
install:
- mkdir /tmp/elasticsearch
- ./scripts/setup_ci.sh
- npm i
script:
- npm run travis
addons:
apt:
packages:
- oracle-java8-installer
before_install:
- npm i -g npm
before_script:
- sleep 10
- curl http://127.0.0.1:9200/
- ./bin/create_index
branches:
Expand Down
23 changes: 23 additions & 0 deletions scripts/elastic_wait.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function elastic_status(){
curl --output /dev/null --silent --write-out "%{http_code}" "http://${ELASTIC_HOST:-localhost:9200}" || true;
}

function elastic_wait(){
echo 'waiting for elasticsearch service to come up';
retry_count=30

i=1
while [[ "$i" -le "$retry_count" ]]; do
if [[ $(elastic_status) -eq 200 ]]; then
echo "Elasticsearch up!"
exit 0
fi
sleep 2
printf "."
i=$(($i + 1))
done

echo
echo "Elasticsearch did not come up, check configuration"
exit 1
}
13 changes: 12 additions & 1 deletion scripts/setup_ci.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/bash
set -e

# create elasticsearch directory
mkdir /tmp/elasticsearch

# allow switching the JDK version
curl -s https://raw.githubusercontent.com/michaelklishin/jdk_switcher/master/jdk_switcher.sh | bash -s use "${JDK_VERSION}"

# download and install elasticsearch with ICU plugin
# note: the download servers and plugin install binary changed between versions

Expand All @@ -25,9 +31,14 @@ else
/tmp/elasticsearch/bin/elasticsearch-plugin install analysis-icu

# start elasticsearch server
/tmp/elasticsearch/bin/elasticsearch --daemonize -Epath.data=/tmp -Edefault.path.data=/tmp -Ediscovery.type=single-node
/tmp/elasticsearch/bin/elasticsearch --daemonize -Epath.data=/tmp/elasticsearch -Ediscovery.type=single-node
fi

# wait for server to boot up
# logs show that on travis-ci it can take ~17s to boot an ES6 server
source "${BASH_SOURCE%/*}/elastic_wait.sh"
elastic_wait

# set the correct esclient.apiVersion in pelias.json
v=( ${ES_VERSION//./ } ) # split version number on '.'
echo "{\"esclient\":{\"apiVersion\":\"${v[0]}.${v[1]}\"}}" > ~/pelias.json
Expand Down

0 comments on commit 7a3088f

Please sign in to comment.