-
Notifications
You must be signed in to change notification settings - Fork 3
Add OpenMetadata PR impact analysis action #18
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
Open
PRADDZY
wants to merge
1
commit into
open-metadata:main
Choose a base branch
from
PRADDZY:hackathon/pr-sentinel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
.github/actions/openmetadata-impact-analysis/action.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| name: OpenMetadata Impact Analysis | ||
| description: Analyze dbt model changes with OpenMetadata lineage and publish report artifacts. | ||
|
|
||
| inputs: | ||
| diff-path: | ||
| description: Path to a unified git diff file. Generated from base-ref when missing. | ||
| required: false | ||
| default: changes.diff | ||
| metadata-host: | ||
| description: OpenMetadata or Collate host URL. | ||
| required: false | ||
| metadata-token: | ||
| description: Bot JWT token with read access to metadata. | ||
| required: false | ||
| openai-api-key: | ||
| description: OpenAI API key for the LangChain analysis agent. | ||
| required: false | ||
| base-ref: | ||
| description: Base ref used to generate the diff when diff-path does not exist. | ||
| required: false | ||
| default: origin/main | ||
| paths: | ||
| description: Comma-separated path globs to analyze. | ||
| required: false | ||
| default: "**/models/**/*.sql,**/models/**/*.yml,**/models/**/*.yaml" | ||
| report-path: | ||
| description: Markdown report path. | ||
| required: false | ||
| default: impact_report.md | ||
| html-report-path: | ||
| description: Static HTML report artifact path. | ||
| required: false | ||
| default: impact_report.html | ||
| metadata-output-path: | ||
| description: JSON metadata output path. | ||
| required: false | ||
| default: impact_metadata.json | ||
| python-version: | ||
| description: Python version used to run the analyzer. | ||
| required: false | ||
| default: "3.11" | ||
|
|
||
| outputs: | ||
| report-path: | ||
| description: Markdown report path. | ||
| value: ${{ steps.run.outputs.report-path }} | ||
| html-report-path: | ||
| description: Static HTML report artifact path. | ||
| value: ${{ steps.run.outputs.html-report-path }} | ||
| risk-level: | ||
| description: Deterministic risk level for the analyzed PR. | ||
| value: ${{ steps.run.outputs.risk-level }} | ||
| affected-count: | ||
| description: Count of affected OpenMetadata assets discovered in the report. | ||
| value: ${{ steps.run.outputs.affected-count }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
| cache: pip | ||
| cache-dependency-path: python/pyproject.toml | ||
|
|
||
| - name: Generate diff when needed | ||
| shell: bash | ||
| run: | | ||
| if [ ! -f "${{ inputs.diff-path }}" ]; then | ||
| git diff "${{ inputs.base-ref }}...HEAD" > "${{ inputs.diff-path }}" | ||
| fi | ||
|
|
||
| - name: Install Python dependencies | ||
| shell: bash | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -e "python/[langchain]" langchain langchain-openai | ||
|
PRADDZY marked this conversation as resolved.
|
||
|
|
||
| - name: Run impact analysis | ||
| id: run | ||
| shell: bash | ||
| env: | ||
| AI_SDK_HOST: ${{ inputs.metadata-host }} | ||
| AI_SDK_TOKEN: ${{ inputs.metadata-token }} | ||
| OPENAI_API_KEY: ${{ inputs.openai-api-key }} | ||
| run: | | ||
| python cookbook/mcp-impact-analysis/batch_analyzer.py "${{ inputs.diff-path }}" \ | ||
| --output "${{ inputs.report-path }}" \ | ||
| --html-output "${{ inputs.html-report-path }}" \ | ||
| --metadata-output "${{ inputs.metadata-output-path }}" \ | ||
| --paths "${{ inputs.paths }}" | ||
|
PRADDZY marked this conversation as resolved.
|
||
|
|
||
| echo "report-path=${{ inputs.report-path }}" >> "$GITHUB_OUTPUT" | ||
| echo "html-report-path=${{ inputs.html-report-path }}" >> "$GITHUB_OUTPUT" | ||
| METADATA_OUTPUT_PATH="${{ inputs.metadata-output-path }}" python - <<'PY' >> "$GITHUB_OUTPUT" | ||
| import json | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| metadata = json.loads(Path(os.environ["METADATA_OUTPUT_PATH"]).read_text()) | ||
| print(f"risk-level={metadata['risk_level']}") | ||
| print(f"affected-count={metadata['affected_count']}") | ||
| PY | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.