Skip to content

Commit

Permalink
[dev/ci_setup] generalize jenkins_setup script for other CI environme…
Browse files Browse the repository at this point in the history
…nts (#15178)

* [dev/ci_setup] generalize jenkins_setup script for other CI environments

* [dev/ci_setup] accept more general `CACHE_DIR` env arg

* [dev/ci_setup] node.js install might not be invalid
  • Loading branch information
spalger committed Nov 30, 2017
1 parent a6b4183 commit 9991263
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 42 deletions.
53 changes: 53 additions & 0 deletions src/dev/ci_setup/setup.sh
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

set -e

dir="$(pwd)"
cacheDir="${CACHE_DIR:-"/tmp/kibana"}"


###
### check that we seem to be in a kibana project
###
if [ -f "$dir/package.json" ] && [ -f "$dir/.node-version" ]; then
echo "Setting up node.js and npm in $dir"
else
echo "src/dev/ci_setup/setup.sh must be run within a kibana repo"
exit 1
fi


###
### download node
###
nodeVersion="$(cat $dir/.node-version)"
nodeUrl="https://nodejs.org/download/release/v$nodeVersion/node-v$nodeVersion-linux-x64.tar.gz"
nodeDir="$cacheDir/node/$nodeVersion"
echo " -- node: version=v${nodeVersion} dir=$nodeDir"

echo " -- setting up node.js"
if [ -x "$nodeDir/bin/node" ] && [ "$($nodeDir/bin/node --version)" == "v$nodeVersion" ]; then
echo " -- reusing node.js install"
else
if [ -d "$nodeDir" ]; then
echo " -- clearing previous node.js install"
rm -rf "$nodeDir"
fi

echo " -- downloading node.js from $nodeUrl"
mkdir -p "$nodeDir"
curl --silent "$nodeUrl" | tar -xz -C "$nodeDir" --strip-components=1
fi


###
### "install" node by extending the path with it's bin directory
###
export PATH="$nodeDir/bin:$PATH"


###
### install dependencies
###
echo " -- installing node.js dependencies"
npm install --cache "$cacheDir/npm"
39 changes: 0 additions & 39 deletions test/scripts/_jenkins_setup.sh

This file was deleted.

2 changes: 1 addition & 1 deletion test/scripts/jenkins_docs.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
source "$(dirname $0)/_jenkins_setup.sh"
source "$(dirname $0)/../../src/dev/ci_setup/setup.sh"

"$(npm bin)/grunt" jenkins:docs;
2 changes: 1 addition & 1 deletion test/scripts/jenkins_selenium.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

set -e
source "$(dirname $0)/_jenkins_setup.sh"
source "$(dirname $0)/../../src/dev/ci_setup/setup.sh"

"$(npm bin)/grunt" build --release;

Expand Down
2 changes: 1 addition & 1 deletion test/scripts/jenkins_unit.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
source "$(dirname $0)/_jenkins_setup.sh"
source "$(dirname $0)/../../src/dev/ci_setup/setup.sh"

xvfb-run "$(npm bin)/grunt" jenkins:unit;

0 comments on commit 9991263

Please sign in to comment.