]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Save logs on ci failure
authorChocobozzz <me@florianbigard.com>
Thu, 10 Dec 2020 10:24:17 +0000 (11:24 +0100)
committerChocobozzz <chocobozzz@cpy.re>
Mon, 14 Dec 2020 08:11:27 +0000 (09:11 +0100)
.github/workflows/test.yml
shared/extra-utils/miscs/miscs.ts
shared/extra-utils/server/servers.ts

index 042ffe0d429f88831454a94e4bf68f718314e76d..0231b1a1ec1db2d60eed9dcd7b5e955bd70d1e02 100644 (file)
@@ -105,4 +105,5 @@ jobs:
         if: failure()
         with:
           name: test-storages-${{ matrix.test_suite }}
-          path: test*/logs/*
+          path: artifacts
+          retention-days: 7
index 764b74bdaea80454c9fb3206b090ac13329b1230..1cb1cf4408189193c4b1ca59e8e8c667fd8a4fda 100644 (file)
@@ -64,6 +64,10 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
   expect(data.length).to.be.below(maxLength, "the generated image is way larger than the recorded fixture")
 }
 
+function isGithubCI () {
+  return !!process.env.GITHUB_WORKSPACE
+}
+
 function buildAbsoluteFixturePath (path: string, customCIPath = false) {
   if (isAbsolute(path)) return path
 
@@ -151,6 +155,7 @@ export {
   getFileSize,
   immutableAssign,
   testImage,
+  isGithubCI,
   buildAbsoluteFixturePath,
   root,
   generateHighBitrateVideo,
index e88482e49c1cf125a734c649d0e8c8a061d4bbcf..fe4ed3e485691d5523655845e3101cfed4a65fcc 100644 (file)
@@ -2,11 +2,11 @@
 
 import { expect } from 'chai'
 import { ChildProcess, exec, fork } from 'child_process'
-import { copy, pathExists, readdir, readFile, remove } from 'fs-extra'
+import { copy, ensureDir, pathExists, readdir, readFile, remove } from 'fs-extra'
 import { join } from 'path'
 import { randomInt } from '../../core-utils/miscs/miscs'
 import { VideoChannel } from '../../models/videos'
-import { buildServerDirectory, getFileSize, root, wait } from '../miscs/miscs'
+import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs'
 
 interface ServerInfo {
   app: ChildProcess
@@ -298,11 +298,23 @@ function killallServers (servers: ServerInfo[]) {
   }
 }
 
-function cleanupTests (servers: ServerInfo[]) {
+async function cleanupTests (servers: ServerInfo[]) {
   killallServers(servers)
 
+  if (isGithubCI()) {
+    await ensureDir('artifacts')
+  }
+
   const p: Promise<any>[] = []
   for (const server of servers) {
+    if (isGithubCI()) {
+      const origin = await buildServerDirectory(server, 'logs/peertube.log')
+      const destname = `peertube-${server.internalServerNumber}.log`
+      console.log('Saving logs %s.', destname)
+
+      await copy(origin, join('artifacts', destname))
+    }
+
     if (server.parallel) {
       p.push(flushTests(server.internalServerNumber))
     }