Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/commander/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Command } from 'commander';
import { Context } from '../types.js';
import { color, Listr, ListrDefaultRendererLogLevels } from 'listr2';
import startServer from '../tasks/startServer.js';
import auth from '../tasks/auth.js';
import authExec from '../tasks/authExec.js';
import ctxInit from '../lib/ctx.js';
import getGitInfo from '../tasks/getGitInfo.js';
import createBuild from '../tasks/createBuild.js';
import createBuildExec from '../tasks/createBuildExec.js';
import snapshotQueue from '../lib/snapshotQueue.js';
import { startPolling, startPingPolling } from '../lib/utils.js';

Expand All @@ -30,10 +30,10 @@ command

let tasks = new Listr<Context>(
[
auth(ctx),
authExec(ctx),
startServer(ctx),
getGitInfo(ctx),
createBuild(ctx),
createBuildExec(ctx),

],
{
Expand Down
45 changes: 33 additions & 12 deletions src/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,44 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
}
}, 1000);
})
await ctx.client.finalizeBuild(ctx.build.id, ctx.totalSnapshots, ctx.log);

for (const [sessionId, capabilities] of ctx.sessionCapabilitiesMap.entries()) {
try {
const buildId = capabilities?.buildId || '';
const projectToken = capabilities?.projectToken || '';
const totalSnapshots = capabilities?.snapshotCount || 0;
const sessionBuildUrl = capabilities?.buildURL || '';
const testId = capabilities?.id || '';

if (buildId && projectToken) {
await ctx.client.finalizeBuildForCapsWithToken(buildId, totalSnapshots, projectToken, ctx.log);
}

if (testId && buildId) {
buildUrls += `TestId ${testId}: ${sessionBuildUrl}\n`;
}
} catch (error: any) {
ctx.log.debug(`Error finalizing build for session ${sessionId}: ${error.message}`);
}
}

if (ctx.build && ctx.build.id) {
await ctx.client.finalizeBuild(ctx.build.id, ctx.totalSnapshots, ctx.log);
let uploadCLILogsToS3 = ctx?.config?.useLambdaInternal || uploadDomToS3ViaEnv;
if (!uploadCLILogsToS3) {
ctx.log.debug(`Log file to be uploaded`)
let resp = await ctx.client.getS3PreSignedURL(ctx);
await ctx.client.uploadLogs(ctx, resp.data.url);
} else {
ctx.log.debug(`Skipping upload of CLI logs as useLambdaInternal is set`)
}
}

await ctx.browser?.close();
if (ctx.server){
ctx.server.close();
}

let uploadCLILogsToS3 = ctx?.config?.useLambdaInternal || uploadDomToS3ViaEnv;
if (!uploadCLILogsToS3) {
ctx.log.debug(`Log file to be uploaded`)
let resp = await ctx.client.getS3PreSignedURL(ctx);
await ctx.client.uploadLogs(ctx, resp.data.url);
} else {
ctx.log.debug(`Skipping upload of CLI logs as useLambdaInternal is set`)
// ctx.log.debug(`Log file to be uploaded via LSRS`)
// let resp = ctx.client.sendCliLogsToLSRS(ctx);
}

if (pingIntervalId !== null) {
clearInterval(pingIntervalId);
ctx.log.debug('Ping polling stopped immediately.');
Expand Down