1
0
Fork 0
peertube/scripts/ci.sh

99 lines
2.6 KiB
Bash
Raw Normal View History

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