X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Fci.sh;h=8fdbe8f26ad1c89cf31ffc11f599a74e6ed5977e;hb=ac82adaaa002bfde9c20189e913aa5207ed483df;hp=448c1c91f44d66d3d15569fd0b9b4f5ee0ccf316;hpb=7abb5c5da1ed7c6945e81b9e3da0a14f623f69ea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/ci.sh b/scripts/ci.sh index 448c1c91f..8fdbe8f26 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -eu @@ -7,81 +7,109 @@ if [ $# -eq 0 ]; then exit -1 fi -killall -q peertube || true - retries=3 -jobs=2 +speedFactor="${2:-1}" runTest () { - retries=3 + jobname=$1 + shift + jobs=$1 shift + files=$@ echo $files - MOCHA_PARALLEL=true parallel -t -j $jobs --retries $retries \ - npm run mocha -- -c --timeout 30000 --exit --require ts-node/register --require tsconfig-paths/register --bail \ + joblog="$jobname-ci.log" + + parallel -j $jobs --retries $retries \ + "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --bail {}" \ ::: $files + + cat "$joblog" | sort | uniq -c + rm "$joblog" } findTestFiles () { - find $1 -type f -name "*.ts" | grep -v index.ts | xargs echo -} + exception="-not -name index.js" -if [ "$1" = "misc" ]; then - npm run build -- --light + if [ ! -z ${2+x} ]; then + exception="$exception -not -name $2" + fi - feedsFiles=$(findTestFiles server/tests/feeds) - helperFiles=$(findTestFiles server/tests/helpers) - pluginsFiles=$(findTestFiles server/tests/plugins) - miscFiles=server/tests/client.ts server/tests/misc-endpoints.ts + find $1 -type f -name "*.js" $exception | xargs echo +} - TS_NODE_FILES=true runTest 2 $feedsFiles $helperFiles $pluginsFiles $miscFiles -elif [ "$1" = "cli" ]; then +if [ "$1" = "types-package" ]; then + npm run generate-types-package 0.0.0 + npm run tsc -- --noEmit --esModuleInterop packages/types/tests/test.ts +elif [ "$1" = "client" ]; then + npm run build + + feedsFiles=$(findTestFiles ./dist/server/tests/feeds) + helperFiles=$(findTestFiles ./dist/server/tests/helpers) + libFiles=$(findTestFiles ./dist/server/tests/lib) + miscFiles="./dist/server/tests/client.js ./dist/server/tests/misc-endpoints.js" + # Not in their own task, they need an index.html + pluginFiles="./dist/server/tests/plugins/html-injection.js ./dist/server/tests/api/server/plugins.js" + + MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $feedsFiles $helperFiles $miscFiles $pluginFiles $libFiles +elif [ "$1" = "cli-plugin" ]; then npm run build:server npm run setup:cli - cliFiles=$(findTestFiles server/tests/cli) + pluginsFiles=$(findTestFiles ./dist/server/tests/plugins html-injection.js) + cliFiles=$(findTestFiles ./dist/server/tests/cli) - runTest 1 $cliFiles + MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $pluginsFiles + runTest "$1" 1 $cliFiles elif [ "$1" = "api-1" ]; then npm run build:server - checkParamFiles=$(findTestFiles server/tests/api/check-params) - notificationsFiles=$(findTestFiles server/tests/api/notifications) - searchFiles=$(findTestFiles server/tests/api/search) + checkParamFiles=$(findTestFiles ./dist/server/tests/api/check-params) + notificationsFiles=$(findTestFiles ./dist/server/tests/api/notifications) + searchFiles=$(findTestFiles ./dist/server/tests/api/search) - runTest 2 $notificationsFiles $searchFiles $checkParamFiles + MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $notificationsFiles $searchFiles $checkParamFiles elif [ "$1" = "api-2" ]; then npm run build:server - serverFiles=$(findTestFiles server/tests/api/server) - usersFiles=$(findTestFiles server/tests/api/users) + liveFiles=$(findTestFiles ./dist/server/tests/api/live) + serverFiles=$(findTestFiles ./dist/server/tests/api/server plugins.js) + usersFiles=$(findTestFiles ./dist/server/tests/api/users) - runTest 2 $serverFiles $usersFiles + MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $liveFiles $serverFiles $usersFiles elif [ "$1" = "api-3" ]; then npm run build:server - videosFiles=$(findTestFiles server/tests/api/videos) + videosFiles=$(findTestFiles ./dist/server/tests/api/videos) + viewsFiles=$(findTestFiles ./dist/server/tests/api/views) - runTest 1 $videosFiles + MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $viewsFiles $videosFiles elif [ "$1" = "api-4" ]; then npm run build:server - activitypubFiles=$(findTestFiles server/tests/api/moderation) - redundancyFiles=$(findTestFiles server/tests/api/redundancy) - activitypubFiles=$(findTestFiles server/tests/api/activitypub) + moderationFiles=$(findTestFiles ./dist/server/tests/api/moderation) + redundancyFiles=$(findTestFiles ./dist/server/tests/api/redundancy) + objectStorageFiles=$(findTestFiles ./dist/server/tests/api/object-storage) + activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub) + + MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles +elif [ "$1" = "api-5" ]; then + npm run build:server + + transcodingFiles=$(findTestFiles ./dist/server/tests/api/transcoding) - TS_NODE_FILES=true runTest 2 $activitypubFiles $redundancyFiles $activitypubFiles + MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $transcodingFiles elif [ "$1" = "external-plugins" ]; then npm run build:server - externalPluginsFiles=$(findTestFiles server/tests/external-plugins) + externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins) - runTest 1 $externalPluginsFiles + runTest "$1" 1 $externalPluginsFiles elif [ "$1" = "lint" ]; then - npm run eslint -- --ext .ts "server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts" + npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts" npm run swagger-cli -- validate support/doc/api/openapi.yaml ( cd client