This repository has been archived by the owner on Apr 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented NodeJS compatibility test. (#128)
* Implemented NodeJS compatibility test. * Moved compatibility testing scripts to `tools/nodejs_compatibility_checker` * Implemented quick compatibility checking. * Updated CircleCI config to use quick compatibility checking. * Improved compatibility test failure detection. * Improved compatibility test reporting. * Fixed code style for compatibility test scripts. * Fixed code style for "test_compatibility_setup.sh". * Implement NodeJS compatibility test
- Loading branch information
1 parent
78f61fe
commit c995eda
Showing
5 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
[ ! -e ~/.envirius/nv ] && echo 'Error: envirius is not installed!' && exit 1 | ||
[ ! -e nodes_available.log ] && echo 'Error: no environments available!' && exit 1 | ||
|
||
export TERM="dumb" | ||
source ~/.envirius/nv | ||
node_versions=$(cat nodes_available.log) | ||
|
||
# Run the tests on all available versions | ||
for version in ${node_versions}; do | ||
echo "Testing node-${version}!"; | ||
nv activate --same-shell "node-${version}" | ||
npm test >"test_node_${version}.log" 2>&1 | ||
if [ $? -eq 0 ]; then | ||
echo "PASSED" | ||
echo ${version} >> nodes_passed.log | ||
else | ||
echo "FAILED" | ||
fi | ||
nv deactivate | ||
done | ||
|
||
# Determine failed versions and display the test-run | ||
failed=$(comm -23 <(sort nodes_available.log) <(sort nodes_passed.log)) | ||
if [ -z "${failed}" ]; then | ||
echo "Build is compatible with all major node versions!" | ||
exit 0 | ||
fi | ||
|
||
echo "Build is incompatible with the following node versions:" | ||
echo "${failed}" | ||
for version in ${failed}; do | ||
echo "***Started test-run for ${version}***"; | ||
cat "test_node_${version}.log"; | ||
echo "***Finished test-run for ${version}***"; | ||
done | ||
exit 1 |
13 changes: 13 additions & 0 deletions
13
tools/nodejs_compatibility_checker/test_compatibility_cache.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
[ ! -e ~/.envirius/nv ] && echo 'Error: envirius is not installed!' && exit 1 | ||
[ ! -e nodes_available.log ] && echo 'Error: no environments available!' && exit 1 | ||
|
||
export TERM="dumb" | ||
source ~/.envirius/nv | ||
node_versions=$(cat nodes_available.log) | ||
|
||
# Cache NodeJS environments | ||
for version in ${node_versions}; do | ||
echo "Adding NodeJS ${version} into environment cache!" && \ | ||
nv mk "node-${version}" --node-prebuilt=${version} | ||
done |
36 changes: 36 additions & 0 deletions
36
tools/nodejs_compatibility_checker/test_compatibility_setup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
export TERM="dumb" | ||
|
||
# Install envirius | ||
git clone --depth 1 https://github.com/ekalinin/envirius.git && \ | ||
cd envirius && \ | ||
make install && \ | ||
cd .. && \ | ||
source ~/.envirius/nv | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Unable to install envirius!" | ||
exit 1 | ||
fi | ||
|
||
# Determine available node versions | ||
node_versions=$(nv ls-versions --node-prebuilt | sed 's/\s/\n/g' | grep -E '^[1-9]') | ||
if [ -z "${node_versions}" ]; then | ||
echo "Unable to determine node versions!" | ||
exit 1 | ||
fi | ||
|
||
# Quick check | ||
if [ "$1" == "--quick" ]; then | ||
lts_versions=$( | ||
for lts in 4 6 8 9; do | ||
echo "${node_versions}" | grep -E "^${lts}" | tail -1 | ||
done | ||
) | ||
node_versions=${lts_versions} | ||
fi | ||
|
||
# Dump available versions to file | ||
for version in ${node_versions}; do | ||
echo ${version} >> nodes_available.log | ||
done |