]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/ci.sh
Fix upload avatar button
[github/Chocobozzz/PeerTube.git] / scripts / ci.sh
CommitLineData
12e8547f 1#!/bin/bash
0e4ffb4b
LA
2
3set -eu
18530063
C
4
5if [ $# -eq 0 ]; then
6 echo "Need test suite argument."
7 exit -1
8fi
9
7abb5c5d 10retries=3
57e4e1c1 11speedFactor="${2:-1}"
7abb5c5d
C
12
13runTest () {
17ae86e9
C
14 jobname=$1
15 shift
16
7abb5c5d
C
17 jobs=$1
18 shift
17ae86e9 19
7abb5c5d
C
20 files=$@
21
22 echo $files
23
17ae86e9
C
24 joblog="$jobname-ci.log"
25
59fd824c 26 parallel -j $jobs --retries $retries \
f8360396 27 "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --bail {}" \
7abb5c5d 28 ::: $files
17ae86e9 29
34caef7f 30 cat "$joblog" | uniq -c
17ae86e9 31 rm "$joblog"
7abb5c5d
C
32}
33
34findTestFiles () {
29b7426c
C
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
7abb5c5d 42}
be7ca0c6 43
6627dbc9 44if [ "$1" = "types-package" ]; then
21d68e68 45 npm run generate-types-package 0.0.0
6627dbc9 46 npm run tsc -- --noEmit --esModuleInterop packages/types/tests/test.ts
b969539c 47elif [ "$1" = "client" ]; then
59fd824c 48 npm run build
7abb5c5d 49
3d470a53
C
50 feedsFiles=$(findTestFiles ./dist/server/tests/feeds)
51 helperFiles=$(findTestFiles ./dist/server/tests/helpers)
2b9f672b 52 libFiles=$(findTestFiles ./dist/server/tests/lib)
3d470a53 53 miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js"
db1ccd05
C
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"
7abb5c5d 56
57e4e1c1 57 MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles
29b7426c 58elif [ "$1" = "cli-plugin" ]; then
1b6b4757 59 npm run build:server
b488ba1e 60 npm run setup:cli
7abb5c5d 61
29b7426c 62 pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js)
3d470a53 63 cliFiles=$(findTestFiles ./dist/server/tests/cli)
7abb5c5d 64
57e4e1c1 65 MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $pluginsFiles
17ae86e9 66 runTest "$1" 1 $cliFiles
1297eb5d 67elif [ "$1" = "api-1" ]; then
15f25480 68 npm run build:server
7abb5c5d 69
3d470a53
C
70 checkParamFiles=$(findTestFiles ./dist/server/tests/api/check-params)
71 notificationsFiles=$(findTestFiles ./dist/server/tests/api/notifications)
72 searchFiles=$(findTestFiles ./dist/server/tests/api/search)
7abb5c5d 73
57e4e1c1 74 MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $notificationsFiles $searchFiles $checkParamFiles
1297eb5d 75elif [ "$1" = "api-2" ]; then
15f25480 76 npm run build:server
7abb5c5d 77
8ebf2a5d 78 liveFiles=$(findTestFiles ./dist/server/tests/api/live)
db1ccd05 79 serverFiles=$(findTestFiles ./dist/server/tests/api/server plugins.js)
3d470a53 80 usersFiles=$(findTestFiles ./dist/server/tests/api/users)
7abb5c5d 81
57e4e1c1 82 MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $liveFiles $serverFiles $usersFiles
1297eb5d
C
83elif [ "$1" = "api-3" ]; then
84 npm run build:server
7abb5c5d 85
3d470a53 86 videosFiles=$(findTestFiles ./dist/server/tests/api/videos)
b2111066 87 viewsFiles=$(findTestFiles ./dist/server/tests/api/views)
7abb5c5d 88
b2111066 89 MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $viewsFiles $videosFiles
2fbe7f19 90elif [ "$1" = "api-4" ]; then
46b2cec7 91 npm run build:server
7abb5c5d 92
3d470a53
C
93 moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation)
94 redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy)
0305db28 95 objectStorageFiles=$(findTestFiles ./dist/server/tests/api/object-storage)
3d470a53 96 activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub)
7abb5c5d 97
57e4e1c1 98 MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles
95faf1ea
C
99elif [ "$1" = "api-5" ]; then
100 npm run build:server
101
102 transcodingFiles=$(findTestFiles ./dist/server/tests/api/transcoding)
103
57e4e1c1 104 MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $transcodingFiles
829b794a
C
105elif [ "$1" = "external-plugins" ]; then
106 npm run build:server
7abb5c5d 107
3d470a53 108 externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins)
7abb5c5d 109
17ae86e9 110 runTest "$1" 1 $externalPluginsFiles
18530063 111elif [ "$1" = "lint" ]; then
3d470a53 112 npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts"
a3705089 113 npm run swagger-cli -- validate support/doc/api/openapi.yaml
f2659ae0 114
0e4ffb4b
LA
115 ( cd client
116 npm run lint
117 )
18530063 118fi