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