forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:ccxt/ccxt into binanceEditOrderFu…
…tures
- Loading branch information
Showing
66 changed files
with
3,641 additions
and
1,010 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
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,117 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ "${BASH_VERSION:0:1}" -lt 4 ]; then | ||
echo "EPROGMISMATCH: bash version must be at least 4" >&2 | ||
exit 75 | ||
fi | ||
|
||
if [ $# -gt 0 ]; then | ||
echo "E2BIG: too many arguments" >&2 | ||
exit 7 | ||
fi | ||
|
||
function run_tests { | ||
local rest_args= | ||
local ws_args= | ||
if [ $# -eq 2 ]; then | ||
rest_args="$1" | ||
ws_args="$2" | ||
if [ -z "$rest_args" ]; then | ||
: & | ||
local rest_pid=$! | ||
fi | ||
if [ -z "$ws_args" ]; then | ||
: & | ||
local ws_pid=$! | ||
fi | ||
fi | ||
|
||
if [ -z "$rest_pid" ]; then | ||
if [[ -z "$rest_args" ]] || { [[ -n "$rest_args" ]] && [[ $rest_args != "skip" ]]; }; then | ||
# shellcheck disable=SC2086 | ||
node test-commonjs.cjs && node run-tests --js --python-async --php-async $rest_args & | ||
local rest_pid=$! | ||
fi | ||
fi | ||
if [ -z "$ws_pid" ]; then | ||
if [[ -z "$ws_args" ]] || { [[ -n "$ws_args" ]] && [[ $ws_args != "skip" ]]; }; then | ||
# shellcheck disable=SC2086 | ||
node run-tests-ws --js --python-async --php-async $ws_args & | ||
local ws_pid=$! | ||
fi | ||
fi | ||
|
||
if [ -n "$rest_pid" ]; then | ||
wait $rest_pid | ||
fi | ||
|
||
if [ -n "$ws_pid" ]; then | ||
wait $ws_pid | ||
fi | ||
} | ||
|
||
build_and_test_all () { | ||
npm run force-build | ||
npm run test-base | ||
npm run test-base-ws | ||
run_tests | ||
exit | ||
} | ||
|
||
### CHECK IF THIS IS A PR ### | ||
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then | ||
echo "not a PR, will build everything" | ||
build_and_test_all | ||
fi | ||
|
||
##### DETECT CHANGES ##### | ||
diff=$(git diff origin/master --name-only) | ||
diff=$(echo "$diff" | sed -e "s/^build.sh//") # temporarily remove this script from diff | ||
|
||
critical_pattern='Client(Trait)?\.php|Exchange\.php|\/test|\/base|^build|static_dependencies|^run-tests|package(-lock)?\.json|ccxt\.ts|__init__.py' | ||
if [[ "$diff" =~ $critical_pattern ]]; then | ||
echo "detected critical change, will build/test everything" | ||
build_and_test_all | ||
fi | ||
|
||
echo "detected non-critical change, will build/test specific exchanges" | ||
readarray -t y <<<"$diff" | ||
rest_pattern='ts\/src\/([A-Za-z0-9_-]+).ts' # \w not working for some reason | ||
ws_pattern='ts\/src\/pro\/([A-Za-z0-9_-]+)\.ts' | ||
|
||
REST_EXCHANGES=() | ||
WS_EXCHANGES=() | ||
for file in "${y[@]}"; do | ||
if [[ "$file" =~ $rest_pattern ]]; then | ||
modified_exchange="${BASH_REMATCH[1]}" | ||
REST_EXCHANGES+=($modified_exchange) | ||
elif [[ "$file" =~ $ws_pattern ]]; then | ||
modified_exchange="${BASH_REMATCH[1]}" | ||
WS_EXCHANGES+=($modified_exchange) | ||
fi | ||
done | ||
|
||
### BUILD SPECIFIC EXCHANGES ### | ||
npm run pre-transpile | ||
echo "REST_EXCHANGES TO BE TRANSPILED: ${REST_EXCHANGES[@]}" | ||
for exchange in "${REST_EXCHANGES[@]}"; do | ||
node build/transpile.js $exchange --force --child | ||
done | ||
echo "WS_EXCHANGES TO BE TRANSPILED: ${WS_EXCHANGES[@]}" | ||
for exchange in "${WS_EXCHANGES[@]}"; do | ||
node build/transpileWS.js $exchange --force --child | ||
done | ||
npm run post-transpile | ||
|
||
### RUN SPECIFIC TESTS ### | ||
if [ ${#REST_EXCHANGES[@]} -eq 0 ] && [ ${#WS_EXCHANGES[@]} -eq 0 ]; then | ||
echo "no exchanges to test, exiting" | ||
exit | ||
fi | ||
|
||
# rest_args=${REST_EXCHANGES[*]} || "skip" | ||
rest_args=$(IFS=" " ; echo "${REST_EXCHANGES[*]}") || "skip" | ||
# ws_args=${WS_EXCHANGES[*]} || "skip" | ||
ws_args=$(IFS=" " ; echo "${WS_EXCHANGES[*]}") || "skip" | ||
|
||
run_tests "$rest_args" "$ws_args" |
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
Oops, something went wrong.