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
|
|
|
|
|
2020-07-30 14:44:08 +02:00
|
|
|
retries=3
|
2022-03-18 11:17:35 +01:00
|
|
|
speedFactor="${2:-1}"
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
runJSTest () {
|
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 \
|
2023-07-31 14:34:36 +02:00
|
|
|
"echo Trying {} >> $joblog; npm run mocha -- --timeout 30000 --no-config -c --exit --bail {}" \
|
2020-07-30 14:44:08 +02:00
|
|
|
::: $files
|
2020-12-10 16:06:09 +01:00
|
|
|
|
2022-07-13 11:34:48 +02:00
|
|
|
cat "$joblog" | sort | uniq -c
|
2020-12-10 16:06:09 +01:00
|
|
|
rm "$joblog"
|
2020-07-30 14:44:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
findTestFiles () {
|
2023-07-31 14:34:36 +02:00
|
|
|
exception="-not -name index.js -not -name index.ts -not -name *.d.ts"
|
2021-06-17 10:43:34 +02:00
|
|
|
|
|
|
|
if [ ! -z ${2+x} ]; then
|
|
|
|
exception="$exception -not -name $2"
|
|
|
|
fi
|
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
find $1 -type f \( -name "*.js" -o -name "*.ts" \) $exception | xargs echo
|
2020-07-30 14:44:08 +02:00
|
|
|
}
|
2020-01-21 15:59:57 +01:00
|
|
|
|
2021-12-28 10:18:15 +01:00
|
|
|
if [ "$1" = "types-package" ]; then
|
2021-12-28 10:25:30 +01:00
|
|
|
npm run generate-types-package 0.0.0
|
2023-07-31 14:34:36 +02:00
|
|
|
|
|
|
|
# Test on in independent directory
|
|
|
|
rm -fr /tmp/types-generator
|
|
|
|
mkdir -p /tmp/types-generator
|
|
|
|
cp -r packages/types-generator/tests /tmp/types-generator/tests
|
|
|
|
cp -r packages/types-generator/dist /tmp/types-generator/dist
|
|
|
|
(cd /tmp/types-generator/dist && npm install)
|
|
|
|
|
2023-10-11 15:29:11 +02:00
|
|
|
npm run tsc -- --noEmit --esModuleInterop --moduleResolution node16 --module Node16 /tmp/types-generator/tests/test.ts
|
2023-07-31 14:34:36 +02:00
|
|
|
rm -r /tmp/types-generator
|
2021-12-24 13:16:55 +01:00
|
|
|
elif [ "$1" = "client" ]; then
|
2020-12-11 10:36:05 +01:00
|
|
|
npm run build
|
2023-07-31 14:34:36 +02:00
|
|
|
npm run build:tests
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
feedsFiles=$(findTestFiles ./packages/tests/dist/feeds)
|
2023-10-20 15:41:22 +02:00
|
|
|
clientFiles=$(findTestFiles ./packages/tests/dist/client)
|
2024-01-18 09:09:23 +01:00
|
|
|
miscFiles="./packages/tests/dist/misc-endpoints.js ./packages/tests/dist/nginx.js"
|
2022-03-17 10:50:26 +01:00
|
|
|
# Not in their own task, they need an index.html
|
2023-07-31 14:34:36 +02:00
|
|
|
pluginFiles="./packages/tests/dist/plugins/html-injection.js ./packages/tests/dist/api/server/plugins.js"
|
|
|
|
|
2023-10-20 15:41:22 +02:00
|
|
|
MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $feedsFiles $miscFiles $pluginFiles $clientFiles
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
# Use TS tests directly because we import server files
|
|
|
|
helperFiles=$(findTestFiles ./packages/tests/src/server-helpers)
|
|
|
|
libFiles=$(findTestFiles ./packages/tests/src/server-lib)
|
|
|
|
|
|
|
|
npm run mocha -- --timeout 30000 -c --exit --bail $libFiles $helperFiles
|
2021-06-17 10:43:34 +02:00
|
|
|
elif [ "$1" = "cli-plugin" ]; then
|
2023-03-27 08:43:50 +02:00
|
|
|
# Simulate HTML
|
|
|
|
mkdir -p "./client/dist/en-US/"
|
|
|
|
cp "./client/src/index.html" "./client/dist/en-US/index.html"
|
|
|
|
|
2017-10-31 17:33:23 +01:00
|
|
|
npm run build:server
|
2023-07-31 14:34:36 +02:00
|
|
|
npm run build:tests
|
|
|
|
npm run build:peertube-cli
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
# html-injection test needs an HTML file
|
|
|
|
pluginsFiles=$(findTestFiles ./packages/tests/dist/plugins html-injection.js)
|
|
|
|
cliFiles=$(findTestFiles ./packages/tests/dist/cli)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $pluginsFiles
|
|
|
|
runJSTest "$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
|
2023-07-31 14:34:36 +02:00
|
|
|
npm run build:tests
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
checkParamFiles=$(findTestFiles ./packages/tests/dist/api/check-params)
|
|
|
|
notificationsFiles=$(findTestFiles ./packages/tests/dist/api/notifications)
|
|
|
|
searchFiles=$(findTestFiles ./packages/tests/dist/api/search)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
MOCHA_PARALLEL=true runJSTest "$1" $((3*$speedFactor)) $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
|
2023-07-31 14:34:36 +02:00
|
|
|
npm run build:tests
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
liveFiles=$(findTestFiles ./packages/tests/dist/api/live)
|
|
|
|
# plugins test needs an HTML file
|
|
|
|
serverFiles=$(findTestFiles ./packages/tests/dist/api/server plugins.js)
|
|
|
|
usersFiles=$(findTestFiles ./packages/tests/dist/api/users)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
MOCHA_PARALLEL=true runJSTest "$1" $((3*$speedFactor)) $liveFiles $serverFiles $usersFiles
|
2018-08-22 16:15:35 +02:00
|
|
|
elif [ "$1" = "api-3" ]; then
|
|
|
|
npm run build:server
|
2023-07-31 14:34:36 +02:00
|
|
|
npm run build:tests
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
videosFiles=$(findTestFiles ./packages/tests/dist/api/videos)
|
|
|
|
viewsFiles=$(findTestFiles ./packages/tests/dist/api/views)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
MOCHA_PARALLEL=true runJSTest "$1" $((3*$speedFactor)) $viewsFiles $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
|
2023-07-31 14:34:36 +02:00
|
|
|
npm run build:tests
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
moderationFiles=$(findTestFiles ./packages/tests/dist/api/moderation)
|
|
|
|
redundancyFiles=$(findTestFiles ./packages/tests/dist/api/redundancy)
|
|
|
|
objectStorageFiles=$(findTestFiles ./packages/tests/dist/api/object-storage)
|
|
|
|
activitypubFiles=$(findTestFiles ./packages/tests/dist/api/activitypub)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles
|
2022-02-28 15:56:51 +01:00
|
|
|
elif [ "$1" = "api-5" ]; then
|
|
|
|
npm run build:server
|
2023-07-31 14:34:36 +02:00
|
|
|
npm run build:tests
|
2022-02-28 15:56:51 +01:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
transcodingFiles=$(findTestFiles ./packages/tests/dist/api/transcoding)
|
|
|
|
runnersFiles=$(findTestFiles ./packages/tests/dist/api/runners)
|
2022-02-28 15:56:51 +01:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $transcodingFiles $runnersFiles
|
2020-04-27 10:58:09 +02:00
|
|
|
elif [ "$1" = "external-plugins" ]; then
|
|
|
|
npm run build:server
|
2023-07-31 14:34:36 +02:00
|
|
|
npm run build:tests
|
2023-04-21 15:05:27 +02:00
|
|
|
npm run build:peertube-runner
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
externalPluginsFiles=$(findTestFiles ./packages/tests/dist/external-plugins)
|
|
|
|
peertubeRunnerFiles=$(findTestFiles ./packages/tests/dist/peertube-runner)
|
2020-07-30 14:44:08 +02:00
|
|
|
|
2023-07-31 14:34:36 +02:00
|
|
|
runJSTest "$1" 1 $externalPluginsFiles
|
|
|
|
MOCHA_PARALLEL=true runJSTest "$1" $((2*$speedFactor)) $peertubeRunnerFiles
|
2017-10-31 17:23:57 +01:00
|
|
|
elif [ "$1" = "lint" ]; then
|
2023-07-31 14:34:36 +02:00
|
|
|
npm run eslint -- --ext .ts "server/**/*.ts" "scripts/**/*.ts" "packages/**/*.ts" "apps/**/*.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
|
|
|
|
2023-08-18 14:12:32 +02:00
|
|
|
( cd client && npm run lint )
|
2017-10-31 17:23:57 +01:00
|
|
|
fi
|