OpenMetadata/scripts/validate_change.sh
Teddy 2dbf5ed0b4
#24641: fix MySQL data_diff URL to include database (#25047)
* fix(ingestion): include database in MySQL data_diff URL (#24641)

The data_diff library requires MySQL URLs to specify a database in the
path (e.g., mysql://user:pass@host:port/database). Without this, the
table diff test fails with "MySQL URL must specify a database" error.

This fix adds MySQL and MariaDB to the list of dialects that need the
schema (which is the database in MySQL's terminology) included in the
URL path.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: conflicts with recent changes

* chore: translated missing arabic entries

* fix: conditional logic issue

* chore: fix failing tests

* style: ran java linting

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 16:12:52 +01:00

100 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
# Fetch latest from remotes
git fetch --quiet 2>/dev/null
# Auto-detect base branch (upstream/main > origin/main)
if git rev-parse --verify upstream/main &>/dev/null; then
BASE_BRANCH="upstream/main"
elif git rev-parse --verify origin/main &>/dev/null; then
BASE_BRANCH="origin/main"
else
echo "❌ Could not find main branch on origin or upstream"
exit 1
fi
echo "📊 Comparing against: ${BASE_BRANCH}"
# Get the diff (staged changes, or last commit, or working directory)
if [ "$1" == "--staged" ]; then
DIFF=$(git diff --cached --ignore-submodules)
CONTEXT="staged changes"
elif [ "$1" == "--last-commit" ]; then
DIFF=$(git diff HEAD~1 --ignore-submodules)
CONTEXT="last commit: $(git log -1 --pretty=%B)"
elif [ "$1" == "--working" ]; then
DIFF=$(git diff --ignore-submodules)
CONTEXT="working directory changes"
else
# Default: compare current branch to base
DIFF=$(git diff ${BASE_BRANCH}...HEAD --ignore-submodules --no-color -U3 --minimal)
CONTEXT="current branch vs ${BASE_BRANCH}"
fi
# Get list of changed files vs base branch
CHANGED_FILES=$(git diff --name-only ${BASE_BRANCH}...HEAD --ignore-submodules 2>/dev/null || git diff --name-only HEAD)
# Current branch name
CURRENT_BRANCH=$(git branch --show-current)
# Exit if no changes
if [ -z "$DIFF" ]; then
echo "No changes to validate"
exit 0
fi
# Run Claude Code with the diff as context (-p for non-interactive mode)
claude -p "
## Task: Validate Code Changes
### Context
Branch: ${CURRENT_BRANCH}
Comparing: ${CONTEXT}
### Changed Files:
$CHANGED_FILES
### Diff:
\`\`\`diff
$DIFF
\`\`\`
### Instructions:
1. Analyze which files changed and what functionality was affected
2. Provide a throrough code review of the changes validating for:
- Code quality
- Adherence to project conventions
- Potential bugs or issues
- Missing tests or documentation
- Security implications
- Performance considerations
3. Determine which tests are relevant:
- Unit tests for changed modules
- Integration tests if APIs/services changed (for python integration tests assume docker and test DB are available)
- E2E tests (via Playwright MCP) if UI/flows changed
4. Run the relevant tests:
- For unit/integration: use the project's test runner (npm test, pytest, etc.)
- For E2E: use Playwright MCP to validate on http://localhost:8585
5. Report results in this exact format:
## Code Review
[Detailed code review comments by files changed]
## Validation Results
| Test Type | Status | Details |
|-----------|--------|---------|
| Unit | 🟢/🔴 | X passed, Y failed |
| Integration | 🟢/🔴 | X passed, Y failed |
| E2E | 🟢/🔴 | Verified: [list] |
### Overall: 🟢 PASS or 🔴 FAIL
[If FAIL, list specific failures and suggested fixes]
" --allowedTools "Bash,mcp__playwright__*" 2>&1
# Capture exit code
EXIT_CODE=$?
exit $EXIT_CODE