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
|
|
|
|
|
2020-07-30 08:44:08 -04:00
|
|
|
retries=3
|
2022-03-18 06:17:35 -04:00
|
|
|
speedFactor="${2:-1}"
|
2020-07-30 08:44:08 -04:00
|
|
|
|
|
|
|
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 \
|
2022-01-03 11:13:11 -05:00
|
|
|
"echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --bail {}" \
|
2020-07-30 08:44:08 -04:00
|
|
|
::: $files
|
2020-12-10 10:06:09 -05:00
|
|
|
|
2022-07-13 05:34:48 -04:00
|
|
|
cat "$joblog" | sort | uniq -c
|
2020-12-10 10:06:09 -05:00
|
|
|
rm "$joblog"
|
2020-07-30 08:44:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
findTestFiles () {
|
2021-06-17 04:43:34 -04: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 08:44:08 -04:00
|
|
|
}
|
2020-01-21 09:59:57 -05:00
|
|
|
|
2021-12-28 04:18:15 -05:00
|
|
|
if [ "$1" = "types-package" ]; then
|
2021-12-28 04:25:30 -05:00
|
|
|
npm run generate-types-package 0.0.0
|
2021-12-28 04:18:15 -05:00
|
|
|
npm run tsc -- --noEmit --esModuleInterop packages/types/tests/test.ts
|
2021-12-24 07:16:55 -05:00
|
|
|
elif [ "$1" = "client" ]; then
|
2020-12-11 04:36:05 -05:00
|
|
|
npm run build
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2021-06-14 10:52:22 -04:00
|
|
|
feedsFiles=$(findTestFiles ./dist/server/tests/feeds)
|
|
|
|
helperFiles=$(findTestFiles ./dist/server/tests/helpers)
|
2021-07-21 09:44:28 -04:00
|
|
|
libFiles=$(findTestFiles ./dist/server/tests/lib)
|
2021-06-14 10:52:22 -04:00
|
|
|
miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js"
|
2022-03-17 05:50:26 -04:00
|
|
|
# Not in their own task, they need an index.html
|
|
|
|
pluginFiles="./dist/server/tests/plugins/html-injection.js ./dist/server/tests/api/server/plugins.js"
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2022-03-18 06:17:35 -04:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles
|
2021-06-17 04:43:34 -04:00
|
|
|
elif [ "$1" = "cli-plugin" ]; then
|
2017-10-31 12:33:23 -04:00
|
|
|
npm run build:server
|
2020-07-30 03:43:12 -04:00
|
|
|
npm run setup:cli
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2021-06-17 04:43:34 -04:00
|
|
|
pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js)
|
2021-06-14 10:52:22 -04:00
|
|
|
cliFiles=$(findTestFiles ./dist/server/tests/cli)
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2022-03-18 06:17:35 -04:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $pluginsFiles
|
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
|
2017-10-31 12:50:28 -04:00
|
|
|
npm run build:server
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2021-06-14 10:52:22 -04: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 08:44:08 -04:00
|
|
|
|
2022-03-18 06:17:35 -04:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $notificationsFiles $searchFiles $checkParamFiles
|
2018-08-22 10:15:35 -04:00
|
|
|
elif [ "$1" = "api-2" ]; then
|
2017-10-31 12:50:28 -04:00
|
|
|
npm run build:server
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2021-06-16 09:14:41 -04:00
|
|
|
liveFiles=$(findTestFiles ./dist/server/tests/api/live)
|
2022-03-17 05:50:26 -04:00
|
|
|
serverFiles=$(findTestFiles ./dist/server/tests/api/server plugins.js)
|
2021-06-14 10:52:22 -04:00
|
|
|
usersFiles=$(findTestFiles ./dist/server/tests/api/users)
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2022-03-18 06:17:35 -04:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $liveFiles $serverFiles $usersFiles
|
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
|
|
|
|
2021-06-14 10:52:22 -04:00
|
|
|
videosFiles=$(findTestFiles ./dist/server/tests/api/videos)
|
2022-03-24 08:36:47 -04:00
|
|
|
viewsFiles=$(findTestFiles ./dist/server/tests/api/views)
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2022-03-24 08:36:47 -04:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $viewsFiles $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-06-14 10:52:22 -04:00
|
|
|
moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation)
|
|
|
|
redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy)
|
2021-08-17 02:26:20 -04:00
|
|
|
objectStorageFiles=$(findTestFiles ./dist/server/tests/api/object-storage)
|
2021-06-14 10:52:22 -04:00
|
|
|
activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub)
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2022-03-18 06:17:35 -04:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles
|
2022-02-28 09:56:51 -05:00
|
|
|
elif [ "$1" = "api-5" ]; then
|
|
|
|
npm run build:server
|
|
|
|
|
|
|
|
transcodingFiles=$(findTestFiles ./dist/server/tests/api/transcoding)
|
|
|
|
|
2022-03-18 06:17:35 -04:00
|
|
|
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $transcodingFiles
|
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
|
|
|
|
2021-06-14 10:52:22 -04:00
|
|
|
externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins)
|
2020-07-30 08:44:08 -04:00
|
|
|
|
2020-12-10 10:06:09 -05:00
|
|
|
runTest "$1" 1 $externalPluginsFiles
|
2017-10-31 12:23:57 -04:00
|
|
|
elif [ "$1" = "lint" ]; then
|
2021-06-14 10:52:22 -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
|