diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..58c7840512 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +\.~tmp*/ diff --git a/.travis.yml b/.travis.yml index 850ae39ea1..d31d22094b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,14 @@ sudo: required services: - docker - + +before_install: + - sudo wget -O /usr/bin/dante https://github.com/retrohacker/dante/releases/download/2.1.0/dante-linux-amd64 + - sudo chmod +x /usr/bin/dante + +before_script: + - ./generate-inventory.sh + - cat inventory.yml + script: - - ./test-build.sh + - dante test -j 4 diff --git a/generate-inventory.sh b/generate-inventory.sh new file mode 100755 index 0000000000..85eec45837 --- /dev/null +++ b/generate-inventory.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +INVENTORY="images:" + +gen_entry () { + INVENTORY=$INVENTORY" + - name: \"node:$2\" + path: \"$1\" + test: [\"./tests/smoke-tests/\",\"./tests/versions\"]" +} + +for version in $(find . -name '[0-9]*\.[0-9]*' -type d); do + for dir in $(find "$version" -type d); do + tag=$(echo "$dir" | sed 's/\.\///' | sed 's/\//-/') + gen_entry "$dir" "$tag" + done +done + +echo -e "$INVENTORY" > inventory.yml diff --git a/tests/smoke-tests/Dockerfile b/tests/smoke-tests/Dockerfile new file mode 100644 index 0000000000..d329221a28 --- /dev/null +++ b/tests/smoke-tests/Dockerfile @@ -0,0 +1,15 @@ +RUN apt-get update \ + && apt-get install -y --force-yes --no-install-recommends\ + git \ + ca-certificates \ + build-essential \ + ssh-client \ + && rm -rf /var/lib/apt/lists/*; + +ENV NODE_ENV dev +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app +RUN npm config set spin=false +ADD ./smoke_test.sh ./smoke_test.sh +RUN chmod +x ./smoke_test.sh +RUN ./smoke_test.sh diff --git a/tests/smoke-tests/package.json b/tests/smoke-tests/package.json new file mode 100644 index 0000000000..c0ca188ac8 --- /dev/null +++ b/tests/smoke-tests/package.json @@ -0,0 +1,3 @@ +{ + "comment": "This satisifies the onbuild triggers" +} diff --git a/tests/smoke-tests/smoke_test.sh b/tests/smoke-tests/smoke_test.sh new file mode 100755 index 0000000000..55219cb0cc --- /dev/null +++ b/tests/smoke-tests/smoke_test.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# ============================================================================= +# +# smoke_test.sh +# +# This script clones down a set of popular npm packages and runs their unit +# tests. This can be used to help verify a stable Node and npm install. +# +# ============================================================================= + +# Define a set of tuples that are used to clone npm projects for testing +# Note: Bash doesn't suppor tuples, so we have 4 arrays. +REPOS=( + "https://github.com/caolan/async" + "https://github.com/tj/commander.js" + "https://github.com/substack/node-mkdirp" + "https://github.com/rvagg/through2" + "https://github.com/isaacs/node-glob" + "https://github.com/broofa/node-uuid" + "https://github.com/cheeriojs/cheerio" + "https://github.com/kriskowal/q" +) + +BRANCHES=( + "2.x" + "master" + "master" + "master" + "master" + "master" + "master" + "v1" +) + +DIRS=( + "async" + "commander" + "mkdirp" + "through2" + "glob" + "uuid" + "cheerio" + "q" +) + +TESTS=( + "nodeunit-test" + "test" + "test" + "test" + "test" + "test" + "test" + "test" +) + +# Keep track of where we started before we cd around +CWD=$PWD + +# Iterate through all tuples in the set defined above +for i in `seq 3 $(expr ${#REPOS[@]} - 1)`; do + # Break tuple apart into components + REPO=${REPOS[$i]} + BRANCH=${BRANCHES[$i]} + DIR=${DIRS[$i]} + TEST=${TESTS[$i]} + + # Clone an npm package from github, install its deps, and then test it. + echo "--> Cloning $DIR" + git clone --recursive --depth 1 --branch $BRANCH $REPO $DIR + cd $DIR + echo "--> Setting up $DIR" + install_log=$(npm install 2>&1) + if [ $? -ne 0 ]; then + echo -e "$install_log" + exit 1 + fi + echo "--> Testing $DIR" + # Only log error if tests fail + run_log=$(npm run "$TEST" 2>&1) + if [ $? -ne 0 ]; then + echo -e "$run_log" + exit 1 + fi + cd $CWD +done diff --git a/tests/versions/Dockerfile b/tests/versions/Dockerfile new file mode 100644 index 0000000000..e98824683b --- /dev/null +++ b/tests/versions/Dockerfile @@ -0,0 +1,6 @@ +# This simply documents the versions of Node.js and npm installed, along with +# the versions of the linked library availble to the runtime. This provides +# an audit trail for buggy builds +RUN node -v +RUN node -p "process.versions" +RUN npm --version diff --git a/tests/versions/package.json b/tests/versions/package.json new file mode 100644 index 0000000000..c0ca188ac8 --- /dev/null +++ b/tests/versions/package.json @@ -0,0 +1,3 @@ +{ + "comment": "This satisifies the onbuild triggers" +}