Skip to content

Commit

Permalink
DOP-4414 nits
Browse files Browse the repository at this point in the history
  • Loading branch information
anabellabuckvar committed Mar 20, 2024
1 parent d953ccd commit c0fe254
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
25 changes: 12 additions & 13 deletions api/controllers/v2/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function prepGithubPushPayload(
priority: 1,
error: {},
result: null,
payload: payload,
payload,
logs: [],
};
}
Expand Down Expand Up @@ -89,9 +89,9 @@ async function createPayload({
action = 'push';
jobType = 'githubPush';
branchName = githubEvent.ref.split('/')[2];
url = githubEvent?.repository.clone_url;
newHead = githubEvent?.after;
repoOwner = githubEvent.repository.owner.login;
url = githubEvent.repository?.clone_url;
newHead = githubEvent.after;
repoOwner = githubEvent.repository?.owner?.login;
}

const branchInfo = await repoBranchesRepository.getRepoBranchAliases(repoName, branchName, repoInfo.project);
Expand Down Expand Up @@ -154,15 +154,14 @@ export const triggerSmokeTestAutomatedBuild = async (event: APIGatewayEvent): Pr
};
}

if (body.workflow_run.conclusion != 'success')
return {
statusCode: 202,
headers: { 'Content-Type': 'text/plain' },
body:
'Build on branch ' +
body.workflow_run.head_branch +
' is not complete and will not trigger smoke test site deployments ',
};
return {
statusCode: 202,
headers: { 'Content-Type': 'text/plain' },
body:
'Build on branch ' +
body.workflow_run.head_branch +
' is not complete and will not trigger smoke test site deployments ',
};

if (body.workflow_run.name != 'Deploy Staging ECS')
return {
Expand Down
6 changes: 5 additions & 1 deletion src/repositories/baseRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ export abstract class BaseRepository {
);
}

protected async findOne(query: any, errorMsg: string, options: mongodb.FindOptions = {}): Promise<any> {
protected async findOne(
query: any,
errorMsg: string,
options: mongodb.FindOptions = {}
): Promise<mongodb.WithId<mongodb.BSON.Document> | null> {
try {
return await this.promiseTimeoutS(
this._config.get('MONGO_TIMEOUT_S'),
Expand Down
4 changes: 2 additions & 2 deletions src/repositories/projectsRepository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Db } from 'mongodb';
import mongodb, { Db } from 'mongodb';
import { IConfig } from 'config';
import { BaseRepository } from './baseRepository';
import { ILogger } from '../services/logger';
Expand All @@ -11,7 +11,7 @@ export class ProjectsRepository extends BaseRepository {
super(config, logger, 'ProjectsRepository', db.collection('projects'));
}

async getProjectEntry(name: string): Promise<any> {
async getProjectEntry(name: string): Promise<mongodb.WithId<mongodb.BSON.Document> | null> {
const query = { name: name };
const projectEntry = await this.findOne(
query,
Expand Down
2 changes: 1 addition & 1 deletion src/repositories/repoEntitlementsRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class RepoEntitlementsRepository extends BaseRepository {
`Mongo Timeout Error: Timedout while retrieving entitlements for ${slackUserId}`
);
// if user has specific entitlements
if ((entitlementsObject?.repos?.length ?? 0) > 0) {
if (entitlementsObject?.repos && entitlementsObject.repos.length > 0) {
return {
repos: entitlementsObject.repos,
github_username: entitlementsObject.github_username,
Expand Down

0 comments on commit c0fe254

Please sign in to comment.