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
1 change: 1 addition & 0 deletions .env.shadow
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ AWS_BUCKET_REGION=region
AWS_ACCESS_KEY_ID=access_key
AWS_SECRET_ACCESS_KEY=secret_key
AWS_BUCKET_NAME=bucket_name
AWS_BUCKET_PATH=
EXPIRES_IN=3600
8 changes: 6 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const envFormat = z.object({
AWS_ACCESS_KEY_ID: z.string().optional(),
AWS_SECRET_ACCESS_KEY: z.string().optional(),
AWS_BUCKET_NAME: z.string(),
AWS_BUCKET_PATH: z.string(),
AWS_BUCKET_PATH: z.string().optional(),
EXPIRES_IN: z.coerce.number()
});

Expand All @@ -24,11 +24,15 @@ if (config.AWS_ACCESS_KEY_ID && config.AWS_SECRET_ACCESS_KEY) {
};
}

if (config.AWS_BUCKET_PATH?.length && !config.AWS_BUCKET_PATH.endsWith('/')) {
throw new Error('Configuration error: AWS_BUCKET_PATH must end with "/" if specified');
}

export default {
PORT: config.PORT,
AWS_BUCKET_REGION: config.AWS_BUCKET_REGION,
AWS_BUCKET_NAME: config.AWS_BUCKET_NAME,
AWS_BUCKET_PATH: config.AWS_BUCKET_PATH,
AWS_BUCKET_PATH: config.AWS_BUCKET_PATH || '',
EXPIRES_IN: config.EXPIRES_IN,
AWS_CREDENTIALS: awsCredentials,
};
2 changes: 1 addition & 1 deletion src/datasources/ConsoleEvent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ConsoleEvent {
logByTestExecutionIdDataLoader = new DataLoader<string, Record<string, Log>>(
(ids) => Promise.all(ids.map(async (testExecutionId) => {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const json = await S3Service.getObject(bucketName, `${bucketPath}${testExecutionId}/console/console-logs.json`);
const parsed = parseLogFile(json);
return Object.fromEntries(
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/NetworkEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class NetworkEvent {
networkEventsByTestExecutionIdDataLoader = new DataLoader<string, ReturnType<typeof mapNetworkEvents>>(
(ids) => Promise.all(ids.map(async (testExecutionId) => {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const events = await S3Service.getObject(bucketName, `${bucketPath}${testExecutionId}/har/network-events.har`);
const mappedEvents = mapNetworkEvents(events, testExecutionId);

Expand Down
2 changes: 1 addition & 1 deletion src/datasources/Screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Screenshot {
screenshotByTestExecutionIdDataLoader = new DataLoader<string, ReturnType<typeof mapScreenshots>>(
(ids) => Promise.all(ids.map(async (testExecutionId) => {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const screenshots = await S3Service.listObjects(bucketName, `${bucketPath}${testExecutionId}/screenshots/`);
return mapScreenshots(screenshots, testExecutionId)
}))
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/Snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Snapshot {
snapshotByTestExecutionIdDataLoader = new DataLoader<string, ReturnType<typeof mapSnapshots>>(
(ids) => Promise.all(ids.map(async (testExecutionId) => {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const snapshots = await S3Service.getObject(bucketName, `${bucketPath}${testExecutionId}/snapshots/snapshot-metadata.json`);
const mappedSnapshots = mapSnapshots(snapshots, testExecutionId);
return mappedSnapshots;
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/StepEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class StepEvent {
stepByTestExecutionIdDataLoader = new DataLoader<string, ReturnType<typeof mapSteps>>(
(ids) => Promise.all(ids.map(async (testExecutionId) => {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const [steps, results] = await Promise.all([
S3Service.getObject(bucketName, `${bucketPath}${testExecutionId}/cypress/out.json`),
this.context.dataSources.testResults.getResultsByTestExecutionId(testExecutionId),
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/TestCodeRevision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class TestCodeRevision {
cicdDataByRunIdDataLoader = new DataLoader<string, Cicd>(
(ids) => Promise.all(ids.map(async (runId) => {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const cicdRaw = await S3Service.getObject(bucketName, `${bucketPath}${runId}/logs/cicd.json`)
const cicd = CicdSchema.parse(cicdRaw);
return cicd;
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/TestExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class TestExecution {
first?: number | null, after?: string | null;
}) {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const results = await S3Service.listSubFolders(bucketName, `${bucketPath}${id}/`);

const testExecutionIds = results
Expand All @@ -29,7 +29,7 @@ export class TestExecution {

async getById(id: string) {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const [runId, requestId] = id.split('/');
const results = await S3Service.getObject(bucketName, `${bucketPath}${runId}/${requestId}/cypress/results.json`) as {startedTestsAt: string, endedTestsAt: string};

Expand Down
2 changes: 1 addition & 1 deletion src/datasources/TestResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class TestResults {
resultsByTestExecutionIdDataLoader = new DataLoader<string, Results>(
(ids) => Promise.all(ids.map(async (testExecutionId) => {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const rawResults = await S3Service.getObject(bucketName, `${bucketPath}${testExecutionId}/cypress/results.json`)
const results = ResultsSchema.parse(rawResults);
return results;
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/TestRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class TestRun {
first?: number | null, after?: string | null;
}) {
const bucketName = config.AWS_BUCKET_NAME;
const bucketPath = config.AWS_BUCKET_PATH || '';
const bucketPath = config.AWS_BUCKET_PATH;
const results = await S3Service.listSubFolders(bucketName, `${bucketPath}`);

const testExecutionIds = results
Expand Down