From 2284f202070aa2e49156cc52b3b1596a7d5aadec Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 29 Jul 2019 11:59:29 +0200 Subject: Add gitlab ci support --- scripts/ci.sh | 41 +++++++++++++++++++++++++++++++++++++++++ scripts/clean/server/test.sh | 13 +++++++++---- scripts/nightly.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ scripts/test.sh | 2 +- scripts/travis.sh | 41 ----------------------------------------- 5 files changed, 93 insertions(+), 46 deletions(-) create mode 100755 scripts/ci.sh create mode 100755 scripts/nightly.sh delete mode 100755 scripts/travis.sh (limited to 'scripts') diff --git a/scripts/ci.sh b/scripts/ci.sh new file mode 100755 index 000000000..1819f73dd --- /dev/null +++ b/scripts/ci.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +set -eu + +if [ $# -eq 0 ]; then + echo "Need test suite argument." + exit -1 +fi + +killall -q peertube || true + +if [ "$1" = "misc" ]; then + npm run build -- --light-fr + mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/client.ts \ + server/tests/feeds/index.ts \ + server/tests/misc-endpoints.ts \ + server/tests/helpers/index.ts \ + server/tests/plugins/index.ts +elif [ "$1" = "cli" ]; then + npm run build:server + CC=gcc-4.9 CXX=g++-4.9 npm run setup:cli + mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/cli/index.ts +elif [ "$1" = "api-1" ]; then + npm run build:server + sh ./server/tests/api/ci-1.sh 2 +elif [ "$1" = "api-2" ]; then + npm run build:server + sh ./server/tests/api/ci-2.sh 2 +elif [ "$1" = "api-3" ]; then + npm run build:server + sh ./server/tests/api/ci-3.sh 2 +elif [ "$1" = "api-4" ]; then + npm run build:server + sh ./server/tests/api/ci-4.sh 2 +elif [ "$1" = "lint" ]; then + npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts" + + ( cd client + npm run lint + ) +fi diff --git a/scripts/clean/server/test.sh b/scripts/clean/server/test.sh index 20745170d..dbd399aaa 100755 --- a/scripts/clean/server/test.sh +++ b/scripts/clean/server/test.sh @@ -5,7 +5,7 @@ set -eu recreateDB () { dbname="peertube_test$1" - dropdb --if-exists "$dbname" + dropdb --if-exists "$dbname" 2>&1 createdb -O peertube "$dbname" psql -c "CREATE EXTENSION pg_trgm;" "$dbname" & @@ -18,10 +18,15 @@ removeFiles () { dropRedis () { port=$((9000+$1)) + host="localhost" - redis-cli KEYS "bull-localhost:$port*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL - redis-cli KEYS "redis-localhost:$port*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL - redis-cli KEYS "*redis-localhost:$port-" | grep -v empty | xargs --no-run-if-empty redis-cli DEL + if [ ! -z ${GITLAB_CI+x} ]; then + host="redis" + fi + + redis-cli -h "$host" KEYS "bull-localhost:$port*" | grep -v empty | xargs --no-run-if-empty redis-cli -h "$host" DEL + redis-cli -h "$host" KEYS "redis-localhost:$port*" | grep -v empty | xargs --no-run-if-empty redis-cli -h "$host" DEL + redis-cli -h "$host" KEYS "*redis-localhost:$port-" | grep -v empty | xargs --no-run-if-empty redis-cli -h "$host" DEL } seq=$(seq 1 6) diff --git a/scripts/nightly.sh b/scripts/nightly.sh new file mode 100755 index 000000000..bde5d57b9 --- /dev/null +++ b/scripts/nightly.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -eu + +shutdown() { + # Get our process group id + # shellcheck disable=SC2009 + PGID=$(ps -o pgid= $$ | grep -o "[0-9]*") + + # Kill it in a new new process group + setsid kill -- -"$PGID" + exit 0 +} + +trap "shutdown" SIGINT SIGTERM + +today=$(date '+%F') +directory_name="peertube-nightly-$today" +tar_name="peertube-nightly-$today.tar.xz" + +npm run build + +# Creating the archives +( + # local variables + directories_to_archive=("$directory_name/CREDITS.md" "$directory_name/FAQ.md" \ + "$directory_name/LICENSE" "$directory_name/README.md" \ + "$directory_name/client/dist/" "$directory_name/client/yarn.lock" \ + "$directory_name/client/package.json" "$directory_name/config" \ + "$directory_name/dist" "$directory_name/package.json" \ + "$directory_name/scripts" "$directory_name/support" \ + "$directory_name/tsconfig.json" "$directory_name/yarn.lock") + + # temporary setup + cd .. + ln -s "PeerTube" "$directory_name" + + XZ_OPT=-e9 tar cfJ "PeerTube/$tar_name" "${directories_to_archive[@]}" + + # temporary setup destruction + rm "$directory_name" +) diff --git a/scripts/test.sh b/scripts/test.sh index 5ec7a5920..1b6b29b66 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -5,6 +5,6 @@ set -eu npm run build:server npm run setup:cli -npm run travis -- lint +npm run ci -- lint mocha --exit --require ts-node/register/type-check --bail server/tests/index.ts diff --git a/scripts/travis.sh b/scripts/travis.sh deleted file mode 100755 index 42e2329c6..000000000 --- a/scripts/travis.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -set -eu - -if [ $# -eq 0 ]; then - echo "Need test suite argument." - exit -1 -fi - -killall -q peertube || true - -if [ "$1" = "misc" ]; then - npm run build -- --light-fr - mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/client.ts \ - server/tests/feeds/index.ts \ - server/tests/misc-endpoints.ts \ - server/tests/helpers/index.ts \ - server/tests/plugins/index.ts -elif [ "$1" = "cli" ]; then - npm run build:server - CC=gcc-4.9 CXX=g++-4.9 npm run setup:cli - mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/cli/index.ts -elif [ "$1" = "api-1" ]; then - npm run build:server - sh ./server/tests/api/travis-1.sh 2 -elif [ "$1" = "api-2" ]; then - npm run build:server - sh ./server/tests/api/travis-2.sh 2 -elif [ "$1" = "api-3" ]; then - npm run build:server - sh ./server/tests/api/travis-3.sh 2 -elif [ "$1" = "api-4" ]; then - npm run build:server - sh ./server/tests/api/travis-4.sh 2 -elif [ "$1" = "lint" ]; then - npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts" - - ( cd client - npm run lint - ) -fi -- cgit v1.2.3