Skip to content

Commit 332b5ae

Browse files
ARC-2803 skip sending commit association for now (#2626)
1 parent 448806e commit 332b5ae

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

src/config/feature-flags.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export enum BooleanFlags {
2727
GENERATE_CORE_HEAP_DUMPS_ON_LOW_MEM = "generate-core-heap-dumps-on-low-mem",
2828
USE_RATELIMIT_ON_JIRA_CLIENT = "use-ratelimit-on-jira-client",
2929
SKIP_PROCESS_QUEUE_IF_ISSUE_NOT_FOUND = "skip-process-queue-when-issue-not-exists",
30-
SKIP_COMMIT_IF_SHA_NOT_FOUND_ON_LAST_TRY = "skip-commit-if-sha-not-found-on-last-try"
30+
SKIP_COMMIT_IF_SHA_NOT_FOUND_ON_LAST_TRY = "skip-commit-if-sha-not-found-on-last-try",
31+
SKIP_SENDING_COMMIT_ASSOCIATION = "skip-sending-commit-association"
3132
}
3233

3334
export enum StringFlags {

src/transforms/transform-deployment.test.ts

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import deployment_status_staging from "fixtures/deployment_status_staging.json";
99
import { getRepoConfig } from "services/user-config-service";
1010
import { when } from "jest-when";
1111
import { DatabaseStateCreator } from "test/utils/database-state-creator";
12-
import { shouldSendAll } from "config/feature-flags";
12+
import { shouldSendAll, booleanFlag, BooleanFlags } from "config/feature-flags";
1313
import { cacheSuccessfulDeploymentInfo } from "services/deployment-cache-service";
1414
import { Config } from "interfaces/common";
1515
import { cloneDeep } from "lodash";
@@ -476,6 +476,60 @@ describe("transform GitHub webhook payload to Jira payload", () => {
476476
]));
477477
});
478478

479+
it(`skip sending commits association in deployment for Cloud when ff is on`, async () => {
480+
481+
when(booleanFlag).calledWith(BooleanFlags.SKIP_SENDING_COMMIT_ASSOCIATION, expect.anything()).mockResolvedValue(true);
482+
483+
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
484+
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
485+
486+
await cacheSuccessfulDeploymentInfo({
487+
gitHubBaseUrl: gitHubClient.baseUrl,
488+
repositoryId: deployment_status.payload.repository.id,
489+
commitSha: "6e87a40179eb7ecf5094b9c8d690db727472d5bc",
490+
env: "Production",
491+
createdAt: new Date(new Date(deployment_status.payload.deployment_status.created_at).getTime() - 1000)
492+
}, getLogger("deploymentLogger"));
493+
494+
// Mocking all GitHub API Calls
495+
// Get commit
496+
githubNock.get(`/repos/${owner.login}/${repoName}/commits/${deployment_status.payload.deployment.sha}`)
497+
.reply(200, {
498+
...owner,
499+
commit: {
500+
message: "testing"
501+
}
502+
});
503+
504+
// Compare commits
505+
githubNock.get(`/repos/${owner.login}/${repoName}/compare/6e87a40179eb7ecf5094b9c8d690db727472d5bc...${deployment_status.payload.deployment.sha}`)
506+
.reply(200, {
507+
commits: [
508+
{
509+
commit: {
510+
message: "ABC-1"
511+
},
512+
sha: "6e87a40179eb7ecf5094b9c8d690db727472d5bc1"
513+
},
514+
{
515+
commit: {
516+
message: "ABC-2"
517+
},
518+
sha: "6e87a40179eb7ecf5094b9c8d690db727472d5bc2"
519+
}
520+
]
521+
});
522+
523+
const jiraPayload = await transformDeployment(gitHubClient, deployment_status.payload as any, jiraHost, "webhook", getLogger("deploymentLogger"), undefined);
524+
525+
expect(jiraPayload).toMatchObject(buildJiraPayload("testing", [
526+
{
527+
associationType: "issueIdOrKeys",
528+
values: ["ABC-1", "ABC-2"]
529+
}
530+
]));
531+
});
532+
479533
it(`supports branch and merge workflows, sending related commits in deploymentfor Cloud`, async () => {
480534

481535
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);

src/transforms/transform-deployment.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Subscription } from "models/subscription";
1616
import minimatch from "minimatch";
1717
import { getRepoConfig } from "services/user-config-service";
1818
import { TransformedRepositoryId, transformRepositoryId } from "~/src/transforms/transform-repository-id";
19-
import { shouldSendAll } from "config/feature-flags";
19+
import { shouldSendAll, booleanFlag, BooleanFlags } from "config/feature-flags";
2020
import { findLastSuccessDeploymentFromCache } from "services/deployment-cache-service";
2121
import { statsd } from "config/statsd";
2222
import { metricDeploymentCache } from "config/metric-names";
@@ -367,10 +367,13 @@ export const transformDeployment = async (
367367
}
368368

369369
const allCommitsMessages = extractMessagesFromCommitSummaries(commitSummaries);
370+
371+
const shouldSkipSendingCommitAssociations = await booleanFlag(BooleanFlags.SKIP_SENDING_COMMIT_ASSOCIATION, jiraHost);
372+
370373
const associations = mapJiraIssueIdsCommitsAndServicesToAssociationArray(
371374
jiraIssueKeyParser(`${deployment.ref}\n${message}\n${allCommitsMessages}`),
372375
transformRepositoryId(payload.repository.id, githubInstallationClient.baseUrl),
373-
commitSummaries,
376+
shouldSkipSendingCommitAssociations ? [] : commitSummaries,
374377
config
375378
);
376379

0 commit comments

Comments
 (0)