]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | ||
3 | set -eu | |
4 | ||
5 | if [ $# -eq 0 ]; then | |
6 | echo "Need test suite argument." | |
7 | exit -1 | |
8 | fi | |
9 | ||
10 | retries=3 | |
11 | speedFactor="${2:-1}" | |
12 | ||
13 | runTest () { | |
14 | jobname=$1 | |
15 | shift | |
16 | ||
17 | jobs=$1 | |
18 | shift | |
19 | ||
20 | files=$@ | |
21 | ||
22 | echo $files | |
23 | ||
24 | joblog="$jobname-ci.log" | |
25 | ||
26 | parallel -j $jobs --retries $retries \ | |
27 | "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --bail {}" \ | |
28 | ::: $files | |
29 | ||
30 | cat "$joblog" | uniq -c | |
31 | rm "$joblog" | |
32 | } | |
33 | ||
34 | findTestFiles () { | |
35 | exception="-not -name index.js" | |
36 | ||
37 | if [ ! -z ${2+x} ]; then | |
38 | exception="$exception -not -name $2" | |
39 | fi | |
40 | ||
41 | find $1 -type f -name "*.js" $exception | xargs echo | |
42 | } | |
43 | ||
44 | if [ "$1" = "types-package" ]; then | |
45 | npm run generate-types-package 0.0.0 | |
46 | npm run tsc -- --noEmit --esModuleInterop packages/types/tests/test.ts | |
47 | elif [ "$1" = "client" ]; then | |
48 | npm run build | |
49 | ||
50 | feedsFiles=$(findTestFiles ./dist/server/tests/feeds) | |
51 | helperFiles=$(findTestFiles ./dist/server/tests/helpers) | |
52 | libFiles=$(findTestFiles ./dist/server/tests/lib) | |
53 | miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js" | |
54 | # Not in their own task, they need an index.html | |
55 | pluginFiles="./dist/server/tests/plugins/html-injection.js ./dist/server/tests/api/server/plugins.js" | |
56 | ||
57 | MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles | |
58 | elif [ "$1" = "cli-plugin" ]; then | |
59 | npm run build:server | |
60 | npm run setup:cli | |
61 | ||
62 | pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js) | |
63 | cliFiles=$(findTestFiles ./dist/server/tests/cli) | |
64 | ||
65 | MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $pluginsFiles | |
66 | runTest "$1" 1 $cliFiles | |
67 | elif [ "$1" = "api-1" ]; then | |
68 | npm run build:server | |
69 | ||
70 | checkParamFiles=$(findTestFiles ./dist/server/tests/api/check-params) | |
71 | notificationsFiles=$(findTestFiles ./dist/server/tests/api/notifications) | |
72 | searchFiles=$(findTestFiles ./dist/server/tests/api/search) | |
73 | ||
74 | MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $notificationsFiles $searchFiles $checkParamFiles | |
75 | elif [ "$1" = "api-2" ]; then | |
76 | npm run build:server | |
77 | ||
78 | liveFiles=$(findTestFiles ./dist/server/tests/api/live) | |
79 | serverFiles=$(findTestFiles ./dist/server/tests/api/server plugins.js) | |
80 | usersFiles=$(findTestFiles ./dist/server/tests/api/users) | |
81 | ||
82 | MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $liveFiles $serverFiles $usersFiles | |
83 | elif [ "$1" = "api-3" ]; then | |
84 | npm run build:server | |
85 | ||
86 | videosFiles=$(findTestFiles ./dist/server/tests/api/videos) | |
87 | viewsFiles=$(findTestFiles ./dist/server/tests/api/views) | |
88 | ||
89 | MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $viewsFiles $videosFiles | |
90 | elif [ "$1" = "api-4" ]; then | |
91 | npm run build:server | |
92 | ||
93 | moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation) | |
94 | redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy) | |
95 | objectStorageFiles=$(findTestFiles ./dist/server/tests/api/object-storage) | |
96 | activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub) | |
97 | ||
98 | MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles | |
99 | elif [ "$1" = "api-5" ]; then | |
100 | npm run build:server | |
101 | ||
102 | transcodingFiles=$(findTestFiles ./dist/server/tests/api/transcoding) | |
103 | ||
104 | MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $transcodingFiles | |
105 | elif [ "$1" = "external-plugins" ]; then | |
106 | npm run build:server | |
107 | ||
108 | externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins) | |
109 | ||
110 | runTest "$1" 1 $externalPluginsFiles | |
111 | elif [ "$1" = "lint" ]; then | |
112 | npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts" | |
113 | npm run swagger-cli -- validate support/doc/api/openapi.yaml | |
114 | ||
115 | ( cd client | |
116 | npm run lint | |
117 | ) | |
118 | fi |