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 --- shared/extra-utils/miscs/miscs.ts | 10 ++++++---- shared/extra-utils/miscs/sql.ts | 3 +-- shared/extra-utils/server/jobs.ts | 5 ++++- shared/extra-utils/server/servers.ts | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'shared') diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts index 42250886c..08f41a7e7 100644 --- a/shared/extra-utils/miscs/miscs.ts +++ b/shared/extra-utils/miscs/miscs.ts @@ -1,10 +1,10 @@ /* tslint:disable:no-unused-expression */ import * as chai from 'chai' -import { basename, isAbsolute, join, resolve } from 'path' +import { basename, dirname, isAbsolute, join, resolve } from 'path' import * as request from 'supertest' import * as WebTorrent from 'webtorrent' -import { pathExists, readFile } from 'fs-extra' +import { ensureDir, pathExists, readFile } from 'fs-extra' import * as ffmpeg from 'fluent-ffmpeg' const expect = chai.expect @@ -59,12 +59,12 @@ async function testImage (url: string, imageName: string, imagePath: string, ext expect(data.length).to.be.below(maxLength) } -function buildAbsoluteFixturePath (path: string, customTravisPath = false) { +function buildAbsoluteFixturePath (path: string, customCIPath = false) { if (isAbsolute(path)) { return path } - if (customTravisPath && process.env.TRAVIS) return join(process.env.HOME, 'fixtures', path) + if (customCIPath && process.env.GITLAB_CI) return join(root(), 'cached-fixtures', path) return join(root(), 'server', 'tests', 'fixtures', path) } @@ -72,6 +72,8 @@ function buildAbsoluteFixturePath (path: string, customTravisPath = false) { async function generateHighBitrateVideo () { const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true) + await ensureDir(dirname(tempFixturePath)) + const exists = await pathExists(tempFixturePath) if (!exists) { diff --git a/shared/extra-utils/miscs/sql.ts b/shared/extra-utils/miscs/sql.ts index 1961a8762..dfe840d8c 100644 --- a/shared/extra-utils/miscs/sql.ts +++ b/shared/extra-utils/miscs/sql.ts @@ -1,6 +1,5 @@ import { QueryTypes, Sequelize } from 'sequelize' import { ServerInfo } from '../server/servers' -import { PluginType } from '../../models/plugins/plugin.type' let sequelizes: { [ id: number ]: Sequelize } = {} @@ -10,7 +9,7 @@ function getSequelize (internalServerNumber: number) { const dbname = 'peertube_test' + internalServerNumber const username = 'peertube' const password = 'peertube' - const host = 'localhost' + const host = process.env.GITLAB_CI ? 'postgres' : 'localhost' const port = 5432 const seq = new Sequelize(dbname, username, password, { diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts index 692b5e24d..11b570f60 100644 --- a/shared/extra-utils/server/jobs.ts +++ b/shared/extra-utils/server/jobs.ts @@ -2,6 +2,7 @@ import * as request from 'supertest' import { Job, JobState } from '../../models' import { wait } from '../miscs/miscs' import { ServerInfo } from './servers' +import { inspect } from 'util' function getJobsList (url: string, accessToken: string, state: JobState) { const path = '/api/v1/jobs/' + state @@ -49,7 +50,9 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { .then(res => res.body.data) .then((jobs: Job[]) => jobs.filter(j => j.type !== 'videos-views')) .then(jobs => { - if (jobs.length !== 0) pendingRequests = true + if (jobs.length !== 0) { + pendingRequests = true + } }) tasks.push(p) } diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 40cf7f0f3..a0720d778 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -79,8 +79,8 @@ function flushTests (serverNumber?: number) { return new Promise((res, rej) => { const suffix = serverNumber ? ` -- ${serverNumber}` : '' - return exec('npm run clean:server:test' + suffix, err => { - if (err) return rej(err) + return exec('npm run clean:server:test' + suffix, (err, _stdout, stderr) => { + if (err || stderr) return rej(err || new Error(stderr)) return res() }) -- cgit v1.2.3