PeerTube/scripts/ci.sh

91 lines
2.4 KiB
Bash
Raw Normal View History

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
jobs=2
runTest () {
retries=3
jobs=$1
shift
files=$@
echo $files
parallel -t -j $jobs --retries $retries \
2020-07-30 14:44:08 +02:00
npm run mocha -- -c --timeout 30000 --exit --require ts-node/register --require tsconfig-paths/register --bail \
::: $files
}
findTestFiles () {
find $1 -type f -name "*.ts" | grep -v index.ts | xargs echo
}
2017-11-30 13:16:23 +01:00
if [ "$1" = "misc" ]; then
2020-01-28 11:37:09 +01:00
npm run build -- --light
2020-07-30 14:44:08 +02:00
feedsFiles=$(findTestFiles server/tests/feeds)
helperFiles=$(findTestFiles server/tests/helpers)
pluginsFiles=$(findTestFiles server/tests/plugins)
miscFiles="server/tests/client.ts server/tests/misc-endpoints.ts"
2020-07-30 14:44:08 +02:00
2020-07-31 09:13:13 +02:00
TS_NODE_FILES=true runTest 1 $feedsFiles $helperFiles $pluginsFiles $miscFiles
2017-10-31 17:23:57 +01:00
elif [ "$1" = "cli" ]; then
2017-10-31 17:33:23 +01:00
npm run build:server
npm run setup:cli
2020-07-30 14:44:08 +02:00
cliFiles=$(findTestFiles server/tests/cli)
runTest 1 $cliFiles
2018-08-22 16:15:35 +02:00
elif [ "$1" = "api-1" ]; then
npm run build:server
2020-07-30 14:44:08 +02:00
checkParamFiles=$(findTestFiles server/tests/api/check-params)
notificationsFiles=$(findTestFiles server/tests/api/notifications)
searchFiles=$(findTestFiles server/tests/api/search)
MOCHA_PARALLEL=true runTest 2 $notificationsFiles $searchFiles $checkParamFiles
2018-08-22 16:15:35 +02:00
elif [ "$1" = "api-2" ]; then
npm run build:server
2020-07-30 14:44:08 +02:00
serverFiles=$(findTestFiles server/tests/api/server)
usersFiles=$(findTestFiles server/tests/api/users)
MOCHA_PARALLEL=true runTest 2 $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
videosFiles=$(findTestFiles server/tests/api/videos)
2020-07-30 16:58:32 +02:00
MOCHA_PARALLEL=true runTest 2 $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
activitypubFiles=$(findTestFiles server/tests/api/moderation)
redundancyFiles=$(findTestFiles server/tests/api/redundancy)
activitypubFiles=$(findTestFiles server/tests/api/activitypub)
MOCHA_PARALLEL=true TS_NODE_FILES=true runTest 2 $activitypubFiles $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
externalPluginsFiles=$(findTestFiles server/tests/external-plugins)
runTest 1 $externalPluginsFiles
2017-10-31 17:23:57 +01:00
elif [ "$1" = "lint" ]; then
2020-07-30 14:44:08 +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