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