]>
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 | ||
7abb5c5d | 10 | retries=3 |
7abb5c5d C |
11 | |
12 | runTest () { | |
17ae86e9 C |
13 | jobname=$1 |
14 | shift | |
15 | ||
7abb5c5d C |
16 | jobs=$1 |
17 | shift | |
17ae86e9 | 18 | |
7abb5c5d C |
19 | files=$@ |
20 | ||
21 | echo $files | |
22 | ||
17ae86e9 C |
23 | joblog="$jobname-ci.log" |
24 | ||
59fd824c | 25 | parallel -j $jobs --retries $retries \ |
f8360396 | 26 | "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --bail {}" \ |
7abb5c5d | 27 | ::: $files |
17ae86e9 | 28 | |
34caef7f | 29 | cat "$joblog" | uniq -c |
17ae86e9 | 30 | rm "$joblog" |
7abb5c5d C |
31 | } |
32 | ||
33 | findTestFiles () { | |
29b7426c C |
34 | exception="-not -name index.js" |
35 | ||
36 | if [ ! -z ${2+x} ]; then | |
37 | exception="$exception -not -name $2" | |
38 | fi | |
39 | ||
40 | find $1 -type f -name "*.js" $exception | xargs echo | |
7abb5c5d | 41 | } |
be7ca0c6 | 42 | |
6627dbc9 | 43 | if [ "$1" = "types-package" ]; then |
21d68e68 | 44 | npm run generate-types-package 0.0.0 |
6627dbc9 | 45 | npm run tsc -- --noEmit --esModuleInterop packages/types/tests/test.ts |
b969539c | 46 | elif [ "$1" = "client" ]; then |
59fd824c | 47 | npm run build |
7abb5c5d | 48 | |
3d470a53 C |
49 | feedsFiles=$(findTestFiles ./dist/server/tests/feeds) |
50 | helperFiles=$(findTestFiles ./dist/server/tests/helpers) | |
2b9f672b | 51 | libFiles=$(findTestFiles ./dist/server/tests/lib) |
3d470a53 | 52 | miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js" |
29b7426c C |
53 | # Not in plugin task, it needs an index.html |
54 | pluginFiles="./dist/server/tests/plugins/html-injection.js" | |
7abb5c5d | 55 | |
2b9f672b | 56 | MOCHA_PARALLEL=true runTest "$1" 2 $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles |
29b7426c | 57 | elif [ "$1" = "cli-plugin" ]; then |
1b6b4757 | 58 | npm run build:server |
b488ba1e | 59 | npm run setup:cli |
7abb5c5d | 60 | |
29b7426c | 61 | pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js) |
3d470a53 | 62 | cliFiles=$(findTestFiles ./dist/server/tests/cli) |
7abb5c5d | 63 | |
29b7426c | 64 | MOCHA_PARALLEL=true runTest "$1" 2 $pluginsFiles |
17ae86e9 | 65 | runTest "$1" 1 $cliFiles |
1297eb5d | 66 | elif [ "$1" = "api-1" ]; then |
15f25480 | 67 | npm run build:server |
7abb5c5d | 68 | |
3d470a53 C |
69 | checkParamFiles=$(findTestFiles ./dist/server/tests/api/check-params) |
70 | notificationsFiles=$(findTestFiles ./dist/server/tests/api/notifications) | |
71 | searchFiles=$(findTestFiles ./dist/server/tests/api/search) | |
7abb5c5d | 72 | |
17ae86e9 | 73 | MOCHA_PARALLEL=true runTest "$1" 3 $notificationsFiles $searchFiles $checkParamFiles |
1297eb5d | 74 | elif [ "$1" = "api-2" ]; then |
15f25480 | 75 | npm run build:server |
7abb5c5d | 76 | |
8ebf2a5d | 77 | liveFiles=$(findTestFiles ./dist/server/tests/api/live) |
3d470a53 C |
78 | serverFiles=$(findTestFiles ./dist/server/tests/api/server) |
79 | usersFiles=$(findTestFiles ./dist/server/tests/api/users) | |
7abb5c5d | 80 | |
13e13377 | 81 | MOCHA_PARALLEL=true runTest "$1" 3 $liveFiles $serverFiles $usersFiles |
1297eb5d C |
82 | elif [ "$1" = "api-3" ]; then |
83 | npm run build:server | |
7abb5c5d | 84 | |
3d470a53 | 85 | videosFiles=$(findTestFiles ./dist/server/tests/api/videos) |
7abb5c5d | 86 | |
17ae86e9 | 87 | MOCHA_PARALLEL=true runTest "$1" 3 $videosFiles |
2fbe7f19 | 88 | elif [ "$1" = "api-4" ]; then |
46b2cec7 | 89 | npm run build:server |
7abb5c5d | 90 | |
3d470a53 C |
91 | moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation) |
92 | redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy) | |
0305db28 | 93 | objectStorageFiles=$(findTestFiles ./dist/server/tests/api/object-storage) |
3d470a53 | 94 | activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub) |
7abb5c5d | 95 | |
fd5fa94b | 96 | MOCHA_PARALLEL=true runTest "$1" 2 $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles |
829b794a C |
97 | elif [ "$1" = "external-plugins" ]; then |
98 | npm run build:server | |
7abb5c5d | 99 | |
3d470a53 | 100 | externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins) |
7abb5c5d | 101 | |
17ae86e9 | 102 | runTest "$1" 1 $externalPluginsFiles |
18530063 | 103 | elif [ "$1" = "lint" ]; then |
3d470a53 | 104 | npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts" |
a3705089 | 105 | npm run swagger-cli -- validate support/doc/api/openapi.yaml |
f2659ae0 | 106 | |
0e4ffb4b LA |
107 | ( cd client |
108 | npm run lint | |
109 | ) | |
18530063 | 110 | fi |