From 9f5cea5f9988f7fb14c1205fc961fbc99fb11a26 Mon Sep 17 00:00:00 2001 From: Markus Danek Date: Tue, 9 May 2017 10:17:37 +0200 Subject: [PATCH] TT#15811 Add Dockerfile and testrunner script Change-Id: I2d98537b0ae1de294e72dd611750133834101ffe --- package.json | 6 +++--- t/Dockerfile | 45 +++++++++++++++++++++++++++++++++++++++++++++ t/testrunner | 22 ++++++++++++++++++++++ 3 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 t/Dockerfile create mode 100755 t/testrunner diff --git a/package.json b/package.json index 0825948..6b3ddd0 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "janus-admin", - "version": "1.0.3", + "version": "1.0.4", "main": "src/admin.js", "scripts": { - "test": "mocha -R spec", - "test-dev": "mocha -R spec -w" + "test": "mocha -R spec --full-trace test/*-spec.js", + "test-dev": "mocha -R spec -w test/*-spec.js" }, "author": "Hans-Peter Herzog ", "license": "GPL-3.0", diff --git a/t/Dockerfile b/t/Dockerfile new file mode 100644 index 0000000..29759ea --- /dev/null +++ b/t/Dockerfile @@ -0,0 +1,45 @@ +# DOCKER_NAME=janus-admin-jessie +FROM docker.mgm.sipwise.com/sipwise-jessie:latest + +# Important! Update this no-op ENV variable when this Dockerfile +# is updated with the current date. It will force refresh of all +# of the base images and things like `apt-get update` won't be using +# old cached versions when the Dockerfile is built. +ENV REFRESHED_AT 2017-05-09 + +# TODO - the release-trunk-jessie is too dynamic yet, though required build deps +RUN echo "deb https://deb.sipwise.com/autobuild/ release-trunk-jessie main" >>/etc/apt/sources.list + +RUN apt-get update +RUN apt-get install --assume-yes \ + curl \ + nodejs + +ADD package.json /tmp/ +ADD npm-shrinkwrap.json /tmp/ +ADD README.md /tmp/ + +WORKDIR /tmp + +RUN npm install /tmp + +RUN echo "cd /code && ./t/testrunner" >/root/.bash_history + +WORKDIR /code + +################################################################################ +# Instructions for usage +# ---------------------- +# When you want to build the base image from scratch (jump to the next section if you don't want to build yourself!): +# NOTE: run the following commands from root folder of git repository: +# % docker build --tag="janus-admin-jessie" -f ./t/Dockerfile . +# % docker run --rm -i -t -v $(pwd):/code:ro -v /results janus-admin-jessie:latest bash +# +# Use the existing docker image: +# % docker pull docker.mgm.sipwise.com/janus-admin-jessie +# NOTE: run the following command from root folder of git repository: +# % docker run --rm -i -t -v $(pwd):/code:ro -v /results docker.mgm.sipwise.com/janus-admin-jessie:latest bash +# +# Inside docker: +# cd /code && ./t/testrunner +################################################################################ diff --git a/t/testrunner b/t/testrunner new file mode 100755 index 0000000..6a29c14 --- /dev/null +++ b/t/testrunner @@ -0,0 +1,22 @@ +#!/bin/bash + +if ! [ -f /.dockerenv ] && ! grep -q 'devices:/docker' /proc/1/cgroup ; then + echo "Not running inside docker, exiting to avoid data damage." >&2 + exit 1 +fi + +set -e +set -u + +echo "### Copying and moving files" +cp -Rf . /tmp/code +ln -s /tmp/node_modules /tmp/code/node_modules +cd /tmp/code/ + +echo "################################################################################" +echo "Finished main setup, now running tests ..." + +npm test + +echo "Finished test execution, test execution returned with exit code." +echo "################################################################################"