]>
Commit | Line | Data |
---|---|---|
12e8547f | 1 | #!/bin/bash |
0e4ffb4b LA |
2 | |
3 | set -eu | |
18530063 C |
4 | |
5 | if [ $# -eq 0 ]; then | |
6 | echo "Need test suite argument." | |
7 | exit -1 | |
8 | fi | |
9 | ||
365b546c C |
10 | killall -q peertube || true |
11 | ||
7abb5c5d | 12 | retries=3 |
7abb5c5d C |
13 | |
14 | runTest () { | |
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 \ |
34caef7f | 28 | "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --require ts-node/register --require tsconfig-paths/register --bail {}" \ |
7abb5c5d | 29 | ::: $files |
17ae86e9 | 30 | |
34caef7f | 31 | cat "$joblog" | uniq -c |
17ae86e9 | 32 | rm "$joblog" |
7abb5c5d C |
33 | } |
34 | ||
35 | findTestFiles () { | |
34caef7f | 36 | find $1 -type f -name "*.ts" | grep -v "/index.ts" | xargs echo |
7abb5c5d | 37 | } |
be7ca0c6 | 38 | |
98ec8b8e | 39 | if [ "$1" = "misc" ]; then |
59fd824c | 40 | npm run build |
7abb5c5d C |
41 | |
42 | feedsFiles=$(findTestFiles server/tests/feeds) | |
43 | helperFiles=$(findTestFiles server/tests/helpers) | |
44 | pluginsFiles=$(findTestFiles server/tests/plugins) | |
f4659d73 | 45 | miscFiles="server/tests/client.ts server/tests/misc-endpoints.ts" |
7abb5c5d | 46 | |
17ae86e9 | 47 | TS_NODE_FILES=true runTest "$1" 1 $feedsFiles $helperFiles $pluginsFiles $miscFiles |
18530063 | 48 | elif [ "$1" = "cli" ]; then |
1b6b4757 | 49 | npm run build:server |
b488ba1e | 50 | npm run setup:cli |
7abb5c5d C |
51 | |
52 | cliFiles=$(findTestFiles server/tests/cli) | |
53 | ||
17ae86e9 | 54 | runTest "$1" 1 $cliFiles |
1297eb5d | 55 | elif [ "$1" = "api-1" ]; then |
15f25480 | 56 | npm run build:server |
7abb5c5d C |
57 | |
58 | checkParamFiles=$(findTestFiles server/tests/api/check-params) | |
59 | notificationsFiles=$(findTestFiles server/tests/api/notifications) | |
60 | searchFiles=$(findTestFiles server/tests/api/search) | |
61 | ||
17ae86e9 | 62 | MOCHA_PARALLEL=true runTest "$1" 3 $notificationsFiles $searchFiles $checkParamFiles |
1297eb5d | 63 | elif [ "$1" = "api-2" ]; then |
15f25480 | 64 | npm run build:server |
7abb5c5d C |
65 | |
66 | serverFiles=$(findTestFiles server/tests/api/server) | |
67 | usersFiles=$(findTestFiles server/tests/api/users) | |
af4ae64f | 68 | liveFiles=$(findTestFiles server/tests/api/live) |
7abb5c5d | 69 | |
17ae86e9 | 70 | MOCHA_PARALLEL=true runTest "$1" 3 $serverFiles $usersFiles $liveFiles |
1297eb5d C |
71 | elif [ "$1" = "api-3" ]; then |
72 | npm run build:server | |
7abb5c5d C |
73 | |
74 | videosFiles=$(findTestFiles server/tests/api/videos) | |
75 | ||
17ae86e9 | 76 | MOCHA_PARALLEL=true runTest "$1" 3 $videosFiles |
2fbe7f19 | 77 | elif [ "$1" = "api-4" ]; then |
46b2cec7 | 78 | npm run build:server |
7abb5c5d | 79 | |
c221d62a | 80 | moderationFiles=$(findTestFiles server/tests/api/moderation) |
7abb5c5d C |
81 | redundancyFiles=$(findTestFiles server/tests/api/redundancy) |
82 | activitypubFiles=$(findTestFiles server/tests/api/activitypub) | |
83 | ||
c221d62a | 84 | MOCHA_PARALLEL=true TS_NODE_FILES=true runTest "$1" 2 $moderationFiles $redundancyFiles $activitypubFiles |
829b794a C |
85 | elif [ "$1" = "external-plugins" ]; then |
86 | npm run build:server | |
7abb5c5d C |
87 | |
88 | externalPluginsFiles=$(findTestFiles server/tests/external-plugins) | |
89 | ||
17ae86e9 | 90 | runTest "$1" 1 $externalPluginsFiles |
18530063 | 91 | elif [ "$1" = "lint" ]; then |
7abb5c5d | 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 | 98 | fi |