]>
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 \ |
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 | ||
35 | findTestFiles () { | |
29b7426c C |
36 | exception="-not -name index.js" |
37 | ||
38 | if [ ! -z ${2+x} ]; then | |
39 | exception="$exception -not -name $2" | |
40 | fi | |
41 | ||
42 | find $1 -type f -name "*.js" $exception | xargs echo | |
7abb5c5d | 43 | } |
be7ca0c6 | 44 | |
29b7426c | 45 | if [ "$1" = "client" ]; then |
59fd824c | 46 | npm run build |
7abb5c5d | 47 | |
3d470a53 C |
48 | feedsFiles=$(findTestFiles ./dist/server/tests/feeds) |
49 | helperFiles=$(findTestFiles ./dist/server/tests/helpers) | |
2b9f672b | 50 | libFiles=$(findTestFiles ./dist/server/tests/lib) |
3d470a53 | 51 | miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js" |
29b7426c C |
52 | # Not in plugin task, it needs an index.html |
53 | pluginFiles="./dist/server/tests/plugins/html-injection.js" | |
7abb5c5d | 54 | |
2b9f672b | 55 | MOCHA_PARALLEL=true runTest "$1" 2 $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles |
29b7426c | 56 | elif [ "$1" = "cli-plugin" ]; then |
1b6b4757 | 57 | npm run build:server |
b488ba1e | 58 | npm run setup:cli |
7abb5c5d | 59 | |
29b7426c | 60 | pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js) |
3d470a53 | 61 | cliFiles=$(findTestFiles ./dist/server/tests/cli) |
7abb5c5d | 62 | |
29b7426c | 63 | MOCHA_PARALLEL=true runTest "$1" 2 $pluginsFiles |
17ae86e9 | 64 | runTest "$1" 1 $cliFiles |
1297eb5d | 65 | elif [ "$1" = "api-1" ]; then |
15f25480 | 66 | npm run build:server |
7abb5c5d | 67 | |
3d470a53 C |
68 | checkParamFiles=$(findTestFiles ./dist/server/tests/api/check-params) |
69 | notificationsFiles=$(findTestFiles ./dist/server/tests/api/notifications) | |
70 | searchFiles=$(findTestFiles ./dist/server/tests/api/search) | |
7abb5c5d | 71 | |
17ae86e9 | 72 | MOCHA_PARALLEL=true runTest "$1" 3 $notificationsFiles $searchFiles $checkParamFiles |
1297eb5d | 73 | elif [ "$1" = "api-2" ]; then |
15f25480 | 74 | npm run build:server |
7abb5c5d | 75 | |
8ebf2a5d | 76 | liveFiles=$(findTestFiles ./dist/server/tests/api/live) |
3d470a53 C |
77 | serverFiles=$(findTestFiles ./dist/server/tests/api/server) |
78 | usersFiles=$(findTestFiles ./dist/server/tests/api/users) | |
7abb5c5d | 79 | |
13e13377 | 80 | MOCHA_PARALLEL=true runTest "$1" 3 $liveFiles $serverFiles $usersFiles |
1297eb5d C |
81 | elif [ "$1" = "api-3" ]; then |
82 | npm run build:server | |
7abb5c5d | 83 | |
3d470a53 | 84 | videosFiles=$(findTestFiles ./dist/server/tests/api/videos) |
7abb5c5d | 85 | |
17ae86e9 | 86 | MOCHA_PARALLEL=true runTest "$1" 3 $videosFiles |
2fbe7f19 | 87 | elif [ "$1" = "api-4" ]; then |
46b2cec7 | 88 | npm run build:server |
7abb5c5d | 89 | |
3d470a53 C |
90 | moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation) |
91 | redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy) | |
92 | activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub) | |
7abb5c5d | 93 | |
c221d62a | 94 | MOCHA_PARALLEL=true TS_NODE_FILES=true runTest "$1" 2 $moderationFiles $redundancyFiles $activitypubFiles |
829b794a C |
95 | elif [ "$1" = "external-plugins" ]; then |
96 | npm run build:server | |
7abb5c5d | 97 | |
3d470a53 | 98 | externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins) |
7abb5c5d | 99 | |
17ae86e9 | 100 | runTest "$1" 1 $externalPluginsFiles |
18530063 | 101 | elif [ "$1" = "lint" ]; then |
3d470a53 | 102 | npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts" |
a3705089 | 103 | npm run swagger-cli -- validate support/doc/api/openapi.yaml |
f2659ae0 | 104 | |
0e4ffb4b LA |
105 | ( cd client |
106 | npm run lint | |
107 | ) | |
18530063 | 108 | fi |