From ba677d7adaf4abf3652b7bac9f332c4f688cc221 Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 29 Dec 2022 16:34:43 +0000 Subject: [PATCH 01/24] tests-manager --- testTimestamp.json | 1 + tests-manager.js | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 testTimestamp.json create mode 100644 tests-manager.js diff --git a/testTimestamp.json b/testTimestamp.json new file mode 100644 index 000000000000..953f76293b9c --- /dev/null +++ b/testTimestamp.json @@ -0,0 +1 @@ +{"lastRun":1672331334109} \ No newline at end of file diff --git a/tests-manager.js b/tests-manager.js new file mode 100644 index 000000000000..4a0040739656 --- /dev/null +++ b/tests-manager.js @@ -0,0 +1,80 @@ +"use strict"; +const fs = require('fs'); +const { spawn } = require('child_process'); +const util = require('node:util'); +const { exit } = require('process'); +const execFile = util.promisify(require('node:child_process').execFile); +const log = require ('ololog').unlimited + +const TEST_TIMESTAMP = "./testTimestamp.json"; + +const testFile = require(TEST_TIMESTAMP); +const lastRun = testFile.lastRun; +const dayInMs = 3600000; +const currentTs = Date.now(); + +if (process.argv.length < 3) { + log.red("Required node command not provided"); + log.yellow("Example: node tests-manager.js run-tests-ws"); + exit(1); +} + +const COMMAND = process.argv[2]; + +const argv = process.argv +argv.splice(0,3); + +async function main() { + + if (false || (currentTs > dayInMs + lastRun)) { + // run all tests again + runCommand(argv) + } else { + const { stdout } = await execFile('git diff', ['--name-only'], { shell:true }); + + if (stdout.length === 0) { + return; + } + + const shouldRunEverything = stdout.indexOf("Exchange") > -1 || + stdout.indexOf("/test") > -1 || + stdout.indexOf("/build") > -1 || + stdout.indexOf("/base") > -1 || + stdout.indexOf("/static_dependencies") > -1 + stdout.indexOf("run-tests") > -1 + + if (shouldRunEverything) { + runCommand(argv) + } else { + const exchangeFiles = stdout.split("\n").filter(e => e && e.indexOf('js/') > -1 ).map(e=> e.split("/").pop()).map(e=> e.split(".")[0]); + // ignore examples and files like that + if (exchangeFiles.length > 0) { + const parsedArgs = exchangeFiles.concat(argv) + runCommand(parsedArgs, false) // when running some specific tests we shouldn't update ts + } + } + } +} + +function runCommand(args, updateTs = true) { + + const nodeCommand = "node " + COMMAND; + const pro = spawn(nodeCommand, args, { stdio: 'inherit', shell:true }) + + pro.on('exit', code => { + console.log("code", code) + if (code === 0 && updateTs) { + log.bright.green("All tests ran sucessfully, saving new timestamp!") + saveNewTS() + } else { + log.bright.red("Error running tests!") + } + }) +} + +function saveNewTS() { + testFile.lastRun = Date.now(); + fs.writeFileSync (TEST_TIMESTAMP, JSON.stringify(testFile)) +} + +main(); From bbf95035bdabe3c6030d7c0d531c758ed6f352d7 Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 29 Dec 2022 16:35:23 +0000 Subject: [PATCH 02/24] dummy change test --- js/bybit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/bybit.js b/js/bybit.js index 75b6ad387eb1..a547cb70f9ff 100644 --- a/js/bybit.js +++ b/js/bybit.js @@ -1215,7 +1215,7 @@ module.exports = class bybit extends Exchange { // "nextPageCursor": "" // }, // "retExtInfo": {}, - // "time": 1667533491917 + // "time": 1667533491916 // } // // option response From 1616fe9b69a96552c5f25549016c9ebdd15b0655 Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 29 Dec 2022 16:37:22 +0000 Subject: [PATCH 03/24] fix git command --- tests-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests-manager.js b/tests-manager.js index 4a0040739656..e169f5873d58 100644 --- a/tests-manager.js +++ b/tests-manager.js @@ -30,7 +30,7 @@ async function main() { // run all tests again runCommand(argv) } else { - const { stdout } = await execFile('git diff', ['--name-only'], { shell:true }); + const { stdout } = await execFile('git diff master', ['--name-only'], { shell:true }); if (stdout.length === 0) { return; From a14f1a8328efe5bcd0f802b29d5369fe7b5e9873 Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 29 Dec 2022 16:38:54 +0000 Subject: [PATCH 04/24] header --- tests-manager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests-manager.js b/tests-manager.js index e169f5873d58..4069317e519c 100644 --- a/tests-manager.js +++ b/tests-manager.js @@ -1,3 +1,7 @@ +// --------------------------------------------------------------------------- +// Usage: node tests-manager.js someNodeFile +// --------------------------------------------------------------------------- + "use strict"; const fs = require('fs'); const { spawn } = require('child_process'); From 3de713cbfd44f089588a15eb264146247649a273 Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 29 Dec 2022 16:39:43 +0000 Subject: [PATCH 05/24] update travis command --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f951de082edb..8953bd1cc8c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,9 +37,9 @@ script: - npm run test-base - npm run test-base-ws - pip list -- node run-tests --js --python-async --php-async 5 2>&1 & +- node tests-manager run-tests --js --python-async --php-async 5 2>&1 & - rest_pid=$! -- node run-tests-ws --js --python-async --php-async 5 2>&1 & +- node tests-manager run-tests-ws --js --python-async --php-async 5 2>&1 & - ws_pid=$! - wait $rest_pid - wait $ws_pid From 1e64b3dc72f55221d5c29a0d7e0cd88fe0b40979 Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 29 Dec 2022 16:42:04 +0000 Subject: [PATCH 06/24] push back file --- build/push.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/push.sh b/build/push.sh index f6e6f477ea6b..dc33bb5da5db 100755 --- a/build/push.sh +++ b/build/push.sh @@ -39,7 +39,7 @@ echo "Pushing generated files back to GitHub..." LAST_COMMIT_MESSAGE="$(git log --no-merges -1 --pretty=%B)" git config --global user.email "travis@travis-ci.org" git config --global user.name "Travis CI" -git add php/*.php php/async/*.php php/pro/*.php php/test/*.php python/ccxt/test/*.py python/ccxt/async_support/*.py python/ccxt/*.py python/ccxt/pro/*.py python/ccxt/pro/test/*.py python/ccxt/pro/test/exchange/*.py wiki/* +git add testTimestamp.json php/*.php php/async/*.php php/pro/*.php php/test/*.php python/ccxt/test/*.py python/ccxt/async_support/*.py python/ccxt/*.py python/ccxt/pro/*.py python/ccxt/pro/test/*.py python/ccxt/pro/test/exchange/*.py wiki/* git add -f python/LICENSE.txt python/package.json python/README.md git commit -a -m "${COMMIT_MESSAGE}" -m '[ci skip]' git tag -a "${COMMIT_MESSAGE}" -m "${LAST_COMMIT_MESSAGE}" -m "" -m "[ci skip]" From be95e6c1c6de5b1cd793052dad46d5e5651ed0aa Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 29 Dec 2022 16:45:21 +0000 Subject: [PATCH 07/24] remove debug flag --- tests-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests-manager.js b/tests-manager.js index 4069317e519c..4a87f55e8674 100644 --- a/tests-manager.js +++ b/tests-manager.js @@ -30,7 +30,7 @@ argv.splice(0,3); async function main() { - if (false || (currentTs > dayInMs + lastRun)) { + if (currentTs > dayInMs + lastRun) { // run all tests again runCommand(argv) } else { From 3f8895a4ac0c685b5d14f4913cccba182915d349 Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 29 Dec 2022 16:46:52 +0000 Subject: [PATCH 08/24] exit process fix --- tests-manager.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests-manager.js b/tests-manager.js index 4a87f55e8674..cec0449cdda5 100644 --- a/tests-manager.js +++ b/tests-manager.js @@ -67,9 +67,11 @@ function runCommand(args, updateTs = true) { pro.on('exit', code => { console.log("code", code) - if (code === 0 && updateTs) { - log.bright.green("All tests ran sucessfully, saving new timestamp!") - saveNewTS() + if (code === 0) { + if (updateTs) { + log.bright.green("All tests ran sucessfully, saving new timestamp!") + saveNewTS() + } } else { log.bright.red("Error running tests!") } From f48157ea0806d7b04d654eb47c57b895f1462d14 Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 09:00:45 -0800 Subject: [PATCH 09/24] fix day in milliseconds --- tests-manager.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests-manager.js b/tests-manager.js index cec0449cdda5..0aca385250df 100644 --- a/tests-manager.js +++ b/tests-manager.js @@ -14,7 +14,7 @@ const TEST_TIMESTAMP = "./testTimestamp.json"; const testFile = require(TEST_TIMESTAMP); const lastRun = testFile.lastRun; -const dayInMs = 3600000; +const dayInMs = 60 * 60 * 24 * 1000; const currentTs = Date.now(); if (process.argv.length < 3) { @@ -29,7 +29,7 @@ const argv = process.argv argv.splice(0,3); async function main() { - + if (currentTs > dayInMs + lastRun) { // run all tests again runCommand(argv) @@ -40,8 +40,8 @@ async function main() { return; } - const shouldRunEverything = stdout.indexOf("Exchange") > -1 || - stdout.indexOf("/test") > -1 || + const shouldRunEverything = stdout.indexOf("Exchange") > -1 || + stdout.indexOf("/test") > -1 || stdout.indexOf("/build") > -1 || stdout.indexOf("/base") > -1 || stdout.indexOf("/static_dependencies") > -1 From 22f73726760b8c93d7c2df2e9db94084cbc9aebc Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 29 Dec 2022 17:11:55 +0000 Subject: [PATCH 10/24] error exit --- tests-manager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests-manager.js b/tests-manager.js index cec0449cdda5..4332003441ca 100644 --- a/tests-manager.js +++ b/tests-manager.js @@ -74,6 +74,7 @@ function runCommand(args, updateTs = true) { } } else { log.bright.red("Error running tests!") + exit(1); } }) } From 066306ec0a444ef3e87bda083ba40786e4fdc479 Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 09:13:34 -0800 Subject: [PATCH 11/24] change to 3 hours --- tests-manager.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests-manager.js b/tests-manager.js index 0aca385250df..629f15263e95 100644 --- a/tests-manager.js +++ b/tests-manager.js @@ -14,7 +14,7 @@ const TEST_TIMESTAMP = "./testTimestamp.json"; const testFile = require(TEST_TIMESTAMP); const lastRun = testFile.lastRun; -const dayInMs = 60 * 60 * 24 * 1000; +const threeHours = 60 * 60 * 3 * 1000; const currentTs = Date.now(); if (process.argv.length < 3) { @@ -30,7 +30,7 @@ argv.splice(0,3); async function main() { - if (currentTs > dayInMs + lastRun) { + if (currentTs > threeHours + lastRun) { // run all tests again runCommand(argv) } else { @@ -40,21 +40,21 @@ async function main() { return; } - const shouldRunEverything = stdout.indexOf("Exchange") > -1 || - stdout.indexOf("/test") > -1 || - stdout.indexOf("/build") > -1 || - stdout.indexOf("/base") > -1 || - stdout.indexOf("/static_dependencies") > -1 - stdout.indexOf("run-tests") > -1 + const shouldRunEverything = stdout.indexOf ("Exchange") > -1 || + stdout.indexOf ("/test") > -1 || + stdout.indexOf ("/build") > -1 || + stdout.indexOf ("/base") > -1 || + stdout.indexOf ("/static_dependencies") > -1 || + stdout.indexOf ("run-tests") > -1 if (shouldRunEverything) { runCommand(argv) } else { - const exchangeFiles = stdout.split("\n").filter(e => e && e.indexOf('js/') > -1 ).map(e=> e.split("/").pop()).map(e=> e.split(".")[0]); + const exchangeFiles = stdout.split ("\n").filter (e => e && e.indexOf('js/') > -1 ).map(e=> e.split("/").pop()).map(e=> e.split(".")[0]); // ignore examples and files like that if (exchangeFiles.length > 0) { - const parsedArgs = exchangeFiles.concat(argv) - runCommand(parsedArgs, false) // when running some specific tests we shouldn't update ts + const parsedArgs = exchangeFiles.concat (argv) + runCommand (parsedArgs, false) // when running some specific tests we shouldn't update ts } } } @@ -63,24 +63,24 @@ async function main() { function runCommand(args, updateTs = true) { const nodeCommand = "node " + COMMAND; - const pro = spawn(nodeCommand, args, { stdio: 'inherit', shell:true }) + const pro = spawn (nodeCommand, args, { stdio: 'inherit', shell: true }) pro.on('exit', code => { - console.log("code", code) + console.log ("code", code) if (code === 0) { if (updateTs) { - log.bright.green("All tests ran sucessfully, saving new timestamp!") - saveNewTS() + log.bright.green ("All tests ran sucessfully, saving new timestamp!") + saveNewTS () } } else { - log.bright.red("Error running tests!") + log.bright.red ("Error running tests!") } }) } function saveNewTS() { - testFile.lastRun = Date.now(); - fs.writeFileSync (TEST_TIMESTAMP, JSON.stringify(testFile)) + testFile.lastRun = Date.now (); + fs.writeFileSync (TEST_TIMESTAMP, JSON.stringify (testFile)) } main(); From 4e2a848450a9abba8f50a754cb2dfa897346c79b Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 09:25:57 -0800 Subject: [PATCH 12/24] make six hours --- tests-manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests-manager.js b/tests-manager.js index a3484e7f8ebc..bc06d52e759a 100644 --- a/tests-manager.js +++ b/tests-manager.js @@ -14,7 +14,7 @@ const TEST_TIMESTAMP = "./testTimestamp.json"; const testFile = require(TEST_TIMESTAMP); const lastRun = testFile.lastRun; -const threeHours = 60 * 60 * 3 * 1000; +const sixHours = 60 * 60 * 6 * 1000; const currentTs = Date.now(); if (process.argv.length < 3) { @@ -30,7 +30,7 @@ argv.splice(0,3); async function main() { - if (currentTs > threeHours + lastRun) { + if (currentTs > sixHours + lastRun) { // run all tests again runCommand(argv) } else { From d83ea1224dd421afd7a7b7b9664848a4c09ec5da Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 09:29:32 -0800 Subject: [PATCH 13/24] refix .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4b87328d89e..c1e1cd2a4376 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,9 +38,9 @@ script: - npm run test-base-ws - pip list - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - node tests-manager --js --python-async --php-async 5 2>&1 & + node tests-manager run-tests --js --python-async --php-async 5 2>&1 & rest_pid=$!; - node tests-manager --js --python-async --php-async 5 2>&1 & + node tests-manager run-tests-ws --js --python-async --php-async 5 2>&1 & ws_pid=$!; wait $rest_pid && wait $ws_pid; fi - git checkout master composer.json From cc01651d501c24a9f1d7e2c64015d068916e980f Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 11:32:16 -0800 Subject: [PATCH 14/24] update to bash --- last-run.txt | 1 + testTimestamp.json | 1 - tests-manager.js | 87 ---------------------------------------------- tests-manager.sh | 30 ++++++++++++++++ 4 files changed, 31 insertions(+), 88 deletions(-) create mode 100644 last-run.txt delete mode 100644 testTimestamp.json delete mode 100644 tests-manager.js create mode 100755 tests-manager.sh diff --git a/last-run.txt b/last-run.txt new file mode 100644 index 000000000000..3349d01ebcaf --- /dev/null +++ b/last-run.txt @@ -0,0 +1 @@ +1672336002 diff --git a/testTimestamp.json b/testTimestamp.json deleted file mode 100644 index 953f76293b9c..000000000000 --- a/testTimestamp.json +++ /dev/null @@ -1 +0,0 @@ -{"lastRun":1672331334109} \ No newline at end of file diff --git a/tests-manager.js b/tests-manager.js deleted file mode 100644 index bc06d52e759a..000000000000 --- a/tests-manager.js +++ /dev/null @@ -1,87 +0,0 @@ -// --------------------------------------------------------------------------- -// Usage: node tests-manager.js someNodeFile -// --------------------------------------------------------------------------- - -"use strict"; -const fs = require('fs'); -const { spawn } = require('child_process'); -const util = require('node:util'); -const { exit } = require('process'); -const execFile = util.promisify(require('node:child_process').execFile); -const log = require ('ololog').unlimited - -const TEST_TIMESTAMP = "./testTimestamp.json"; - -const testFile = require(TEST_TIMESTAMP); -const lastRun = testFile.lastRun; -const sixHours = 60 * 60 * 6 * 1000; -const currentTs = Date.now(); - -if (process.argv.length < 3) { - log.red("Required node command not provided"); - log.yellow("Example: node tests-manager.js run-tests-ws"); - exit(1); -} - -const COMMAND = process.argv[2]; - -const argv = process.argv -argv.splice(0,3); - -async function main() { - - if (currentTs > sixHours + lastRun) { - // run all tests again - runCommand(argv) - } else { - const { stdout } = await execFile('git diff master', ['--name-only'], { shell:true }); - - if (stdout.length === 0) { - return; - } - - const shouldRunEverything = stdout.indexOf ("Exchange") > -1 || - stdout.indexOf ("/test") > -1 || - stdout.indexOf ("/build") > -1 || - stdout.indexOf ("/base") > -1 || - stdout.indexOf ("/static_dependencies") > -1 || - stdout.indexOf ("run-tests") > -1 - - if (shouldRunEverything) { - runCommand(argv) - } else { - const exchangeFiles = stdout.split ("\n").filter (e => e && e.indexOf('js/') > -1 ).map(e=> e.split("/").pop()).map(e=> e.split(".")[0]); - // ignore examples and files like that - if (exchangeFiles.length > 0) { - const parsedArgs = exchangeFiles.concat (argv) - runCommand (parsedArgs, false) // when running some specific tests we shouldn't update ts - } - } - } -} - -function runCommand(args, updateTs = true) { - - const nodeCommand = "node " + COMMAND; - const pro = spawn (nodeCommand, args, { stdio: 'inherit', shell: true }) - - pro.on('exit', code => { - console.log ("code", code) - if (code === 0) { - if (updateTs) { - log.bright.green ("All tests ran sucessfully, saving new timestamp!") - saveNewTS () - } - } else { - log.bright.red("Error running tests!") - exit(1); - } - }) -} - -function saveNewTS() { - testFile.lastRun = Date.now (); - fs.writeFileSync (TEST_TIMESTAMP, JSON.stringify (testFile)) -} - -main(); diff --git a/tests-manager.sh b/tests-manager.sh new file mode 100755 index 000000000000..0d9f3af27093 --- /dev/null +++ b/tests-manager.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +if [ $# -lt 1 ]; then + echo "too few arguments" + exit 1 +fi + +timestamp_file="./last-run.txt" +now=$(date -u +%s) +last_run=$(< $timestamp_file) +delta=$((now - last_run)) +six_hours=$((60 * 60 * 6)) +diff=$(git diff HEAD --name-only) + +if [ "$delta" -gt $six_hours ] || grep -q -E 'Exchange.php|/test|/base|^build|static_dependencies|^run-tests' <<< "$diff"; then + command="node $*" + echo "tests-managers: running $command in $(pwd)" + if eval "$command"; then + echo "Saving new timestamp" + date -u +%s > "$timestamp_file" + else + exit 1 + fi +else + to_test=$(sed -E -n 's:^js/(.+)\.js$:\1:p' <<< "$diff" | xargs) + command="node $* $to_test" + echo "tests-managers: running $command in $(pwd)" + eval "$command" + exit $? +fi From 92c1bf4902c748077ba315209a1f6e193b0bc5e3 Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 11:33:49 -0800 Subject: [PATCH 15/24] update travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1e1cd2a4376..dba92e2f6c58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,9 +38,9 @@ script: - npm run test-base-ws - pip list - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - node tests-manager run-tests --js --python-async --php-async 5 2>&1 & + ./tests-manager.sh run-tests --js --python-async --php-async 5 2>&1 & rest_pid=$!; - node tests-manager run-tests-ws --js --python-async --php-async 5 2>&1 & + ./tests-manager.sh run-tests-ws --js --python-async --php-async 5 2>&1 & ws_pid=$!; wait $rest_pid && wait $ws_pid; fi - git checkout master composer.json From 219dc39c984487ffe208727dde319f9294f52d15 Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 11:35:06 -0800 Subject: [PATCH 16/24] edit push.sh --- build/push.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/push.sh b/build/push.sh index dc33bb5da5db..67284b0e5864 100755 --- a/build/push.sh +++ b/build/push.sh @@ -39,7 +39,7 @@ echo "Pushing generated files back to GitHub..." LAST_COMMIT_MESSAGE="$(git log --no-merges -1 --pretty=%B)" git config --global user.email "travis@travis-ci.org" git config --global user.name "Travis CI" -git add testTimestamp.json php/*.php php/async/*.php php/pro/*.php php/test/*.php python/ccxt/test/*.py python/ccxt/async_support/*.py python/ccxt/*.py python/ccxt/pro/*.py python/ccxt/pro/test/*.py python/ccxt/pro/test/exchange/*.py wiki/* +git add last-run.txt php/*.php php/async/*.php php/pro/*.php php/test/*.php python/ccxt/test/*.py python/ccxt/async_support/*.py python/ccxt/*.py python/ccxt/pro/*.py python/ccxt/pro/test/*.py python/ccxt/pro/test/exchange/*.py wiki/* git add -f python/LICENSE.txt python/package.json python/README.md git commit -a -m "${COMMIT_MESSAGE}" -m '[ci skip]' git tag -a "${COMMIT_MESSAGE}" -m "${LAST_COMMIT_MESSAGE}" -m "" -m "[ci skip]" From 6f69f9dcb111460427fd28b69a509fb710f8e2cb Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 11:37:49 -0800 Subject: [PATCH 17/24] minor comment edit --- tests-manager.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests-manager.sh b/tests-manager.sh index 0d9f3af27093..5407df4a1740 100755 --- a/tests-manager.sh +++ b/tests-manager.sh @@ -14,7 +14,7 @@ diff=$(git diff HEAD --name-only) if [ "$delta" -gt $six_hours ] || grep -q -E 'Exchange.php|/test|/base|^build|static_dependencies|^run-tests' <<< "$diff"; then command="node $*" - echo "tests-managers: running $command in $(pwd)" + echo "tests-manager: running $command in $(pwd)" if eval "$command"; then echo "Saving new timestamp" date -u +%s > "$timestamp_file" @@ -24,7 +24,7 @@ if [ "$delta" -gt $six_hours ] || grep -q -E 'Exchange.php|/test|/base|^build|st else to_test=$(sed -E -n 's:^js/(.+)\.js$:\1:p' <<< "$diff" | xargs) command="node $* $to_test" - echo "tests-managers: running $command in $(pwd)" + echo "tests-manager: running $command in $(pwd)" eval "$command" exit $? fi From d6f7d5d8d2fe0bdc0a8bdec46657c07c50c0ddc9 Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 11:43:04 -0800 Subject: [PATCH 18/24] reduce filesize --- tests-manager.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests-manager.sh b/tests-manager.sh index 5407df4a1740..535eb745439a 100755 --- a/tests-manager.sh +++ b/tests-manager.sh @@ -15,16 +15,10 @@ diff=$(git diff HEAD --name-only) if [ "$delta" -gt $six_hours ] || grep -q -E 'Exchange.php|/test|/base|^build|static_dependencies|^run-tests' <<< "$diff"; then command="node $*" echo "tests-manager: running $command in $(pwd)" - if eval "$command"; then - echo "Saving new timestamp" - date -u +%s > "$timestamp_file" - else - exit 1 - fi + eval "$command" && date -u +%s > "$timestamp_file" else to_test=$(sed -E -n 's:^js/(.+)\.js$:\1:p' <<< "$diff" | xargs) command="node $* $to_test" echo "tests-manager: running $command in $(pwd)" eval "$command" - exit $? fi From 15900242fa9f573152cc3d0b6b8691c4a8839d12 Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 13:19:45 -0800 Subject: [PATCH 19/24] rewrite travis and tests-manager --- .travis.yml | 7 ++----- tests-manager.sh | 49 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index dba92e2f6c58..d78bde576e7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,11 +38,8 @@ script: - npm run test-base-ws - pip list - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - ./tests-manager.sh run-tests --js --python-async --php-async 5 2>&1 & - rest_pid=$!; - ./tests-manager.sh run-tests-ws --js --python-async --php-async 5 2>&1 & - ws_pid=$!; - wait $rest_pid && wait $ws_pid; fi + ./tests-manager.sh 2>&1; + fi - git checkout master composer.json - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then env COMMIT_MESSAGE=${NPM_VERSION:1} GITHUB_TOKEN=${GITHUB_TOKEN} ./build/push.sh; diff --git a/tests-manager.sh b/tests-manager.sh index 535eb745439a..330e6a5a7cac 100755 --- a/tests-manager.sh +++ b/tests-manager.sh @@ -1,24 +1,53 @@ #!/usr/bin/env bash -if [ $# -lt 1 ]; then - echo "too few arguments" - exit 1 +set -x +if [ $# -gt 0 ]; then + echo "E2BIG: too many arguments" + exit 7 fi timestamp_file="./last-run.txt" +if ! [ -f "$timestamp_file" ]; then + echo "ENOENT: file $timestamp_file not found" + exit 2 +fi + now=$(date -u +%s) last_run=$(< $timestamp_file) delta=$((now - last_run)) six_hours=$((60 * 60 * 6)) diff=$(git diff HEAD --name-only) +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 + # shellcheck disable=SC2086 + node run-tests --js --python-async --php-async $rest_args & + local rest_pid=$! + fi + if [ -z "$ws_pid" ]; then + # shellcheck disable=SC2086 + node run-tests-ws --js --python-async --php-async $ws_args & + ws_pid=$! + fi + wait $rest_pid && wait $ws_pid +} + if [ "$delta" -gt $six_hours ] || grep -q -E 'Exchange.php|/test|/base|^build|static_dependencies|^run-tests' <<< "$diff"; then - command="node $*" - echo "tests-manager: running $command in $(pwd)" - eval "$command" && date -u +%s > "$timestamp_file" + run_tests && date -u +%s > "$timestamp_file" else - to_test=$(sed -E -n 's:^js/(.+)\.js$:\1:p' <<< "$diff" | xargs) - command="node $* $to_test" - echo "tests-manager: running $command in $(pwd)" - eval "$command" + run_tests "$(sed -E -n 's:^js/([^/]+)\.js$:\1:p' <<< "$diff" | xargs)" "$(sed -E -n 's:^js/pro/([^/]+)\.js$:\1:p' <<< "$diff" | xargs)" fi From 060a48f162f3f2bf1b5dc66fb0820c3b86a7a713 Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 13:24:31 -0800 Subject: [PATCH 20/24] minor edits --- tests-manager.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests-manager.sh b/tests-manager.sh index 330e6a5a7cac..765edf4bd9dc 100755 --- a/tests-manager.sh +++ b/tests-manager.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -set -x if [ $# -gt 0 ]; then echo "E2BIG: too many arguments" exit 7 @@ -41,7 +40,7 @@ function run_tests { if [ -z "$ws_pid" ]; then # shellcheck disable=SC2086 node run-tests-ws --js --python-async --php-async $ws_args & - ws_pid=$! + local ws_pid=$! fi wait $rest_pid && wait $ws_pid } From 9f79950ffc8f238e66c74a989bcfe5cbc38614f3 Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 13:39:29 -0800 Subject: [PATCH 21/24] diff master --- tests-manager.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests-manager.sh b/tests-manager.sh index 765edf4bd9dc..5d383fa8df53 100755 --- a/tests-manager.sh +++ b/tests-manager.sh @@ -15,7 +15,7 @@ now=$(date -u +%s) last_run=$(< $timestamp_file) delta=$((now - last_run)) six_hours=$((60 * 60 * 6)) -diff=$(git diff HEAD --name-only) +diff=$(git diff master --name-only) function run_tests { local rest_args= From c55e70f33b369f0ed7b734e8560d5f8c2b244b1b Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 14:13:36 -0800 Subject: [PATCH 22/24] rewrite fastflake --- python/fastflake.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/fastflake.sh b/python/fastflake.sh index fbd5619e629d..1b4af3255aba 100755 --- a/python/fastflake.sh +++ b/python/fastflake.sh @@ -5,7 +5,7 @@ files=$(git diff --name-only --relative origin/master | sed -n '/py$/p' | xargs) command="flake8 --ignore=F722,F841,F821,W504,E402,E501,E275,E902 --exclude static_dependencies,node_modules,.tox" execute="${command} ${files}" -printf "\n${execute}\n\n" +echo -e "\n${execute}\n\n" if [[ -n ${files} ]]; then # only one variable expansion happens here so it is safe From 6a39a0825b95087dc53484c3040f75aa70407ba6 Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 14:15:26 -0800 Subject: [PATCH 23/24] actual rewrite --- python/fastflake.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/python/fastflake.sh b/python/fastflake.sh index 1b4af3255aba..d710a77defb9 100755 --- a/python/fastflake.sh +++ b/python/fastflake.sh @@ -2,12 +2,5 @@ # saves time over the other running flake8 on all the files -files=$(git diff --name-only --relative origin/master | sed -n '/py$/p' | xargs) -command="flake8 --ignore=F722,F841,F821,W504,E402,E501,E275,E902 --exclude static_dependencies,node_modules,.tox" -execute="${command} ${files}" -echo -e "\n${execute}\n\n" - -if [[ -n ${files} ]]; then - # only one variable expansion happens here so it is safe - ${execute} -fi +echo -e '\n checking syntax using flake8 over the following files:\n' +git diff --name-only --relative origin/master | sed -n '/py$/p' | tee /dev/stderr | xargs -L 0 flake8 --ignore=F722,F841,F821,W504,E402,E501,E275,E902 --exclude static_dependencies,node_modules,.tox From e2ad4397c1d091d6b4ccbe2bacdafc8e20af9efe Mon Sep 17 00:00:00 2001 From: Carlo Revelli Date: Thu, 29 Dec 2022 15:11:34 -0800 Subject: [PATCH 24/24] use -n 1000 instead --- python/fastflake.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/fastflake.sh b/python/fastflake.sh index d710a77defb9..d7ce4bfaa0f5 100755 --- a/python/fastflake.sh +++ b/python/fastflake.sh @@ -3,4 +3,4 @@ # saves time over the other running flake8 on all the files echo -e '\n checking syntax using flake8 over the following files:\n' -git diff --name-only --relative origin/master | sed -n '/py$/p' | tee /dev/stderr | xargs -L 0 flake8 --ignore=F722,F841,F821,W504,E402,E501,E275,E902 --exclude static_dependencies,node_modules,.tox +git diff --name-only --relative origin/master | sed -n '/py$/p' | tee /dev/stderr | xargs -n 1000 flake8 --ignore=F722,F841,F821,W504,E402,E501,E275,E902 --exclude static_dependencies,node_modules,.tox