From 67e054c5a7d94042dda26849537e9f63e32e6481 Mon Sep 17 00:00:00 2001 From: Nazar Serhiichuk <43041209+G1gg1L3s@users.noreply.github.com> Date: Sat, 10 Jun 2023 01:43:53 +0300 Subject: [PATCH] jsthemis: Downgrade mocha to ^7 for Centos7 (#1003) * jsthemis: Downgrade mocha to ^7 This version and all its transitive dependencies support node v8 which is the only version we can run on centos 7. It seems like other OS work fine, at least on buildbot. Another option is to fix our scripts on buildbot just for centos 7 so they patch the versions before testing. This may save us from future problems. However, downgrading dev dependency is not that scary, so maybe this approach is okay. * jsthemis: Downgrade mocha on centos 7 Add a separate script for that. It will be caled during make test. * Revert "jsthemis: Downgrade mocha to ^7" This reverts commit 0e7df2e87c0dcfab85819610542efdf45aa67f6d. --------- Co-authored-by: Lagovas --- .../jsthemis/install_centos7_specific_deps.sh | 16 ++++++++++++++++ src/wrappers/themis/jsthemis/package.json | 3 ++- tests/test.mk | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 src/wrappers/themis/jsthemis/install_centos7_specific_deps.sh diff --git a/src/wrappers/themis/jsthemis/install_centos7_specific_deps.sh b/src/wrappers/themis/jsthemis/install_centos7_specific_deps.sh new file mode 100755 index 000000000..ccf6561be --- /dev/null +++ b/src/wrappers/themis/jsthemis/install_centos7_specific_deps.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# centos:7 has pretty old Node (v8) which is not supported by many packages, +# including mocha - test framework that we use. Therefore, we need to downgrade +# it for testing. The addon itself works fine, we just cannot test it without +# this patch. + + +set -e -o pipefail + +OS=$(cat /etc/*-release | grep '^NAME' | tr -d 'NAME="' || true) +VERSION=$(cat /etc/*-release | grep '^VERSION_ID' | tr -d 'VERSION_ID="' || true) + +if [[ "$OS" == "CentOS Linux" && "$VERSION" == "7" ]]; then + npm install mocha@7 --save-dev +fi diff --git a/src/wrappers/themis/jsthemis/package.json b/src/wrappers/themis/jsthemis/package.json index 2510c2bdc..4f968edc0 100644 --- a/src/wrappers/themis/jsthemis/package.json +++ b/src/wrappers/themis/jsthemis/package.json @@ -5,7 +5,8 @@ "main": "build/Release/jsthemis.node", "scripts": { "test": "mocha", - "preuninstall": "rm -rf build/*" + "preuninstall": "rm -rf build/*", + "install_centos7_specific_deps": "./install_centos7_specific_deps.sh" }, "repository": { "type": "git", diff --git a/tests/test.mk b/tests/test.mk index a3485bcc1..ca5bfe22a 100644 --- a/tests/test.mk +++ b/tests/test.mk @@ -148,7 +148,7 @@ ifdef NPM_VERSION @echo "Running jsthemis tests." @echo "In case of errors, see https://docs.cossacklabs.com/themis/languages/nodejs/" @echo "------------------------------------------------------------" - cd $(JSTHEMIS_SRC) && npm install && npm test + cd $(JSTHEMIS_SRC) && npm run install_centos7_specific_deps && npm install && npm test @echo "------------------------------------------------------------" endif