aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils')
-rw-r--r--shared/extra-utils/miscs/miscs.ts5
-rw-r--r--shared/extra-utils/server/servers.ts18
2 files changed, 20 insertions, 3 deletions
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts
index 764b74bda..1cb1cf440 100644
--- a/shared/extra-utils/miscs/miscs.ts
+++ b/shared/extra-utils/miscs/miscs.ts
@@ -64,6 +64,10 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
64 expect(data.length).to.be.below(maxLength, "the generated image is way larger than the recorded fixture") 64 expect(data.length).to.be.below(maxLength, "the generated image is way larger than the recorded fixture")
65} 65}
66 66
67function isGithubCI () {
68 return !!process.env.GITHUB_WORKSPACE
69}
70
67function buildAbsoluteFixturePath (path: string, customCIPath = false) { 71function buildAbsoluteFixturePath (path: string, customCIPath = false) {
68 if (isAbsolute(path)) return path 72 if (isAbsolute(path)) return path
69 73
@@ -151,6 +155,7 @@ export {
151 getFileSize, 155 getFileSize,
152 immutableAssign, 156 immutableAssign,
153 testImage, 157 testImage,
158 isGithubCI,
154 buildAbsoluteFixturePath, 159 buildAbsoluteFixturePath,
155 root, 160 root,
156 generateHighBitrateVideo, 161 generateHighBitrateVideo,
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index e88482e49..fe4ed3e48 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -2,11 +2,11 @@
2 2
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { ChildProcess, exec, fork } from 'child_process' 4import { ChildProcess, exec, fork } from 'child_process'
5import { copy, pathExists, readdir, readFile, remove } from 'fs-extra' 5import { copy, ensureDir, pathExists, readdir, readFile, remove } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { randomInt } from '../../core-utils/miscs/miscs' 7import { randomInt } from '../../core-utils/miscs/miscs'
8import { VideoChannel } from '../../models/videos' 8import { VideoChannel } from '../../models/videos'
9import { buildServerDirectory, getFileSize, root, wait } from '../miscs/miscs' 9import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs'
10 10
11interface ServerInfo { 11interface ServerInfo {
12 app: ChildProcess 12 app: ChildProcess
@@ -298,11 +298,23 @@ function killallServers (servers: ServerInfo[]) {
298 } 298 }
299} 299}
300 300
301function cleanupTests (servers: ServerInfo[]) { 301async function cleanupTests (servers: ServerInfo[]) {
302 killallServers(servers) 302 killallServers(servers)
303 303
304 if (isGithubCI()) {
305 await ensureDir('artifacts')
306 }
307
304 const p: Promise<any>[] = [] 308 const p: Promise<any>[] = []
305 for (const server of servers) { 309 for (const server of servers) {
310 if (isGithubCI()) {
311 const origin = await buildServerDirectory(server, 'logs/peertube.log')
312 const destname = `peertube-${server.internalServerNumber}.log`
313 console.log('Saving logs %s.', destname)
314
315 await copy(origin, join('artifacts', destname))
316 }
317
306 if (server.parallel) { 318 if (server.parallel) {
307 p.push(flushTests(server.internalServerNumber)) 319 p.push(flushTests(server.internalServerNumber))
308 } 320 }