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
27 changes: 0 additions & 27 deletions src/server/services/__tests__/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,33 +326,6 @@ describe('Github Service - handlePullRequestHook', () => {
expect(mockDb.services.LabelService.labelQueue.add).not.toHaveBeenCalled();
});

test('queues a build when an open deployed PR receives a synchronize event', async () => {
mockHasDeployLabel.mockResolvedValue(true);
mockEnableKillSwitch.mockResolvedValue(false);

const mockPullRequest = createMockPullRequest({
deployOnUpdate: true,
latestCommit: 'previous-commit',
});
mockDb.services.PullRequest.findOrCreatePullRequest.mockResolvedValue(mockPullRequest);

await githubService.handlePullRequestHook(
createMockPullRequestEvent({
action: 'synchronize',
labels: [{ name: 'lifecycle-deploy!' }],
branchSha: 'latest-commit',
})
);

expect(mockGetYamlFileContent).not.toHaveBeenCalled();
expect(mockDb.services.BuildService.createBuildAndDeploys).not.toHaveBeenCalled();
expect(mockPullRequest.__patch).toHaveBeenCalledWith({ latestCommit: 'latest-commit' });
expect(mockDb.models.Build.findOne).toHaveBeenCalledWith({ pullRequestId: 1 });
expect(mockDb.services.BuildService.resolveAndDeployBuildQueue.add).toHaveBeenCalledWith('resolve-deploy', {
buildId: 10,
});
});

test('keeps the existing label sync flow for unlabeled autoDeploy PRs', async () => {
mockGetYamlFileContent.mockResolvedValue({ environment: { autoDeploy: true } });
mockHasDeployLabel.mockResolvedValue(false);
Expand Down
28 changes: 0 additions & 28 deletions src/server/services/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export default class GithubService extends Service {
action as GithubPullRequestActions
);
const isClosed = action === GithubPullRequestActions.CLOSED;
const isSynchronized = action === GithubPullRequestActions.SYNCHRONIZE;
let lifecycleConfig = {} as LifecycleYamlConfigOptions;
let pullRequest: PullRequest, repository: Repository | undefined, build: Build;

Expand Down Expand Up @@ -279,33 +278,6 @@ export default class GithubService extends Service {
labels: labels.map((l) => l.name),
...extractContextForQueue(),
});
} else if (isSynchronized) {
if (branchSha && latestCommit !== branchSha) {
await pullRequest.$query().patch({ latestCommit: branchSha });
}

if (status !== PullRequestStatus.OPEN || pullRequestState?.deployOnUpdate !== true) {
getLogger({}).info(
`PR sync decision: repo=${fullName} branch=${branch} pullRequestId=${pullRequestId} decision=no-deploy deployOnUpdate=${pullRequestState?.deployOnUpdate}`
);
return;
}

build = await this.db.models.Build.findOne({
pullRequestId,
});
if (!build) {
getLogger({}).warn(`Build: not found for synchronized PR repo=${fullName}/${branch}`);
return;
}

getLogger({}).info(
`PR sync decision: repo=${fullName} branch=${branch} pullRequestId=${pullRequestId} decision=queue-build`
);
await this.db.services.BuildService.enqueueResolveAndDeployBuild({
buildId: build.id,
...extractContextForQueue(),
});
}
} catch (error) {
getLogger().fatal({ error }, `Github: PR event handling failed repo=${fullName} branch=${branch}`);
Expand Down
Loading