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