From 208f0f021238131354f79a53dd3a3daafe0d3095 Mon Sep 17 00:00:00 2001 From: Romain Date: Sat, 25 Nov 2017 22:01:30 +1100 Subject: [PATCH] Run full integration tests inside Docker. Travis runs unit + integration. --- .dockerignore | 1 + .travis.yml | 16 +++++++++++++++- Dockerfile | 19 ++++++++----------- package.json | 5 +++-- scripts/cibuild | 21 ++++----------------- test-integration/{snapshot.sh => snapshot} | 2 +- test-integration/{test.sh => test} | 2 +- 7 files changed, 33 insertions(+), 33 deletions(-) rename test-integration/{snapshot.sh => snapshot} (76%) rename test-integration/{test.sh => test} (91%) diff --git a/.dockerignore b/.dockerignore index 3c3629e..f4874aa 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ node_modules +test-integration/output-actual diff --git a/.travis.yml b/.travis.yml index 62622df..2dd262d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,19 @@ +# Run unit tests on several versions of Node language: node_js node_js: - '6' - '8' -script: scripts/cibuild + +# Also require docker for the integration tests +sudo: required +services: + - docker + +jobs: + include: + # After unit tests pass on all version of Node + # run the integration tests + - stage: Integration tests + script: + - docker pull thumbsupgallery/build:alpine + - docker build . diff --git a/Dockerfile b/Dockerfile index c9ba699..ee3f250 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,10 @@ -# Node.js runtime -FROM node:8-alpine +# Node.js + build depdencies + runtime dependencies +FROM thumbsupgallery/build:alpine -# Cache all the binary dependencies first -RUN apk add --update ffmpeg graphicsmagick exiftool +# Install and cache dependencies +COPY package.json /app +RUN npm install -# Install thumbsup globally -ARG THUMBSUP_VERSION=2.x.x -RUN npm install -g thumbsup@${THUMBSUP_VERSION} - -# Default command is thumbsup itself, so we can run -# > docker run thumbsupgallery/thumbsup --input [...] --output [...] -CMD ["thumbsup"] +# Run the tests +COPY . /app +RUN scripts/cibuild diff --git a/package.json b/package.json index 7a7108e..cf7376a 100644 --- a/package.json +++ b/package.json @@ -18,12 +18,13 @@ "type": "git", "url": "https://github.com/thumbsup/thumbsup.git" }, + "main": "bin/thumbsup.js", "bin": { "thumbsup": "./bin/thumbsup.js" }, "scripts": { - "test": "./scripts/cibuild", - "test-only": "mocha" + "pkglint": "require-lint --ignore-extra lightgallery --ignore-extra video.js", + "test": "standard && npm run pkglint && mocha" }, "dependencies": { "async": "^2.5.0", diff --git a/scripts/cibuild b/scripts/cibuild index 30d2eb7..117792d 100755 --- a/scripts/cibuild +++ b/scripts/cibuild @@ -3,27 +3,14 @@ # Fail the build on any error set -eou pipefail -# Make sure binary package.json dependencies are available -PATH=$(pwd)/node_modules/.bin:$PATH - -echo "--- Check all dependencies in package.json" -require-lint --src bin/thumbsup.js --ignore-extra lightgallery --ignore-extra video.js - -echo "--- Static code analysis" -standard +echo "--- Run unit tests" +npm test echo "--- Verify lightgallery dependency is built in" grep \"lightgallery\" package.json 1>/dev/null -echo "--- Run unit tests" -mocha - -echo "--- Update CLI arguments in README" -./scripts/readme - -# TODO: add all dependencies like if we want this to run on Travis CI -# echo "--- Running integration tests" -# ./test-integration/test.sh +echo "--- Comparing gallery snapshot" +./test-integration/test echo "================" echo "Build successful" diff --git a/test-integration/snapshot.sh b/test-integration/snapshot similarity index 76% rename from test-integration/snapshot.sh rename to test-integration/snapshot index afb8ab4..6e21766 100755 --- a/test-integration/snapshot.sh +++ b/test-integration/snapshot @@ -12,4 +12,4 @@ function finish { rm -rf output-expected # run thumbsup -thumbsup --config config.json --output output-expected +node ../bin/thumbsup.js --config config.json --output output-expected diff --git a/test-integration/test.sh b/test-integration/test similarity index 91% rename from test-integration/test.sh rename to test-integration/test index 3eef065..9d71064 100755 --- a/test-integration/test.sh +++ b/test-integration/test @@ -12,7 +12,7 @@ function finish { rm -rf output-actual # run thumbsup -thumbsup --config config.json --output output-actual +node ../bin/thumbsup.js --config config.json --output output-actual # compare albums with the snapshot for expected in output-expected/*.html; do