]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - scripts/ci.sh
Translated using Weblate (French (France) (fr_FR))
[github/Chocobozzz/PeerTube.git] / scripts / ci.sh
1 #!/bin/bash
2
3 set -eu
4
5 if [ $# -eq 0 ]; then
6 echo "Need test suite argument."
7 exit -1
8 fi
9
10 killall -q peertube || true
11
12 retries=3
13
14 runTest () {
15 jobname=$1
16 shift
17
18 jobs=$1
19 shift
20
21 files=$@
22
23 echo $files
24
25 joblog="$jobname-ci.log"
26
27 parallel -j $jobs --retries $retries \
28 "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --require ./dist/server/tests/register.js --bail {}" \
29 ::: $files
30
31 cat "$joblog" | uniq -c
32 rm "$joblog"
33 }
34
35 findTestFiles () {
36 exception="-not -name index.js"
37
38 if [ ! -z ${2+x} ]; then
39 exception="$exception -not -name $2"
40 fi
41
42 find $1 -type f -name "*.js" $exception | xargs echo
43 }
44
45 if [ "$1" = "client" ]; then
46 npm run build
47
48 feedsFiles=$(findTestFiles ./dist/server/tests/feeds)
49 helperFiles=$(findTestFiles ./dist/server/tests/helpers)
50 libFiles=$(findTestFiles ./dist/server/tests/lib)
51 miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js"
52 # Not in plugin task, it needs an index.html
53 pluginFiles="./dist/server/tests/plugins/html-injection.js"
54
55 MOCHA_PARALLEL=true runTest "$1" 2 $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles
56 elif [ "$1" = "cli-plugin" ]; then
57 npm run build:server
58 npm run setup:cli
59
60 pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js)
61 cliFiles=$(findTestFiles ./dist/server/tests/cli)
62
63 MOCHA_PARALLEL=true runTest "$1" 2 $pluginsFiles
64 runTest "$1" 1 $cliFiles
65 elif [ "$1" = "api-1" ]; then
66 npm run build:server
67
68 checkParamFiles=$(findTestFiles ./dist/server/tests/api/check-params)
69 notificationsFiles=$(findTestFiles ./dist/server/tests/api/notifications)
70 searchFiles=$(findTestFiles ./dist/server/tests/api/search)
71
72 MOCHA_PARALLEL=true runTest "$1" 3 $notificationsFiles $searchFiles $checkParamFiles
73 elif [ "$1" = "api-2" ]; then
74 npm run build:server
75
76 liveFiles=$(findTestFiles ./dist/server/tests/api/live)
77 serverFiles=$(findTestFiles ./dist/server/tests/api/server)
78 usersFiles=$(findTestFiles ./dist/server/tests/api/users)
79
80 MOCHA_PARALLEL=true runTest "$1" 3 $liveFiles $serverFiles $usersFiles
81 elif [ "$1" = "api-3" ]; then
82 npm run build:server
83
84 videosFiles=$(findTestFiles ./dist/server/tests/api/videos)
85
86 MOCHA_PARALLEL=true runTest "$1" 3 $videosFiles
87 elif [ "$1" = "api-4" ]; then
88 npm run build:server
89
90 moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation)
91 redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy)
92 objectStorageFiles=$(findTestFiles ./dist/server/tests/api/object-storage)
93 activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub)
94
95 MOCHA_PARALLEL=true TS_NODE_FILES=true runTest "$1" 2 $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles
96 elif [ "$1" = "external-plugins" ]; then
97 npm run build:server
98
99 externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins)
100
101 runTest "$1" 1 $externalPluginsFiles
102 elif [ "$1" = "lint" ]; then
103 npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts"
104 npm run swagger-cli -- validate support/doc/api/openapi.yaml
105
106 ( cd client
107 npm run lint
108 )
109 fi