From 803ee396fd310dbbc7a3c6b18bd05c2d14b75557 Mon Sep 17 00:00:00 2001 From: Alden Quimby Date: Tue, 6 Jun 2023 09:52:55 -0400 Subject: [PATCH 1/3] Provide environment URL when possible --- src/github/client/github-queries.ts | 12 +++++++----- src/interfaces/jira.ts | 1 + src/sync/deployment.ts | 1 + src/transforms/transform-deployment.ts | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/github/client/github-queries.ts b/src/github/client/github-queries.ts index 4625772224..4f448d13d9 100644 --- a/src/github/client/github-queries.ts +++ b/src/github/client/github-queries.ts @@ -380,6 +380,7 @@ export type DeploymentQueryNode = { createdAt: string, updatedAt: string, state: string, + environmentUrl: string, logUrl: string }[] }, @@ -408,7 +409,7 @@ export const getDeploymentsQuery = `query ($owner: String!, $repo: String!, $per edges { cursor node { - createdAt + createdAt repository { id: databaseId node_id: id @@ -431,7 +432,7 @@ export const getDeploymentsQuery = `query ($owner: String!, $repo: String!, $per logUrl state id - createdAt + createdAt updatedAt } } @@ -446,7 +447,7 @@ export const getDeploymentsQueryWithStatuses = `query ($owner: String!, $repo: S edges { cursor node { - createdAt + createdAt repository { id: databaseId node_id: id @@ -469,7 +470,8 @@ export const getDeploymentsQueryWithStatuses = `query ($owner: String!, $repo: S createdAt updatedAt state - logUrl + logUrl + environmentUrl } } latestStatus { @@ -477,7 +479,7 @@ export const getDeploymentsQueryWithStatuses = `query ($owner: String!, $repo: S logUrl state id - createdAt + createdAt updatedAt } } diff --git a/src/interfaces/jira.ts b/src/interfaces/jira.ts index 88c737f85b..c87ea8173e 100644 --- a/src/interfaces/jira.ts +++ b/src/interfaces/jira.ts @@ -147,6 +147,7 @@ export interface JiraDeployment { id: string; displayName: string; type: string; + url?: string; }; associations: JiraAssociation[]; } diff --git a/src/sync/deployment.ts b/src/sync/deployment.ts index b6bd30f2d6..8969fdc140 100644 --- a/src/sync/deployment.ts +++ b/src/sync/deployment.ts @@ -60,6 +60,7 @@ const getTransformedDeployments = async (useDynamoForBackfill: boolean, deployme environment: deployment.environment, id: deployment.databaseId, target_url: logUrl, + environment_url: firstNonInactiveStatus?.environmentUrl || deployment.latestStatus?.environmentUrl, created_at: firstNonInactiveStatus?.createdAt || deployment.latestStatus?.createdAt, updated_at: firstNonInactiveStatus?.updatedAt || deployment.latestStatus?.updatedAt, state: firstNonInactiveStatus?.state?.toLowerCase() || deployment.latestStatus?.state diff --git a/src/transforms/transform-deployment.ts b/src/transforms/transform-deployment.ts index 140003e660..a57d315720 100644 --- a/src/transforms/transform-deployment.ts +++ b/src/transforms/transform-deployment.ts @@ -387,6 +387,7 @@ export const transformDeployment = async ( environment: { id: deployment_status.environment, displayName: deployment_status.environment, + url: deployment_status.environment_url, type: environment }, associations From d92eca861119223a800fced2f843ac2cfdd9ae57 Mon Sep 17 00:00:00 2001 From: Alden Quimby Date: Tue, 6 Jun 2023 12:08:55 -0400 Subject: [PATCH 2/3] Add tests --- src/sync/deployment.test.ts | 4 ++++ src/transforms/transform-deployment.test.ts | 1 + .../api/graphql/deployment-nodes-mixed.json | 14 ++++++++------ test/fixtures/api/graphql/deployment-nodes.json | 17 ++++++++++------- test/fixtures/deployment_status-basic.json | 1 + 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/sync/deployment.test.ts b/src/sync/deployment.test.ts index 8e7a8a9fe6..3ade122a4d 100644 --- a/src/sync/deployment.test.ts +++ b/src/sync/deployment.test.ts @@ -495,6 +495,7 @@ describe("sync/deployments", () => { "environment": { "id": "prod", "displayName": "prod", + "url": "https://test-repo-url.env-production.company.io", "type": "production" }, "associations": [ @@ -621,6 +622,7 @@ describe("sync/deployments", () => { environment: { id: "prod", displayName: "prod", + url: "https://test-repo-url.env-production.company.io", type: "production" }, associations: [ @@ -660,6 +662,7 @@ describe("sync/deployments", () => { environment: { id: "prod", displayName: "prod", + url: "https://test-repo-url.env-production.company.io", type: "production" }, associations: [ @@ -893,6 +896,7 @@ describe("sync/deployments", () => { "environment": { "id": "prod", "displayName": "prod", + "url": "https://test-repo-url.env-production.company.io", "type": "production" }, "associations": [ diff --git a/src/transforms/transform-deployment.test.ts b/src/transforms/transform-deployment.test.ts index f4a8b2f37a..d184765531 100644 --- a/src/transforms/transform-deployment.test.ts +++ b/src/transforms/transform-deployment.test.ts @@ -61,6 +61,7 @@ const buildJiraPayload = (displayName="testing", associations) => { environment: { id: "Production", displayName: "Production", + url: "https://test-repo-url.env-production.company.io", type: "production" }, associations diff --git a/test/fixtures/api/graphql/deployment-nodes-mixed.json b/test/fixtures/api/graphql/deployment-nodes-mixed.json index d57de2c9d1..b9f6861e3b 100644 --- a/test/fixtures/api/graphql/deployment-nodes-mixed.json +++ b/test/fixtures/api/graphql/deployment-nodes-mixed.json @@ -7,8 +7,8 @@ "cursor": "Y3Vyc29yOnYyOpK0MjAyMi0wMi0wM1QyMjo0NTowM1rOHdDZeg==", "node": { "repository": { - "id": 24, - "node_id": "pK0MjAyMi0wMi0wM1QyMj", + "id": 24, + "node_id": "pK0MjAyMi0wMi0wM1QyMj", "name": "test-repo-name", "owner": { "login": "test-repo-owner" @@ -24,7 +24,7 @@ "environment": "prod", "description": "", "latestStatus": { - "environmentUrl": "", + "environmentUrl": "https://test-repo-url.env-production.company.io", "logUrl": "https://github.com/test-repo-owner/test-repo-name/commit/51e16759cdac67b0d2a94e0674c9603b75a840f6/checks", "state": "success", "id": "DES_kwDOGtdD5840PkSo", @@ -35,6 +35,7 @@ { "createdAt": "2022-02-03T22:45:04Z", "updatedAt": "2022-02-03T22:45:04Z", + "environmentUrl": "https://test-repo-url.env-production.company.io", "state": "SUCCESS" } ] @@ -45,8 +46,8 @@ "cursor": "Y3Vyc29yOnYyOpK0MjAyMi0wMi0wM1QyMjo0NTowM1rOHdDZeg==", "node": { "repository": { - "id": 42, - "node_id": "pK0MjAyMi0wMi0wM1QyMj", + "id": 42, + "node_id": "pK0MjAyMi0wMi0wM1QyMj", "name": "test-repo-name", "owner": { "login": "test-repo-owner" @@ -62,7 +63,7 @@ "environment": "prod", "description": "", "latestStatus": { - "environmentUrl": "", + "environmentUrl": "https://test-repo-url.env-production.company.io", "logUrl": "https://github.com/test-repo-owner/test-repo-name/commit/7544f2fec0321a32d5effd421682463c2ebd5018/checks", "state": "success", "id": "DES_kwDOGtdD5840PkSo", @@ -73,6 +74,7 @@ { "createdAt": "2022-02-03T22:45:04Z", "updatedAt": "2022-02-03T22:45:04Z", + "environmentUrl": "https://test-repo-url.env-production.company.io", "state": "SUCCESS" } ] diff --git a/test/fixtures/api/graphql/deployment-nodes.json b/test/fixtures/api/graphql/deployment-nodes.json index e05a0a3f86..d95a82e770 100644 --- a/test/fixtures/api/graphql/deployment-nodes.json +++ b/test/fixtures/api/graphql/deployment-nodes.json @@ -7,10 +7,10 @@ "cursor": "Y3Vyc29yOnYyOpK0MjAyMi0wMi0wM1QyMjo0NTowM1rOHdDZeg==", "node": { "createdAt": "2022-02-03T22:45:04Z", - "updatedAt": "2022-02-03T22:45:04Z", + "updatedAt": "2022-02-03T22:45:04Z", "repository": { - "id": 19, - "node_id": "AyMi0wMi0wM1QyMjo0NT", + "id": 19, + "node_id": "AyMi0wMi0wM1QyMjo0NT", "name": "test-repo-name", "owner": { "login": "test-repo-owner" @@ -26,7 +26,7 @@ "environment": "prod", "description": "", "latestStatus": { - "environmentUrl": "", + "environmentUrl": "https://test-repo-url.env-production.company.io", "logUrl": null, "state": "INACTIVE", "id": "DES_kwDOGtdD5840PkSo", @@ -39,19 +39,22 @@ "createdAt": "2022-02-03T22:45:04Z", "updatedAt": "2022-02-03T22:45:04Z", "state": "INACTIVE", - "logUrl": null + "environmentUrl": "https://test-repo-url.env-production.company.io", + "logUrl": null }, { "createdAt": "2022-02-03T22:45:04Z", "updatedAt": "2022-02-03T22:45:04Z", "state": "SUCCESS", - "logUrl": "random-success" + "environmentUrl": "https://test-repo-url.env-production.company.io", + "logUrl": "random-success" }, { "createdAt": "2022-02-03T22:45:04Z", "updatedAt": "2022-02-03T22:45:04Z", "state": "IN_PROGRESS", - "logUrl": "random-in-progress" + "environmentUrl": "", + "logUrl": "random-in-progress" } ] } diff --git a/test/fixtures/deployment_status-basic.json b/test/fixtures/deployment_status-basic.json index 4b5d65ec5e..c82946056d 100644 --- a/test/fixtures/deployment_status-basic.json +++ b/test/fixtures/deployment_status-basic.json @@ -11,6 +11,7 @@ }, "description": "", "environment": "Production", + "environment_url": "https://test-repo-url.env-production.company.io", "target_url": "test-repo-url/commit/885bee1-commit-id-1c458/checks", "created_at": "2021-06-28T12:15:18Z", "updated_at": "2021-06-28T12:15:18Z" From b349163eeb619cefbe98e84412a7074dfdef783b Mon Sep 17 00:00:00 2001 From: Alden Quimby Date: Tue, 6 Jun 2023 12:52:39 -0400 Subject: [PATCH 3/3] Fix SQS test too --- src/sqs/deployment.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sqs/deployment.test.ts b/src/sqs/deployment.test.ts index 903d4abb37..ee7c3e9163 100644 --- a/src/sqs/deployment.test.ts +++ b/src/sqs/deployment.test.ts @@ -170,6 +170,7 @@ describe("Deployment Webhook", () => { "environment": { "id": "Production", "displayName": "Production", + "url": "https://test-repo-url.env-production.company.io", "type": "production" }, "associations": [