Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DQ-384 feat(contract): add support for contract impact analysis #130

Merged
merged 19 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5a8ae85
Merge pull request #117 from atlanhq/staging
Jaagrav Nov 2, 2023
c57b8ad
Merge branch 'feat/integration_support' into PR_main_integration_support
ArpitShukla12 Nov 7, 2023
fed7a6d
Merge branch 'feat/integration_support' into PR_main_integration_support
ArpitShukla12 Nov 7, 2023
2f69567
Merge branch 'feat/integration_support' into PR_main_integration_support
ArpitShukla12 Nov 7, 2023
fe795dd
Merge branch 'feat/integration_support' into PR_main_integration_support
ArpitShukla12 Nov 8, 2023
f42ce9c
Merge pull request #120 from ArpitShukla12/PR_main_integration_support
ArpitShukla12 Nov 8, 2023
c1dffb3
Merge pull request #125 from atlanhq/main-test
ArpitShukla12 Nov 9, 2023
f590db4
Add files via upload
gopalatlansingh2022 May 10, 2024
a249a6b
Update and rename github-actions-pr-jira_yml (1).yaml to github-actio…
gopalatlansingh2022 May 10, 2024
99459e1
added logs for visibility
ArpitShukla12 Sep 12, 2024
8b94ced
fixed index.js
ArpitShukla12 Sep 12, 2024
5dc164b
Merge pull request #128 from atlanhq/add-logging-for-visibility
Jaagrav Sep 12, 2024
4e3d955
feat(action): add support data contract action
rittikdasgupta Sep 9, 2024
4c8e4a3
doc(readme): add details for contract impact analysis
rittikdasgupta Sep 20, 2024
f3b34d9
feat(contract): add atlan config and contract parsing support in CI A…
rittikdasgupta Sep 24, 2024
a4e3991
enhancement(contract): modify contract ci action
rittikdasgupta Sep 24, 2024
880d6af
enhancement(downstream-asset): modify payload for fetching downstream…
rittikdasgupta Sep 24, 2024
6d0d2ae
chore: npm run build
rittikdasgupta Sep 24, 2024
2fbf88a
fix(downstream-asset): add fix to remove parent asset in downstream l…
rittikdasgupta Sep 24, 2024
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
Prev Previous commit
Next Next commit
feat(action): add support data contract action
changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes

changes
  • Loading branch information
rittikdasgupta committed Sep 19, 2024
commit 4e3d9551014a93e2ed80a585c32504466d53d6f5
1 change: 1 addition & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ jobs:
beta: Wide World Importers PE1
test-action: Wide World Importers PE1
IGNORE_MODEL_ALIAS_MATCHING: true
ATLAN_CONFIG: .atlan/config.yaml
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
node_modules/
event.json
.idea
.DS_Store
.DS_Store
.vscode/
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
description: "Ignore model alias matching"
required: false
default: false
ATLAN_CONFIG:
description: "Atlan CLI config file location"
required: false
runs:
using: "node16"
main: "dist/index.js"
Expand Down
33 changes: 33 additions & 0 deletions adapters/api/get-asset-classifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
ATLAN_API_TOKEN,
ATLAN_INSTANCE_URL,
} from "../utils/get-environment-variables.js";

import fetch from "node-fetch";

export default async function getAssetClassifications() {
var myHeaders = {
Authorization: `Bearer ${ATLAN_API_TOKEN}`,
"Content-Type": "application/json",
};

var requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow",
};

var response = await fetch(
`${ATLAN_INSTANCE_URL}/api/meta/types/typedefs?type=classification`,
requestOptions
)
.then((e) => e.json())
.catch((err) => {
return {
error: err
}
});
if (response.error) return response

return response?.classificationDefs;
}
7 changes: 4 additions & 3 deletions adapters/api/get-classifications.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import fetch from "node-fetch";
import {
ATLAN_INSTANCE_URL,
ATLAN_API_TOKEN,
ATLAN_INSTANCE_URL,
} from "../utils/get-environment-variables.js";

import fetch from "node-fetch";

export default async function getClassifications({
sendSegmentEventOfIntegration,
}) {
Expand Down Expand Up @@ -34,4 +35,4 @@ export default async function getClassifications({
});

return response?.classificationDefs;
}
}
55 changes: 55 additions & 0 deletions adapters/api/get-contract-asset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
ATLAN_API_TOKEN,
ATLAN_INSTANCE_URL,
} from "../utils/get-environment-variables.js";

import fetch from "node-fetch";
import {
getErrorAssetNotFound,
} from "../templates/atlan.js";
import stringify from "json-stringify-safe";

export default async function getContractAsset({
name,
atlanConfig,
contractSpec,
}) {
var myHeaders = {
Authorization: `Bearer ${ATLAN_API_TOKEN}`,
"Content-Type": "application/json",
};

var raw = stringify(
{
"atlanConfig": atlanConfig,
"contractSpec": contractSpec
}
);

var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};

var response = await fetch(
`${ATLAN_INSTANCE_URL}/api/service/contracts/asset`,
requestOptions
)
.then((e) => e.json())
.catch((err) => {
return {
error: err,
comment: getErrorAssetNotFound(name)
}
});

if (!response?.entities?.length) {
return {
error: "asset not found",
comment: getErrorAssetNotFound(name),
};
}

return response.entities[0];
}
162 changes: 137 additions & 25 deletions adapters/api/get-downstream-assets.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import fetch from "node-fetch";
import {
getConnectorImage,
ATLAN_API_TOKEN,
ATLAN_INSTANCE_URL,
} from "../utils/get-environment-variables.js";
import {
getCertificationImage,
getConnectorImage,
getImageURL,
} from "../utils/index.js";

import fetch from "node-fetch";
import stringify from "json-stringify-safe";
import {
ATLAN_INSTANCE_URL,
ATLAN_API_TOKEN,
} from "../utils/get-environment-variables.js";

const ASSETS_LIMIT = 100;

Expand Down Expand Up @@ -71,25 +72,26 @@ export default async function getDownstreamAssets(
};

var handleError = (err) => {
const comment = `### ${getConnectorImage(
asset.attributes.connectorName
)} [${asset.displayText}](${ATLAN_INSTANCE_URL}/assets/${
asset.guid
}/overview?utm_source=dbt_${integration}_action) ${
asset.attributes?.certificateStatus
? getCertificationImage(asset.attributes.certificateStatus)
: ""
}

_Failed to fetch impacted assets._

${getImageURL(
"atlan-logo",
15,
15
)} [View lineage in Atlan](${ATLAN_INSTANCE_URL}/assets/${
asset.guid
}/lineage/overview?utm_source=dbt_${integration}_action)`;
const comment = `
### ${getConnectorImage(asset.attributes.connectorName
)} [${asset.displayText}](${ATLAN_INSTANCE_URL}/assets/${
asset.guid
}/overview?utm_source=dbt_${integration}_action) ${
asset.attributes?.certificateStatus
? getCertificationImage(asset.attributes.certificateStatus)
: ""
}

_Failed to fetch impacted assets._

${getImageURL(
"atlan-logo",
15,
15
)} [View lineage in Atlan](${ATLAN_INSTANCE_URL}/assets/${
asset.guid
}/lineage/overview?utm_source=dbt_${integration}_action)
`;

sendSegmentEventOfIntegration({
action: "dbt_ci_action_failure",
Expand Down Expand Up @@ -125,3 +127,113 @@ ${getImageURL(

return response;
}

function contructCommentForDownstreamLineageFetchError({
asset,
utmSource
}){
const comment = `
### ${getConnectorImage(asset.attributes.connectorName
)} [${asset.displayText}](${ATLAN_INSTANCE_URL}/assets/${
asset.guid
}/overview?utm_source=${utmSource}) ${
asset.attributes?.certificateStatus
? getCertificationImage(asset.attributes.certificateStatus)
: ""
}

_Failed to fetch impacted assets._

${getImageURL(
"atlan-logo",
15,
15
)} [View lineage in Atlan](${ATLAN_INSTANCE_URL}/assets/${
asset.guid
}/lineage/overview?utm_source=${utmSource})
`;

return comment;
}

export async function getDownstreamLineageForAssets({
asset,
guid,
totalModifiedFiles,
utmSource
}) {
var myHeaders = {
authorization: `Bearer ${ATLAN_API_TOKEN}`,
"content-type": "application/json",
};

var raw = stringify({
guid: guid,
size: Math.max(Math.ceil(ASSETS_LIMIT / totalModifiedFiles), 1),
from: 0,
depth: 21,
direction: "OUTPUT",
entityFilters: {
condition: "AND",
criterion: [
{
attributeName: "__typeName",
operator: "not_contains",
attributeValue: "Process",
},
{
attributeName: "__state",
operator: "eq",
attributeValue: "ACTIVE",
},
],
},
attributes: [
"name",
"description",
"userDescription",
"sourceURL",
"qualifiedName",
"connectorName",
"certificateStatus",
"certificateUpdatedBy",
"certificateUpdatedAt",
"ownerUsers",
"ownerGroups",
"classificationNames",
"meanings",
],
excludeMeanings: false,
excludeClassifications: false,
});

var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};

var response = await fetch(
`${ATLAN_INSTANCE_URL}/api/meta/lineage/list`,
requestOptions
)
.then((e) => {
if (e.status === 200) {
return e.json();
} else {
throw e;
}
})
.catch((err) => {
return {
error: err,
comment: contructCommentForDownstreamLineageFetchError({asset, utmSource}),
};
});
if (response.error) return {
error: err,
comment: contructCommentForDownstreamLineageFetchError({asset, utmSource}),
};

return response;
}
13 changes: 8 additions & 5 deletions adapters/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// main.js
import { runAction } from "./gateway.js";
import GitHubIntegration from "./integrations/github-integration.js";
import GitLabIntegration from "./integrations/gitlab-integration.js";
import {
GITLAB_TOKEN,
GITHUB_TOKEN,
GITLAB_TOKEN,
} from "./utils/get-environment-variables.js";

import ContractIntegration from "./integrations/atlan-contract-impact-analysis-github.js";
import GitHubIntegration from "./integrations/github-integration.js";
import GitLabIntegration from "./integrations/gitlab-integration.js";
// main.js
import { runAction } from "./gateway.js";

async function run() {
//Add new integrations over here
await runAction(GITHUB_TOKEN, ContractIntegration);
await runAction(GITHUB_TOKEN, GitHubIntegration);
await runAction(GITLAB_TOKEN, GitLabIntegration);
}
Expand Down
Loading
Loading