diff --git a/.travis.yml b/.travis.yml index 6d4fdd5a6..f32210e54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,8 +40,7 @@ env: - NODE_VERSION=10.16.0 COMMAND=clean - NODE_VERSION=10.16.0 COMMAND=build-devenv #- NODE_VERSION=10.16.0 COMMAND=run-devenv - # TODO Add unit test command(s) - #- NODE_VERSION=10.16.0 COMMAND=test + - NODE_VERSION=10.16.0 COMMAND=test-devenv - NODE_VERSION=10.16.0 COMMAND=build-release - NODE_VERSION=10.16.0 COMMAND=build-release-frontend - NODE_VERSION=10.16.0 COMMAND=build-release-backend diff --git a/backend/scripts/build-tests.sh b/backend/scripts/build-tests.sh new file mode 100644 index 000000000..9946c9e6b --- /dev/null +++ b/backend/scripts/build-tests.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +echo "Not yet implemented!" + +# TODO +#lein test diff --git a/frontend/package.json b/frontend/package.json index d6966af89..82ffe5b85 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,6 +17,8 @@ "dist:assets": "gulp dist", "prod": "gulp dist --production", "start": "npm run figwheel", + "build:main": "clojure -Adev tools.clj build main", + "build:view": "clojure -Adev tools.clj build view", "build:worker": "clojure -Adev tools.clj build worker", "figwheel": "clojure -Adev tools.clj figwheel" }, diff --git a/frontend/scripts/build-tests.sh b/frontend/scripts/build-tests.sh new file mode 100644 index 000000000..88d39adbb --- /dev/null +++ b/frontend/scripts/build-tests.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +source ~/.bashrc + +npm install +npm run build:main || exit 1; +npm run build:view || exit 1; +npm run build:worker || exit 1; + +# TODO +#node ./out/tests.js diff --git a/manage.sh b/manage.sh index 3a864eab9..9a8e2abfa 100755 --- a/manage.sh +++ b/manage.sh @@ -49,6 +49,53 @@ function run-devenv { $CONTAINER } +function test-devenv { + echo "Testing frontend..." + test-devenv-frontend || exit 1; + echo "Testing backend..." + test-devenv-backend || exit 1; +} + +function test-devenv-frontend { + # TODO Add frontend unit tests call + echo "Not yet implemented!" + +# if ! $(docker images | grep $IMGNAME | grep -q $REV); then +# build-devenv +# fi +# +# CONTAINER=$IMGNAME:latest +# +# echo "Running development image $CONTAINER to test backend..." +# docker run -ti --rm \ +# -w /home/uxbox/uxbox/backend \ +# -v `pwd`:/home/uxbox/uxbox \ +# -v $HOME/.m2:/home/uxbox/.m2 \ +# -e UXBOX_API_URL="/api" \ +# -e UXBOX_VIEW_URL="/view" \ +# $CONTAINER ./scripts/build-tests.sh +} + +function test-devenv-backend { + # TODO Add backend unit tests call + echo "Not yet implemented!" + +# if ! $(docker images | grep $IMGNAME | grep -q $REV); then +# build-devenv +# fi +# +# CONTAINER=$IMGNAME:latest +# +# echo "Running development image $CONTAINER to test frontend..." +# docker run -ti --rm \ +# -w /home/uxbox/uxbox/frontend \ +# -v `pwd`:/home/uxbox/uxbox \ +# -v $HOME/.m2:/home/uxbox/.m2 \ +# -e UXBOX_API_URL="/api" \ +# -e UXBOX_VIEW_URL="/view" \ +# $CONTAINER ./scripts/build-tests.sh +} + function build-release-frontend-local { if ! $(docker images | grep $IMGNAME | grep -q $REV); then build-devenv @@ -135,9 +182,9 @@ function usage { echo "- clean Stop and clean up docker containers" echo "- build-devenv Build docker container for development with tmux" echo "- run-devenv Run (and build if necessary) development container (frontend at localhost:3449, backend at localhost:6060)" - echo "- test Execute unit tests for both backend and frontend" - echo "- test-frontend Execute unit tests for frontend only" - echo "- test-backend Execute unit tests for backend only" + echo "- test-devenv Execute unit tests for both backend and frontend" + echo "- test-devenv-frontend Execute unit tests for frontend only" + echo "- test-devenv-backend Execute unit tests for backend only" echo "- build-release Build 'production ready' docker images for both backend and frontend" echo "- build-release-frontend Build a 'production ready' docker images for frontend only" echo "- build-release-backend Build a 'production ready' docker images for backend only" @@ -155,14 +202,14 @@ case $1 in run-devenv) run-devenv ;; - test) - test + test-devenv) + test-devenv ;; - test-frontend) - test-frontend + test-devenv-frontend) + test-devenv-frontend ;; - test-backend) - test-backend + test-devenv-backend) + test-devenv-backend ;; build-release) build-release