Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build suite #141

Closed
wants to merge 13 commits into from
Closed
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\.~tmp*/
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions generate-inventory.sh
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/smoke-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tests/smoke-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"comment": "This satisifies the onbuild triggers"
}
86 changes: 86 additions & 0 deletions tests/smoke-tests/smoke_test.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/versions/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tests/versions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"comment": "This satisifies the onbuild triggers"
}