PeerTube/scripts/ci.sh

127 lines
4.1 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
2020-07-30 14:44:08 +02:00
retries=3
speedFactor="${2:-1}"
2020-07-30 14:44:08 +02:00
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 \
"echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --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 () {
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
}
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
2021-12-28 10:18:15 +01:00
npm run tsc -- --noEmit --esModuleInterop packages/types/tests/test.ts
2021-12-24 13:16:55 +01:00
elif [ "$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"
2022-03-17 10:50:26 +01: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 14:44:08 +02:00
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles
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
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
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $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
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
MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $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
2021-06-16 15:14:41 +02:00
liveFiles=$(findTestFiles ./dist/server/tests/api/live)
2022-03-17 10:50:26 +01:00
serverFiles=$(findTestFiles ./dist/server/tests/api/server plugins.js)
2021-06-14 16:52:22 +02:00
usersFiles=$(findTestFiles ./dist/server/tests/api/users)
2020-07-30 14:44:08 +02:00
MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $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)
viewsFiles=$(findTestFiles ./dist/server/tests/api/views)
2020-07-30 14:44:08 +02:00
MOCHA_PARALLEL=true runTest "$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
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)
Add support for saving video files to object storage (#4290) * Add support for saving video files to object storage * Add support for custom url generation on s3 stored files Uses two config keys to support url generation that doesn't directly go to (compatible s3). Can be used to generate urls to any cache server or CDN. * Upload files to s3 concurrently and delete originals afterwards * Only publish after move to object storage is complete * Use base url instead of url template * Fix mistyped config field * Add rudenmentary way to download before transcode * Implement Chocobozzz suggestions https://github.com/Chocobozzz/PeerTube/pull/4290#issuecomment-891670478 The remarks in question: Try to use objectStorage prefix instead of s3 prefix for your function/variables/config names Prefer to use a tree for the config: s3.streaming_playlists_bucket -> object_storage.streaming_playlists.bucket Use uppercase for config: S3.STREAMING_PLAYLISTS_BUCKETINFO.bucket -> OBJECT_STORAGE.STREAMING_PLAYLISTS.BUCKET (maybe BUCKET_NAME instead of BUCKET) I suggest to rename moveJobsRunning to pendingMovingJobs (or better, create a dedicated videoJobInfo table with a pendingMove & videoId columns so we could also use this table to track pending transcoding jobs) https://github.com/Chocobozzz/PeerTube/pull/4290/files#diff-3e26d41ca4bda1de8e1747af70ca2af642abcc1e9e0bfb94239ff2165acfbde5R19 uses a string instead of an integer I think we should store the origin object storage URL in fileUrl, without base_url injection. Instead, inject the base_url at "runtime" so admins can easily change this configuration without running a script to update DB URLs * Import correct function * Support multipart upload * Remove import of node 15.0 module stream/promises * Extend maximum upload job length Using the same value as for redundancy downloading seems logical * Use dynamic part size for really large uploads Also adds very small part size for local testing * Fix decreasePendingMove query * Resolve various PR comments * Move to object storage after optimize * Make upload size configurable and increase default * Prune webtorrent files that are stored in object storage * Move files after transcoding jobs * Fix federation * Add video path manager * Support move to external storage job in client * Fix live object storage tests Co-authored-by: Chocobozzz <me@florianbigard.com>
2021-08-17 08:26:20 +02:00
objectStorageFiles=$(findTestFiles ./dist/server/tests/api/object-storage)
2021-06-14 16:52:22 +02:00
activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub)
2020-07-30 14:44:08 +02:00
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles
elif [ "$1" = "api-5" ]; then
npm run build:server
transcodingFiles=$(findTestFiles ./dist/server/tests/api/transcoding)
2023-04-21 15:05:27 +02:00
runnersFiles=$(findTestFiles ./dist/server/tests/api/runners)
2023-04-21 15:05:27 +02:00
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $transcodingFiles $runnersFiles
2020-04-27 10:58:09 +02:00
elif [ "$1" = "external-plugins" ]; then
npm run build:server
2023-04-21 15:05:27 +02:00
npm run build:peertube-runner
2020-07-30 14:44:08 +02:00
2021-06-14 16:52:22 +02:00
externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins)
2023-04-21 15:05:27 +02:00
peertubeRunnerFiles=$(findTestFiles ./dist/server/tests/peertube-runner)
2020-07-30 14:44:08 +02:00
2023-05-19 13:33:27 +02:00
runTest "$1" 1 $externalPluginsFiles
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $peertubeRunnerFiles
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