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