Skip to content

Commit

Permalink
update nodejs installation (#302)
Browse files Browse the repository at this point in the history
* fix nodejs integration tests to support node v4.6

* add 'jsthemis install/uninstall' command

* do not do extra jsthemis install while running tests

* use local jsthemis install for integration tests

* install node

* circle ci: run js tests with sudo

* use old nodejs for integration tests

* install as root
  • Loading branch information
vixentael authored and Lagovas committed Feb 1, 2018
1 parent 175a1b3 commit 4b64a02
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
12 changes: 7 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ jobs:
GOTHEMIS_IMPORT: github.com/cossacklabs/themis/gothemis
CFLAGS: "-DCIRICLE_TEST"
steps:
- run: sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libssl-dev python python-setuptools python3 python3-setuptools ruby-dev npm lcov libc6-dbg rsync software-properties-common
- run: sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libssl-dev python python-setuptools python3 python3-setuptools ruby-dev nodejs npm lcov libc6-dbg rsync software-properties-common
- run: sudo ln -sf /usr/bin/gcov-5 /usr/bin/gcov
- run: sudo ln -sf /usr/bin/nodejs /usr/bin/node
- run: sudo gem install coveralls-lcov
- run: go get github.com/mattn/goveralls
# ruby rvm repository
Expand Down Expand Up @@ -57,6 +58,7 @@ jobs:
- run: sudo make themispp_install
- run: sudo make pythemis_install
- run: sudo make rubythemis_install
- run: sudo make jsthemis_install

- restore_cache:
keys:
Expand All @@ -81,7 +83,7 @@ jobs:
- run: sudo /sbin/ldconfig
- run: make test
- run: make test_python
- run: make test_js
- run: sudo make test_js
# it's important to set version of ruby precisely.
- run: source /etc/profile.d/rvm.sh && rvm use system && make test_ruby
- run: make test_go
Expand All @@ -105,12 +107,12 @@ jobs:
steps:
# dependencies
- run: sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libssl-dev python python-setuptools python3 python3-setuptools ruby-dev lcov libc6-dbg rsync software-properties-common
# nodejs
- run: sudo DEBIAN_FRONTEND=noninteractive apt-get -y install nodejs npm
- run: sudo ln -sf /usr/bin/nodejs /usr/bin/node
# ruby rvm repository
- run: sudo apt-add-repository -y ppa:rael-gc/rvm
- run: sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get -y install rvm
# nodejs install (need to install fresh nodejs)
- run: cd $HOME && curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh && sudo bash nodesource_setup.sh && sudo apt-get -y install nodejs
# php7
- run: sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.0-dev php7.0-xml php7.0-mbstring

Expand All @@ -124,7 +126,7 @@ jobs:
- run: sudo make rubythemis_install
- run: sudo make phpthemis_install
- run: sudo bash -c 'echo "extension=phpthemis.so" > /etc/php/7.0/cli/conf.d/20-phpthemis.ini'
- run: npm install jsthemis
- run: sudo make jsthemis_install
- run: mkdir -p $HOME/go/src/$GOTHEMIS_IMPORT
- run: rsync -auv gothemis/ $HOME/go/src/$GOTHEMIS_IMPORT/

Expand Down
21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -383,24 +383,29 @@ for-audit: $(SOTER_AUD) $(THEMIS_AUD)


phpthemis_uninstall: CMD = if [ -e src/wrappers/themis/php/Makefile ]; then cd src/wrappers/themis/php && make distclean ; fi;

phpthemis_uninstall:
ifdef PHP_THEMIS_INSTALL
@echo -n "phpthemis uninstall "
@$(BUILD_CMD_)
endif

rubythemis_uninstall: CMD = gem uninstall themis

rubythemis_uninstall:
ifdef RUBY_GEM_VERSION
@echo -n "rubythemis uninstall "
@$(BUILD_CMD_)
endif

jsthemis_uninstall: CMD = rm -rf build/jsthemis-$(JSTHEMIS_PACKAGE_VERSION).tgz && npm uninstall jsthemis
jsthemis_uninstall:
ifdef NPM_VERSION
@echo -n "jsthemis uninstall "
@$(BUILD_CMD_)
endif

uninstall: CMD = rm -rf $(PREFIX)/include/themis && rm -rf $(PREFIX)/include/soter && rm -f $(PREFIX)/lib/libsoter.a && rm -f $(PREFIX)/lib/libthemis.a && rm -f $(PREFIX)/lib/libsoter.$(SHARED_EXT) && rm -f $(PREFIX)/lib/libthemis.$(SHARED_EXT)

uninstall: phpthemis_uninstall rubythemis_uninstall themispp_uninstall
uninstall: phpthemis_uninstall rubythemis_uninstall themispp_uninstall jsthemis_uninstall
@echo -n "themis uninstall "
@$(BUILD_CMD_)

Expand Down Expand Up @@ -432,6 +437,16 @@ else
@exit 1
endif

jsthemis_install: CMD = cd src/wrappers/themis/jsthemis && npm pack && mv jsthemis-$(JSTHEMIS_PACKAGE_VERSION).tgz ../../../../build && cd - && npm install nan && npm install ./build/jsthemis-0.9.6-4.tgz
jsthemis_install:
ifdef NPM_VERSION
@echo -n "jsthemis install "
@$(BUILD_CMD_)
else
@echo "Error: npm not found"
@exit 1
endif

pythemis_install: CMD = cd src/wrappers/themis/python/ && python2 setup.py install --record files.txt; python3 setup.py install --record files3.txt
pythemis_install:
ifeq ($(or $(PYTHON2_VERSION),$(PYTHON3_VERSION)),)
Expand Down
16 changes: 5 additions & 11 deletions tests/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,10 @@ ifdef PYTHON3_VERSION
endif
ifdef NPM_VERSION
@echo -n "make tests for jsthemis "
echo "cd ./tests/jsthemis/" > ./$(BIN_PATH)/tests/node.sh
echo "wget https://nodejs.org/dist/v4.6.0/node-v4.6.0-linux-x64.tar.gz" >> ./$(BIN_PATH)/tests/node.sh
echo "tar -xvf node-v4.6.0-linux-x64.tar.gz" >> ./$(BIN_PATH)/tests/node.sh
echo "cd ../../src/wrappers/themis/jsthemis && PATH=`pwd`/tests/jsthemis/node-v4.6.0-linux-x64/bin:$(PATH) npm pack && mv jsthemis-$(JSTHEMIS_PACKAGE_VERSION).tgz ../../../../build && cd -" >> ./$(BIN_PATH)/tests/node.sh
echo "PATH=`pwd`/tests/jsthemis/node-v4.6.0-linux-x64/bin:$(PATH) npm install mocha" >> ./$(BIN_PATH)/tests/node.sh
echo "PATH=`pwd`/tests/jsthemis/node-v4.6.0-linux-x64/bin:$(PATH) npm install nan" >> ./$(BIN_PATH)/tests/node.sh
echo "PATH=`pwd`/tests/jsthemis/node-v4.6.0-linux-x64/bin:$(PATH) npm install ../../build/jsthemis-$(JSTHEMIS_PACKAGE_VERSION).tgz" >> ./$(BIN_PATH)/tests/node.sh
echo "PATH=`pwd`/tests/jsthemis/node-v4.6.0-linux-x64/bin:$(PATH) ./node_modules/mocha/bin/mocha" >> ./$(BIN_PATH)/tests/node.sh
echo "PATH=`pwd`/tests/jsthemis/node-v4.6.0-linux-x64/bin:$(PATH) rm -rf ./node_modules" >> ./$(BIN_PATH)/tests/node.sh
chmod a+x ./$(BIN_PATH)/tests/node.sh
@echo "#!/bin/bash -e" > ./$(BIN_PATH)/tests/jsthemis_test.sh
@echo "npm install mocha" >> ./$(BIN_PATH)/tests/jsthemis_test.sh
@echo "$(shell npm root)/mocha/bin/mocha ./tests/jsthemis" >> ./$(BIN_PATH)/tests/jsthemis_test.sh
@chmod a+x ./$(BIN_PATH)/tests/jsthemis_test.sh
@$(PRINT_OK_)
endif

Expand Down Expand Up @@ -171,7 +165,7 @@ ifdef NPM_VERSION
@echo "Running jsthemis tests."
@echo "If any error, check https://github.com/cossacklabs/themis/wiki/NodeJS-Howto"
@echo "------------------------------------------------------------"
$(TEST_BIN_PATH)/node.sh
$(TEST_BIN_PATH)/jsthemis_test.sh
endif

test_go:
Expand Down
2 changes: 1 addition & 1 deletion tools/js/scell_seal_string_echo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var jsthemis = require('jsthemis');

if (![5, 6].includes(process.argv.length)) {
if (process.argv.length < 5 || process.argv.length > 6) {
console.log('Usage: <command: enc | dec > <key> <message> <context (optional)>');
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/js/scell_token_string_echo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var jsthemis = require('jsthemis');

if (![5, 6].includes(process.argv.length)) {
if (process.argv.length < 5 || process.argv.length > 6) {
console.log('Usage: <command: enc | dec > <key> <message> <context (optional)>');
process.exit(1);
}
Expand Down

0 comments on commit 4b64a02

Please sign in to comment.