Skip to content

Commit

Permalink
Merge pull request #136 from atlanhq/revert-134-DQ-384-rename-to-atla…
Browse files Browse the repository at this point in the history
…n-action

Revert "DQ-384 rename(dbt-action): change dbt-action to atlan action"
  • Loading branch information
rittikdasgupta authored Oct 7, 2024
2 parents d8e827a + 77e39e9 commit 4e565a3
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 166 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Test Action
on:
pull_request:
types: [opened, edited, synchronize, reopened, closed]
paths:
- 'test/**'

jobs:
get-downstream-assets:
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Atlan Action
# Atlan dbt Action

![atlan<>dbt](https://user-images.githubusercontent.com/14099191/209542321-54d5557e-8abf-4d9a-9f6d-dcacb856f25f.png)

## Overview

_Have you ever changed a dbt model or a [data contract](https://ask.atlan.com/hc/en-us/articles/9281528742799-How-to-create-data-contracts) only to later find it broke a downstream table or dashboard? 💔_
_Have you ever changed a dbt model only to later find it broke a downstream table or dashboard? 💔_

We've created a GitHub Action to help you out — putting Atlan's impact analysis right into your pull request. So now, before merging the PR, you can see the potential downstream impact of your changes.

Expand All @@ -31,7 +31,7 @@ Here's what it looks like 👇
2. Add the following code to the workflow file:

```yaml
name: Atlan action
name: Atlan dbt action

on:
pull_request:
Expand All @@ -43,7 +43,7 @@ Here's what it looks like 👇
runs-on: ubuntu-latest
steps:
- name: Run Action
uses: atlanhq/atlan-action@v2
uses: atlanhq/dbt-action@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ATLAN_INSTANCE_URL: ${{secrets.ATLAN_INSTANCE_URL}}
Expand All @@ -52,7 +52,7 @@ Here's what it looks like 👇
## Test the action
After you've completed the configuration above, create a pull request with a changed dbt model or data contract file to test the action. You should see the Atlan GitHub action running and then adding comments in your pull request:
After you've completed the configuration above, create a pull request with a changed dbt model file to test the action. You should see the Atlan GitHub action running and then adding comments in your pull request:
- The GitHub workflow will add and update a single comment for every file change.
- The impacted assets in the comment will be displayed in a collapsible section and grouped by source and asset type.
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run Action
uses: atlanhq/atlan-action@v2
uses: atlanhq/dbt-action@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ATLAN_INSTANCE_URL: ${{secrets.ATLAN_INSTANCE_URL}}
Expand All @@ -105,7 +105,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run Action
uses: atlanhq/atlan-action@v2
uses: atlanhq/dbt-action@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ATLAN_INSTANCE_URL: ${{secrets.ATLAN_INSTANCE_URL}}
Expand Down
4 changes: 2 additions & 2 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ It is a very useful and easy to use library, which runs your Github Actions loca

Since you as a developer would be using your Github PAT to test the action locally, you'll need to locally run the clone of your fork, in order to generate the event.json file, follow the following steps:

- [Fork this repo.](https://github.com/atlanhq/atlan-action/fork)
- [Fork this repo.](https://github.com/atlanhq/dbt-action/fork)
- Create a pull request from `test-action` branch to `main` branch. Once you do so, it will automatically run the action.
- Go to your forked repo's `Actions` page and open the workflow with the name `Test Action`.
- Click on the one and only job, `Get Downstream Assets`.
Expand All @@ -58,4 +58,4 @@ Once and if `act` is setup properly, then you can simply use the command `npm st

## Contributing

Please make sure to use the command `npm run sync` in order to sync changes, since the workflow [`.github/workflows/package-action.yml`](https://github.com/atlanhq/atlan-action/blob/main/.github/workflows/package-action.yml) updates the `dist/` in order to package the action code in case you forget to package the action before pushing.
Please make sure to use the command `npm run sync` in order to sync changes, since the workflow [`.github/workflows/package-action.yml`](https://github.com/atlanhq/dbt-action/blob/main/.github/workflows/package-action.yml) updates the `dist/` in order to package the action code in case you forget to package the action before pushing.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Atlan Action"
description: "Whenever you make a change to a dbt model or a data contract, Atlan will add downstream lineage impact context right in your pull requests."
name: "Atlan dbt Action"
description: "Whenever you make a change to a dbt model, Atlan will add downstream lineage impact context right in your pull requests."
author: "Atlan"

inputs:
Expand Down
9 changes: 0 additions & 9 deletions adapters/api/get-contract-asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ export default async function getContractAsset({
term: {
qualifiedName: assetQualifiedName
}
},
{
terms: {
"__typeName.keyword": [
"Table",
"MaterialisedView",
"View"
]
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ ${viewAssetButton}`;

// Iterate through the object to find relevant keys
for (const [key, value] of Object.entries(configYaml)) {
console.log(key);
if (key.startsWith('data_source ')) {
// Trim the prefix and add to the Map
const trimmedKey = key.replace('data_source ', '');
Expand Down
73 changes: 15 additions & 58 deletions adapters/integrations/gitlab-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,66 +779,23 @@ ${content}`;
CI_COMMIT_SHA,
"getAssetName"
);
const startRegex =
/{{\s*config\s*\(/im;
const startMatch = fileContents.match(startRegex);
let configSection = ''
if (startMatch) {
const startIndex = startMatch.index;
const openParensIndex = fileContents.indexOf('(', startIndex) + 1;
let openParensCount = 1;
let endIndex = openParensIndex;

while (openParensCount > 0 && endIndex < fileContents.length) {
const char = fileContents[endIndex];

if (char === '(') {
openParensCount++;
} else if (char === ')') {
openParensCount--;
}
endIndex++;
}

const endMarker = '}}';
const finalEndIndex = fileContents.indexOf(endMarker, endIndex) + endMarker.length;

configSection = fileContents.substring(startIndex, finalEndIndex);
logger.withInfo(
"Extracted config section",
integrationName,
CI_COMMIT_SHA,
"getAssetName"
);

if (configSection){
logger.withInfo(
"Executing final regex",
integrationName,
CI_COMMIT_SHA,
"getAssetName"
);

var matches = regExp.exec(configSection);

logger.withInfo(
"Successfully executed regex matching",
integrationName,
CI_COMMIT_SHA,
"getAssetName"
);
var matches = regExp.exec(fileContents);

}
if (matches) {
logger.withInfo(
`Found a match: ${matches[1].trim()}`,
integrationName,
CI_COMMIT_SHA,
"getAssetName"
);
logger.withInfo(
"Successfully executed regex matching",
integrationName,
CI_COMMIT_SHA,
"getAssetName"
);

return matches[1].trim();
}
if (matches) {
logger.withInfo(
`Found a match: ${matches[1].trim()}`,
integrationName,
CI_COMMIT_SHA,
"getAssetName"
);
return matches[1].trim();
}
}

Expand Down
4 changes: 2 additions & 2 deletions adapters/templates/github-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getErrorResponseStatus401 (ATLAN_INSTANCE_URL, context) {
Atlan Instance URL: ${ATLAN_INSTANCE_URL}
Set your repository action secrets [here](https://github.com/${context.payload.repository.full_name}/settings/secrets/actions). For more information on how to setup the Atlan Action, please read the [setup documentation here](https://github.com/atlanhq/atlan-action/blob/main/README.md).`
Set your repository action secrets [here](https://github.com/${context.payload.repository.full_name}/settings/secrets/actions). For more information on how to setup the Atlan dbt Action, please read the [setup documentation here](https://github.com/atlanhq/dbt-action/blob/main/README.md).`
}

export function getErrorResponseStatusUndefined(ATLAN_INSTANCE_URL, context) {
Expand All @@ -16,7 +16,7 @@ Atlan Instance URL: ${ATLAN_INSTANCE_URL}
Make sure your Atlan Instance URL is set in the following format.
\`https://tenant.atlan.com\`
Set your repository action secrets [here](https://github.com/${context.payload.repository.full_name}/settings/secrets/actions). For more information on how to setup the Atlan Action, please read the [setup documentation here](https://github.com/atlanhq/atlan-action/blob/main/README.md).`
Set your repository action secrets [here](https://github.com/${context.payload.repository.full_name}/settings/secrets/actions). For more information on how to setup the Atlan dbt Action, please read the [setup documentation here](https://github.com/atlanhq/dbt-action/blob/main/README.md).`
}

export function getSetResourceOnAssetComment(tableMd, setResourceFailed) {
Expand Down
6 changes: 3 additions & 3 deletions adapters/templates/gitlab-integration.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getCertificationImage, getConnectorImage, getImageURL } from "../utils/index.js";
import { getImageURL, getConnectorImage, getCertificationImage } from "../utils/index.js";

export function getErrorResponseStatus401 (ATLAN_INSTANCE_URL, CI_PROJECT_NAME, CI_PROJECT_NAMESPACE) {
return `We couldn't connect to your Atlan Instance, please make sure to set the valid Atlan Bearer Token as \`ATLAN_API_TOKEN\` as this repository's CI/CD variable.
Atlan Instance URL: ${ATLAN_INSTANCE_URL}
Set your CI/CD variables [here](https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/settings/ci_cd). For more information on how to setup the Atlan Action, please read the [setup documentation here](https://ask.atlan.com/hc/en-us/articles/8284983222415).`
Set your CI/CD variables [here](https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/settings/ci_cd). For more information on how to setup the Atlan dbt Action, please read the [setup documentation here](https://ask.atlan.com/hc/en-us/articles/8284983222415).`
}

export function getErrorResponseStatusUndefined(ATLAN_INSTANCE_URL, CI_PROJECT_NAME, CI_PROJECT_NAMESPACE) {
Expand All @@ -16,7 +16,7 @@ Atlan Instance URL: ${ATLAN_INSTANCE_URL}
Make sure your Atlan Instance URL is set in the following format.
\`https://tenant.atlan.com\`
Set your CI/CD variables [here](https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/settings/ci_cd). For more information on how to setup the Atlan Action, please read the [setup documentation here](https://ask.atlan.com/hc/en-us/articles/8284983222415).`
Set your CI/CD variables [here](https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/settings/ci_cd). For more information on how to setup the Atlan dbt Action, please read the [setup documentation here](https://ask.atlan.com/hc/en-us/articles/8284983222415).`
}

export function getSetResourceOnAssetComment(tableMd, setResourceFailed) {
Expand Down
91 changes: 20 additions & 71 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24831,7 +24831,7 @@ function getErrorResponseStatus401 (ATLAN_INSTANCE_URL, context) {

Atlan Instance URL: ${ATLAN_INSTANCE_URL}

Set your repository action secrets [here](https://github.com/${context.payload.repository.full_name}/settings/secrets/actions). For more information on how to setup the Atlan Action, please read the [setup documentation here](https://github.com/atlanhq/atlan-action/blob/main/README.md).`
Set your repository action secrets [here](https://github.com/${context.payload.repository.full_name}/settings/secrets/actions). For more information on how to setup the Atlan dbt Action, please read the [setup documentation here](https://github.com/atlanhq/dbt-action/blob/main/README.md).`
}

function getErrorResponseStatusUndefined(ATLAN_INSTANCE_URL, context) {
Expand All @@ -24842,7 +24842,7 @@ Atlan Instance URL: ${ATLAN_INSTANCE_URL}
Make sure your Atlan Instance URL is set in the following format.
\`https://tenant.atlan.com\`

Set your repository action secrets [here](https://github.com/${context.payload.repository.full_name}/settings/secrets/actions). For more information on how to setup the Atlan Action, please read the [setup documentation here](https://github.com/atlanhq/atlan-action/blob/main/README.md).`
Set your repository action secrets [here](https://github.com/${context.payload.repository.full_name}/settings/secrets/actions). For more information on how to setup the Atlan dbt Action, please read the [setup documentation here](https://github.com/atlanhq/dbt-action/blob/main/README.md).`
}

function getSetResourceOnAssetComment(tableMd, setResourceFailed) {
Expand Down Expand Up @@ -25120,15 +25120,6 @@ async function getContractAsset({
term: {
qualifiedName: assetQualifiedName
}
},
{
terms: {
"__typeName.keyword": [
"Table",
"MaterialisedView",
"View"
]
}
}
]
}
Expand Down Expand Up @@ -30597,6 +30588,7 @@ ${viewAssetButton}`;

// Iterate through the object to find relevant keys
for (const [key, value] of Object.entries(configYaml)) {
console.log(key);
if (key.startsWith('data_source ')) {
// Trim the prefix and add to the Map
const trimmedKey = key.replace('data_source ', '');
Expand Down Expand Up @@ -39065,7 +39057,7 @@ function gitlab_integration_getErrorResponseStatus401 (ATLAN_INSTANCE_URL, CI_PR

Atlan Instance URL: ${ATLAN_INSTANCE_URL}

Set your CI/CD variables [here](https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/settings/ci_cd). For more information on how to setup the Atlan Action, please read the [setup documentation here](https://ask.atlan.com/hc/en-us/articles/8284983222415).`
Set your CI/CD variables [here](https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/settings/ci_cd). For more information on how to setup the Atlan dbt Action, please read the [setup documentation here](https://ask.atlan.com/hc/en-us/articles/8284983222415).`
}

function gitlab_integration_getErrorResponseStatusUndefined(ATLAN_INSTANCE_URL, CI_PROJECT_NAME, CI_PROJECT_NAMESPACE) {
Expand All @@ -39076,7 +39068,7 @@ Atlan Instance URL: ${ATLAN_INSTANCE_URL}
Make sure your Atlan Instance URL is set in the following format.
\`https://tenant.atlan.com\`

Set your CI/CD variables [here](https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/settings/ci_cd). For more information on how to setup the Atlan Action, please read the [setup documentation here](https://ask.atlan.com/hc/en-us/articles/8284983222415).`
Set your CI/CD variables [here](https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/settings/ci_cd). For more information on how to setup the Atlan dbt Action, please read the [setup documentation here](https://ask.atlan.com/hc/en-us/articles/8284983222415).`
}

function gitlab_integration_getSetResourceOnAssetComment(tableMd, setResourceFailed) {
Expand Down Expand Up @@ -39910,66 +39902,23 @@ ${content}`;
CI_COMMIT_SHA,
"getAssetName"
);
const startRegex =
/{{\s*config\s*\(/im;
const startMatch = fileContents.match(startRegex);
let configSection = ''
if (startMatch) {
const startIndex = startMatch.index;
const openParensIndex = fileContents.indexOf('(', startIndex) + 1;
let openParensCount = 1;
let endIndex = openParensIndex;

while (openParensCount > 0 && endIndex < fileContents.length) {
const char = fileContents[endIndex];

if (char === '(') {
openParensCount++;
} else if (char === ')') {
openParensCount--;
}
endIndex++;
}

const endMarker = '}}';
const finalEndIndex = fileContents.indexOf(endMarker, endIndex) + endMarker.length;

configSection = fileContents.substring(startIndex, finalEndIndex);
logger_logger.withInfo(
"Extracted config section",
gitlab_integration_integrationName,
CI_COMMIT_SHA,
"getAssetName"
);

if (configSection){
logger_logger.withInfo(
"Executing final regex",
gitlab_integration_integrationName,
CI_COMMIT_SHA,
"getAssetName"
);

var matches = regExp.exec(configSection);

logger_logger.withInfo(
"Successfully executed regex matching",
gitlab_integration_integrationName,
CI_COMMIT_SHA,
"getAssetName"
);
var matches = regExp.exec(fileContents);

}
if (matches) {
logger_logger.withInfo(
`Found a match: ${matches[1].trim()}`,
gitlab_integration_integrationName,
CI_COMMIT_SHA,
"getAssetName"
);
logger_logger.withInfo(
"Successfully executed regex matching",
gitlab_integration_integrationName,
CI_COMMIT_SHA,
"getAssetName"
);

return matches[1].trim();
}
if (matches) {
logger_logger.withInfo(
`Found a match: ${matches[1].trim()}`,
gitlab_integration_integrationName,
CI_COMMIT_SHA,
"getAssetName"
);
return matches[1].trim();
}
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4e565a3

Please sign in to comment.