]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - scripts/ci.sh
Translated using Weblate (Occitan)
[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 jobs=2
14
15 runTest () {
16 retries=3
17
18 jobname=$1
19 shift
20
21 jobs=$1
22 shift
23
24 files=$@
25
26 echo $files
27
28 joblog="$jobname-ci.log"
29
30 parallel -j $jobs --retries $retries \
31 "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --require ts-node/register --require tsconfig-paths/register --bail {}" \
32 ::: $files
33
34 cat "$joblog" | uniq -c
35 rm "$joblog"
36 }
37
38 findTestFiles () {
39 find $1 -type f -name "*.ts" | grep -v "/index.ts" | xargs echo
40 }
41
42 if [ "$1" = "misc" ]; then
43 npm run build
44
45 feedsFiles=$(findTestFiles server/tests/feeds)
46 helperFiles=$(findTestFiles server/tests/helpers)
47 pluginsFiles=$(findTestFiles server/tests/plugins)
48 miscFiles="server/tests/client.ts server/tests/misc-endpoints.ts"
49
50 TS_NODE_FILES=true runTest "$1" 1 $feedsFiles $helperFiles $pluginsFiles $miscFiles
51 elif [ "$1" = "cli" ]; then
52 npm run build:server
53 npm run setup:cli
54
55 cliFiles=$(findTestFiles server/tests/cli)
56
57 runTest "$1" 1 $cliFiles
58 elif [ "$1" = "api-1" ]; then
59 npm run build:server
60
61 checkParamFiles=$(findTestFiles server/tests/api/check-params)
62 notificationsFiles=$(findTestFiles server/tests/api/notifications)
63 searchFiles=$(findTestFiles server/tests/api/search)
64
65 MOCHA_PARALLEL=true runTest "$1" 3 $notificationsFiles $searchFiles $checkParamFiles
66 elif [ "$1" = "api-2" ]; then
67 npm run build:server
68
69 serverFiles=$(findTestFiles server/tests/api/server)
70 usersFiles=$(findTestFiles server/tests/api/users)
71 liveFiles=$(findTestFiles server/tests/api/live)
72
73 MOCHA_PARALLEL=true runTest "$1" 3 $serverFiles $usersFiles $liveFiles
74 elif [ "$1" = "api-3" ]; then
75 npm run build:server
76
77 videosFiles=$(findTestFiles server/tests/api/videos)
78
79 MOCHA_PARALLEL=true runTest "$1" 3 $videosFiles
80 elif [ "$1" = "api-4" ]; then
81 npm run build:server
82
83 activitypubFiles=$(findTestFiles server/tests/api/moderation)
84 redundancyFiles=$(findTestFiles server/tests/api/redundancy)
85 activitypubFiles=$(findTestFiles server/tests/api/activitypub)
86
87 MOCHA_PARALLEL=true TS_NODE_FILES=true runTest "$1" 2 $activitypubFiles $redundancyFiles $activitypubFiles
88 elif [ "$1" = "external-plugins" ]; then
89 npm run build:server
90
91 externalPluginsFiles=$(findTestFiles server/tests/external-plugins)
92
93 runTest "$1" 1 $externalPluginsFiles
94 elif [ "$1" = "lint" ]; then
95 npm run eslint -- --ext .ts "server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts"
96 npm run swagger-cli -- validate support/doc/api/openapi.yaml
97
98 ( cd client
99 npm run lint
100 )
101 fi