Skip to content

Commit

Permalink
ARC-2803 skip sending commit association for now (#2626)
Browse files Browse the repository at this point in the history
gxueatlassian authored Jan 9, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
mmarchini mary marchini
1 parent 448806e commit 332b5ae
Showing 3 changed files with 62 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/config/feature-flags.ts
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@ export enum BooleanFlags {
GENERATE_CORE_HEAP_DUMPS_ON_LOW_MEM = "generate-core-heap-dumps-on-low-mem",
USE_RATELIMIT_ON_JIRA_CLIENT = "use-ratelimit-on-jira-client",
SKIP_PROCESS_QUEUE_IF_ISSUE_NOT_FOUND = "skip-process-queue-when-issue-not-exists",
SKIP_COMMIT_IF_SHA_NOT_FOUND_ON_LAST_TRY = "skip-commit-if-sha-not-found-on-last-try"
SKIP_COMMIT_IF_SHA_NOT_FOUND_ON_LAST_TRY = "skip-commit-if-sha-not-found-on-last-try",
SKIP_SENDING_COMMIT_ASSOCIATION = "skip-sending-commit-association"
}

export enum StringFlags {
56 changes: 55 additions & 1 deletion src/transforms/transform-deployment.test.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import deployment_status_staging from "fixtures/deployment_status_staging.json";
import { getRepoConfig } from "services/user-config-service";
import { when } from "jest-when";
import { DatabaseStateCreator } from "test/utils/database-state-creator";
import { shouldSendAll } from "config/feature-flags";
import { shouldSendAll, booleanFlag, BooleanFlags } from "config/feature-flags";
import { cacheSuccessfulDeploymentInfo } from "services/deployment-cache-service";
import { Config } from "interfaces/common";
import { cloneDeep } from "lodash";
@@ -476,6 +476,60 @@ describe("transform GitHub webhook payload to Jira payload", () => {
]));
});

it(`skip sending commits association in deployment for Cloud when ff is on`, async () => {

when(booleanFlag).calledWith(BooleanFlags.SKIP_SENDING_COMMIT_ASSOCIATION, expect.anything()).mockResolvedValue(true);

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);

await cacheSuccessfulDeploymentInfo({
gitHubBaseUrl: gitHubClient.baseUrl,
repositoryId: deployment_status.payload.repository.id,
commitSha: "6e87a40179eb7ecf5094b9c8d690db727472d5bc",
env: "Production",
createdAt: new Date(new Date(deployment_status.payload.deployment_status.created_at).getTime() - 1000)
}, getLogger("deploymentLogger"));

// Mocking all GitHub API Calls
// Get commit
githubNock.get(`/repos/${owner.login}/${repoName}/commits/${deployment_status.payload.deployment.sha}`)
.reply(200, {
...owner,
commit: {
message: "testing"
}
});

// Compare commits
githubNock.get(`/repos/${owner.login}/${repoName}/compare/6e87a40179eb7ecf5094b9c8d690db727472d5bc...${deployment_status.payload.deployment.sha}`)
.reply(200, {
commits: [
{
commit: {
message: "ABC-1"
},
sha: "6e87a40179eb7ecf5094b9c8d690db727472d5bc1"
},
{
commit: {
message: "ABC-2"
},
sha: "6e87a40179eb7ecf5094b9c8d690db727472d5bc2"
}
]
});

const jiraPayload = await transformDeployment(gitHubClient, deployment_status.payload as any, jiraHost, "webhook", getLogger("deploymentLogger"), undefined);

expect(jiraPayload).toMatchObject(buildJiraPayload("testing", [
{
associationType: "issueIdOrKeys",
values: ["ABC-1", "ABC-2"]
}
]));
});

it(`supports branch and merge workflows, sending related commits in deploymentfor Cloud`, async () => {

githubUserTokenNock(DatabaseStateCreator.GITHUB_INSTALLATION_ID);
7 changes: 5 additions & 2 deletions src/transforms/transform-deployment.ts
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import { Subscription } from "models/subscription";
import minimatch from "minimatch";
import { getRepoConfig } from "services/user-config-service";
import { TransformedRepositoryId, transformRepositoryId } from "~/src/transforms/transform-repository-id";
import { shouldSendAll } from "config/feature-flags";
import { shouldSendAll, booleanFlag, BooleanFlags } from "config/feature-flags";
import { findLastSuccessDeploymentFromCache } from "services/deployment-cache-service";
import { statsd } from "config/statsd";
import { metricDeploymentCache } from "config/metric-names";
@@ -367,10 +367,13 @@ export const transformDeployment = async (
}

const allCommitsMessages = extractMessagesFromCommitSummaries(commitSummaries);

const shouldSkipSendingCommitAssociations = await booleanFlag(BooleanFlags.SKIP_SENDING_COMMIT_ASSOCIATION, jiraHost);

const associations = mapJiraIssueIdsCommitsAndServicesToAssociationArray(
jiraIssueKeyParser(`${deployment.ref}\n${message}\n${allCommitsMessages}`),
transformRepositoryId(payload.repository.id, githubInstallationClient.baseUrl),
commitSummaries,
shouldSkipSendingCommitAssociations ? [] : commitSummaries,
config
);

0 comments on commit 332b5ae

Please sign in to comment.