]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/ci.sh
Improve responsive on medium destkop screens
[github/Chocobozzz/PeerTube.git] / scripts / ci.sh
CommitLineData
12e8547f 1#!/bin/bash
0e4ffb4b
LA
2
3set -eu
18530063
C
4
5if [ $# -eq 0 ]; then
6 echo "Need test suite argument."
7 exit -1
8fi
9
7abb5c5d 10retries=3
57e4e1c1 11speedFactor="${2:-1}"
7abb5c5d
C
12
13runTest () {
17ae86e9
C
14 jobname=$1
15 shift
16
7abb5c5d
C
17 jobs=$1
18 shift
17ae86e9 19
7abb5c5d
C
20 files=$@
21
22 echo $files
23
17ae86e9
C
24 joblog="$jobname-ci.log"
25
59fd824c 26 parallel -j $jobs --retries $retries \
f8360396 27 "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --bail {}" \
7abb5c5d 28 ::: $files
17ae86e9 29
14b3e8f4 30 cat "$joblog" | sort | uniq -c
17ae86e9 31 rm "$joblog"
7abb5c5d
C
32}
33
34findTestFiles () {
29b7426c
C
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
7abb5c5d 42}
be7ca0c6 43
6627dbc9 44if [ "$1" = "types-package" ]; then
21d68e68 45 npm run generate-types-package 0.0.0
6627dbc9 46 npm run tsc -- --noEmit --esModuleInterop packages/types/tests/test.ts
b969539c 47elif [ "$1" = "client" ]; then
59fd824c 48 npm run build
7abb5c5d 49
3d470a53
C
50 feedsFiles=$(findTestFiles ./dist/server/tests/feeds)
51 helperFiles=$(findTestFiles ./dist/server/tests/helpers)
2b9f672b 52 libFiles=$(findTestFiles ./dist/server/tests/lib)
3d470a53 53 miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js"
db1ccd05
C
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"
7abb5c5d 56
57e4e1c1 57 MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles
29b7426c 58elif [ "$1" = "cli-plugin" ]; then
1e3e64a6
C
59 # Simulate HTML
60 mkdir -p "./client/dist/en-US/"
61 cp "./client/src/index.html" "./client/dist/en-US/index.html"
62
1b6b4757 63 npm run build:server
b488ba1e 64 npm run setup:cli
7abb5c5d 65
29b7426c 66 pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js)
3d470a53 67 cliFiles=$(findTestFiles ./dist/server/tests/cli)
7abb5c5d 68
57e4e1c1 69 MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $pluginsFiles
17ae86e9 70 runTest "$1" 1 $cliFiles
1297eb5d 71elif [ "$1" = "api-1" ]; then
15f25480 72 npm run build:server
7abb5c5d 73
3d470a53
C
74 checkParamFiles=$(findTestFiles ./dist/server/tests/api/check-params)
75 notificationsFiles=$(findTestFiles ./dist/server/tests/api/notifications)
76 searchFiles=$(findTestFiles ./dist/server/tests/api/search)
7abb5c5d 77
57e4e1c1 78 MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $notificationsFiles $searchFiles $checkParamFiles
1297eb5d 79elif [ "$1" = "api-2" ]; then
15f25480 80 npm run build:server
7abb5c5d 81
8ebf2a5d 82 liveFiles=$(findTestFiles ./dist/server/tests/api/live)
db1ccd05 83 serverFiles=$(findTestFiles ./dist/server/tests/api/server plugins.js)
3d470a53 84 usersFiles=$(findTestFiles ./dist/server/tests/api/users)
7abb5c5d 85
57e4e1c1 86 MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $liveFiles $serverFiles $usersFiles
1297eb5d
C
87elif [ "$1" = "api-3" ]; then
88 npm run build:server
7abb5c5d 89
3d470a53 90 videosFiles=$(findTestFiles ./dist/server/tests/api/videos)
b2111066 91 viewsFiles=$(findTestFiles ./dist/server/tests/api/views)
7abb5c5d 92
b2111066 93 MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $viewsFiles $videosFiles
2fbe7f19 94elif [ "$1" = "api-4" ]; then
46b2cec7 95 npm run build:server
7abb5c5d 96
3d470a53
C
97 moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation)
98 redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy)
0305db28 99 objectStorageFiles=$(findTestFiles ./dist/server/tests/api/object-storage)
3d470a53 100 activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub)
7abb5c5d 101
57e4e1c1 102 MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles
95faf1ea
C
103elif [ "$1" = "api-5" ]; then
104 npm run build:server
105
106 transcodingFiles=$(findTestFiles ./dist/server/tests/api/transcoding)
1772b383 107 runnersFiles=$(findTestFiles ./dist/server/tests/api/runners)
95faf1ea 108
1772b383 109 MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $transcodingFiles $runnersFiles
829b794a
C
110elif [ "$1" = "external-plugins" ]; then
111 npm run build:server
1772b383 112 npm run build:peertube-runner
7abb5c5d 113
3d470a53 114 externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins)
1772b383 115 peertubeRunnerFiles=$(findTestFiles ./dist/server/tests/peertube-runner)
7abb5c5d 116
6403a6bd
C
117 runTest "$1" 1 $externalPluginsFiles
118 MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $peertubeRunnerFiles
18530063 119elif [ "$1" = "lint" ]; then
3d470a53 120 npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts"
a3705089 121 npm run swagger-cli -- validate support/doc/api/openapi.yaml
f2659ae0 122
0e4ffb4b
LA
123 ( cd client
124 npm run lint
125 )
18530063 126fi