diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-10 11:24:17 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-12-14 09:11:27 +0100 |
commit | 83ef31fe10061f0d3db0df1bc5e7f208972982eb (patch) | |
tree | 5d6878c5803e1181ad1a7749c62da56e6f8607e5 /shared/extra-utils | |
parent | 040d6896a3cd5622e78cccdedd8cce2afcf49a31 (diff) | |
download | PeerTube-83ef31fe10061f0d3db0df1bc5e7f208972982eb.tar.gz PeerTube-83ef31fe10061f0d3db0df1bc5e7f208972982eb.tar.zst PeerTube-83ef31fe10061f0d3db0df1bc5e7f208972982eb.zip |
Save logs on ci failure
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/miscs/miscs.ts | 5 | ||||
-rw-r--r-- | shared/extra-utils/server/servers.ts | 18 |
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 | ||
67 | function isGithubCI () { | ||
68 | return !!process.env.GITHUB_WORKSPACE | ||
69 | } | ||
70 | |||
67 | function buildAbsoluteFixturePath (path: string, customCIPath = false) { | 71 | function 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 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { ChildProcess, exec, fork } from 'child_process' | 4 | import { ChildProcess, exec, fork } from 'child_process' |
5 | import { copy, pathExists, readdir, readFile, remove } from 'fs-extra' | 5 | import { copy, ensureDir, pathExists, readdir, readFile, remove } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { randomInt } from '../../core-utils/miscs/miscs' | 7 | import { randomInt } from '../../core-utils/miscs/miscs' |
8 | import { VideoChannel } from '../../models/videos' | 8 | import { VideoChannel } from '../../models/videos' |
9 | import { buildServerDirectory, getFileSize, root, wait } from '../miscs/miscs' | 9 | import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs' |
10 | 10 | ||
11 | interface ServerInfo { | 11 | interface ServerInfo { |
12 | app: ChildProcess | 12 | app: ChildProcess |
@@ -298,11 +298,23 @@ function killallServers (servers: ServerInfo[]) { | |||
298 | } | 298 | } |
299 | } | 299 | } |
300 | 300 | ||
301 | function cleanupTests (servers: ServerInfo[]) { | 301 | async 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 | } |