2020-07-30 16:25:00 +02:00
|
|
|
#!/bin/bash
|
2018-03-27 10:35:12 +02:00
|
|
|
|
|
|
|
set -eu
|
2017-10-31 17:23:57 +01:00
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo "Need test suite argument."
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2018-07-31 10:26:13 +02:00
|
|
|
killall -q peertube || true
|
|
|
|
|
2020-07-30 14:44:08 +02:00
|
|
|
retries=3
|
|
|
|
|
|
|
|
runTest () {
|
2020-12-10 16:06:09 +01:00
|
|
|
jobname=$1
|
|
|
|
shift
|
|
|
|
|
2020-07-30 14:44:08 +02:00
|
|
|
jobs=$1
|
|
|
|
shift
|
2020-12-10 16:06:09 +01:00
|
|
|
|
2020-07-30 14:44:08 +02:00
|
|
|
files=$@
|
|
|
|
|
|
|
|
echo $files
|
|
|
|
|
2020-12-10 16:06:09 +01:00
|
|
|
joblog="$jobname-ci.log"
|
|
|
|
|
2020-12-11 10:36:05 +01:00
|
|
|
parallel -j $jobs --retries $retries \
|
2021-06-14 16:52:22 +02:00
|
|
|
"echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --require ./dist/server/tests/register.js --bail {}" \
|
2020-07-30 14:44:08 +02:00
|
|
|
::: $files
|
2020-12-10 16:06:09 +01:00
|
|
|
|
2020-12-10 16:38:12 +01:00
|
|
|
cat "$joblog" | uniq -c
|
2020-12-10 16:06:09 +01:00
|
|
|
rm "$joblog"
|
2020-07-30 14:44:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
findTestFiles () {
|
2021-06-17 10:43:34 +02:00
|
|
|
exception="-not -name index.js"
|
|
|
|
|
|
|
|
if [ ! -z ${2+x} ]; then
|
|
|
|
exception="$exception -not -name $2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
find $1 -type f -name "*.js" $exception | xargs echo
|
2020-07-30 14:44:08 +02:00
|
|
|
}
|
2020-01-21 15:59:57 +01:00
|
|
|
|
2021-06-17 10:43:34 +02:00
|
|
|
if [ "$1" = "client" ]; then
|
2020-12-11 10:36:05 +01:00
|
|
|
npm run build
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-06-14 16:52:22 +02:00
|
|
|
feedsFiles=$(findTestFiles ./dist/server/tests/feeds)
|
|
|
|
helperFiles=$(findTestFiles ./dist/server/tests/helpers)
|
2021-07-21 15:44:28 +02:00
|
|
|
libFiles=$(findTestFiles ./dist/server/tests/lib)
|
2021-06-14 16:52:22 +02:00
|
|
|
miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js"
|
2021-06-17 10:43:34 +02:00
|
|
|
# Not in plugin task, it needs an index.html
|
|
|
|
pluginFiles="./dist/server/tests/plugins/html-injection.js"
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-07-21 15:44:28 +02:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" 2 $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles
|
2021-06-17 10:43:34 +02:00
|
|
|
elif [ "$1" = "cli-plugin" ]; then
|
2017-10-31 17:33:23 +01:00
|
|
|
npm run build:server
|
2020-07-30 09:43:12 +02:00
|
|
|
npm run setup:cli
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-06-17 10:43:34 +02:00
|
|
|
pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js)
|
2021-06-14 16:52:22 +02:00
|
|
|
cliFiles=$(findTestFiles ./dist/server/tests/cli)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-06-17 10:43:34 +02:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" 2 $pluginsFiles
|
2020-12-10 16:06:09 +01:00
|
|
|
runTest "$1" 1 $cliFiles
|
2018-08-22 16:15:35 +02:00
|
|
|
elif [ "$1" = "api-1" ]; then
|
2017-10-31 17:50:28 +01:00
|
|
|
npm run build:server
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-06-14 16:52:22 +02:00
|
|
|
checkParamFiles=$(findTestFiles ./dist/server/tests/api/check-params)
|
|
|
|
notificationsFiles=$(findTestFiles ./dist/server/tests/api/notifications)
|
|
|
|
searchFiles=$(findTestFiles ./dist/server/tests/api/search)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2020-12-10 16:06:09 +01:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" 3 $notificationsFiles $searchFiles $checkParamFiles
|
2018-08-22 16:15:35 +02:00
|
|
|
elif [ "$1" = "api-2" ]; then
|
2017-10-31 17:50:28 +01:00
|
|
|
npm run build:server
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-06-16 15:14:41 +02:00
|
|
|
liveFiles=$(findTestFiles ./dist/server/tests/api/live)
|
2021-06-14 16:52:22 +02:00
|
|
|
serverFiles=$(findTestFiles ./dist/server/tests/api/server)
|
|
|
|
usersFiles=$(findTestFiles ./dist/server/tests/api/users)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-07-22 08:46:55 +02:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" 3 $liveFiles $serverFiles $usersFiles
|
2018-08-22 16:15:35 +02:00
|
|
|
elif [ "$1" = "api-3" ]; then
|
|
|
|
npm run build:server
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-06-14 16:52:22 +02:00
|
|
|
videosFiles=$(findTestFiles ./dist/server/tests/api/videos)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2020-12-10 16:06:09 +01:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" 3 $videosFiles
|
2018-11-15 09:24:56 +01:00
|
|
|
elif [ "$1" = "api-4" ]; then
|
2019-05-24 17:42:35 +02:00
|
|
|
npm run build:server
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-06-14 16:52:22 +02:00
|
|
|
moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation)
|
|
|
|
redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy)
|
|
|
|
activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-03-09 15:45:37 +01:00
|
|
|
MOCHA_PARALLEL=true TS_NODE_FILES=true runTest "$1" 2 $moderationFiles $redundancyFiles $activitypubFiles
|
2020-04-27 10:58:09 +02:00
|
|
|
elif [ "$1" = "external-plugins" ]; then
|
|
|
|
npm run build:server
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2021-06-14 16:52:22 +02:00
|
|
|
externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2020-12-10 16:06:09 +01:00
|
|
|
runTest "$1" 1 $externalPluginsFiles
|
2017-10-31 17:23:57 +01:00
|
|
|
elif [ "$1" = "lint" ]; then
|
2021-06-14 16:52:22 +02:00
|
|
|
npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts"
|
2020-01-21 14:28:28 +01:00
|
|
|
npm run swagger-cli -- validate support/doc/api/openapi.yaml
|
2018-09-21 09:26:02 +02:00
|
|
|
|
2018-03-27 10:35:12 +02:00
|
|
|
( cd client
|
|
|
|
npm run lint
|
|
|
|
)
|
2017-10-31 17:23:57 +01:00
|
|
|
fi
|