ci.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/bash
  2. set -eu
  3. if [ $# -eq 0 ]; then
  4. echo "Need test suite argument."
  5. exit -1
  6. fi
  7. killall -q peertube || true
  8. retries=3
  9. jobs=2
  10. runTest () {
  11. retries=3
  12. jobname=$1
  13. shift
  14. jobs=$1
  15. shift
  16. files=$@
  17. echo $files
  18. joblog="$jobname-ci.log"
  19. parallel -j $jobs --retries $retries \
  20. "echo Trying {} >> $joblog; npm run mocha -- -c --timeout 30000 --exit --require ts-node/register --require tsconfig-paths/register --bail {}" \
  21. ::: $files
  22. cat "$joblog" | uniq -c
  23. rm "$joblog"
  24. }
  25. findTestFiles () {
  26. find $1 -type f -name "*.ts" | grep -v "/index.ts" | xargs echo
  27. }
  28. if [ "$1" = "misc" ]; then
  29. npm run build
  30. feedsFiles=$(findTestFiles server/tests/feeds)
  31. helperFiles=$(findTestFiles server/tests/helpers)
  32. pluginsFiles=$(findTestFiles server/tests/plugins)
  33. miscFiles="server/tests/client.ts server/tests/misc-endpoints.ts"
  34. TS_NODE_FILES=true runTest "$1" 1 $feedsFiles $helperFiles $pluginsFiles $miscFiles
  35. elif [ "$1" = "cli" ]; then
  36. npm run build:server
  37. npm run setup:cli
  38. cliFiles=$(findTestFiles server/tests/cli)
  39. runTest "$1" 1 $cliFiles
  40. elif [ "$1" = "api-1" ]; then
  41. npm run build:server
  42. checkParamFiles=$(findTestFiles server/tests/api/check-params)
  43. notificationsFiles=$(findTestFiles server/tests/api/notifications)
  44. searchFiles=$(findTestFiles server/tests/api/search)
  45. MOCHA_PARALLEL=true runTest "$1" 3 $notificationsFiles $searchFiles $checkParamFiles
  46. elif [ "$1" = "api-2" ]; then
  47. npm run build:server
  48. serverFiles=$(findTestFiles server/tests/api/server)
  49. usersFiles=$(findTestFiles server/tests/api/users)
  50. liveFiles=$(findTestFiles server/tests/api/live)
  51. MOCHA_PARALLEL=true runTest "$1" 3 $serverFiles $usersFiles $liveFiles
  52. elif [ "$1" = "api-3" ]; then
  53. npm run build:server
  54. videosFiles=$(findTestFiles server/tests/api/videos)
  55. MOCHA_PARALLEL=true runTest "$1" 3 $videosFiles
  56. elif [ "$1" = "api-4" ]; then
  57. npm run build:server
  58. activitypubFiles=$(findTestFiles server/tests/api/moderation)
  59. redundancyFiles=$(findTestFiles server/tests/api/redundancy)
  60. activitypubFiles=$(findTestFiles server/tests/api/activitypub)
  61. MOCHA_PARALLEL=true TS_NODE_FILES=true runTest "$1" 2 $activitypubFiles $redundancyFiles $activitypubFiles
  62. elif [ "$1" = "external-plugins" ]; then
  63. npm run build:server
  64. externalPluginsFiles=$(findTestFiles server/tests/external-plugins)
  65. runTest "$1" 1 $externalPluginsFiles
  66. elif [ "$1" = "lint" ]; then
  67. npm run eslint -- --ext .ts "server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts"
  68. npm run swagger-cli -- validate support/doc/api/openapi.yaml
  69. ( cd client
  70. npm run lint
  71. )
  72. fi