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