Skip to content

fix: resolve pixi environment configuration warnings #230

fix: resolve pixi environment configuration warnings

fix: resolve pixi environment configuration warnings #230

Workflow file for this run

name: Pull Request Checks
on:
pull_request:
branches: [ main, development ]
types: [opened, synchronize, reopened, ready_for_review]
jobs:
pr-quality-gate:
name: PR Quality Gate
runs-on: ubuntu-latest
env:
ENVIRONMENT: ci
PYTHONUNBUFFERED: 1
PIXI_ENV: ci
UCKN_DISABLE_TORCH: "1"
HF_HUB_DISABLE_PROGRESS_BARS: "1"
HF_HUB_DISABLE_TELEMETRY: "1"
if: github.event.pull_request.draft == false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get full history for diff analysis
- name: Setup pixi
uses: prefix-dev/[email protected]
with:
pixi-version: v0.50.2
cache: true
- name: Install dependencies (pixi)
run: pixi install
- name: Install dev dependencies
run: pixi run dev
- name: Quick lint check (changed files only)
run: |
echo "🔍 Quick lint check on changed files..."
# Ensure base branch is available
git fetch origin ${{ github.base_ref }} || echo "Warning: Could not fetch base branch"
# Check for changed Python files (for logging purposes)
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- '*.py' 2>/dev/null || echo "")
if [ -n "$CHANGED_FILES" ]; then
echo "Python files changed: $CHANGED_FILES"
echo "Running lint check on all src/ and tests/ directories..."
pixi run -e quality lint
pixi run -e quality format --check
echo "✅ Lint check passed"
else
echo "No Python files changed, skipping lint check"
fi
- name: Run tests on changed modules
env:
CI: "1"
ENVIRONMENT: ci
run: |
echo "🧪 Running tests for changed modules (CI optimized)..."
# For now, always run tests to avoid git diff issues in CI
echo "Running all tests with CI optimizations"
pixi run db-migrate || echo "Migration completed or no migrations needed"
pixi run -e quality test
echo "✅ Tests passed"
- name: Validate atomic design on changes
run: |
echo "🏗️ Validating atomic design on changed files..."
python << 'EOF'
import os
import subprocess
import sys
# Get changed files (with fallback if git diff fails)
try:
# Get all changed files first, then filter for Python files in src
result = subprocess.run(['git', 'diff', '--name-only', 'origin/${{ github.base_ref }}...HEAD'],
capture_output=True, text=True, check=False)
all_changed = result.stdout.strip().split('\n') if result.stdout.strip() else []
changed_files = [f for f in all_changed if f.startswith('src/') and f.endswith('.py')]
except:
# Fallback: check all Python files in src
result = subprocess.run(['find', 'src', '-name', '*.py'], capture_output=True, text=True)
changed_files = result.stdout.strip().split('\n') if result.stdout.strip() else []
violations = []
for file_path in changed_files:
if file_path and os.path.exists(file_path) and file_path.endswith('.py'):
with open(file_path, 'r') as f:
line_count = sum(1 for line in f)
if line_count > 500:
violations.append(f"{file_path}: {line_count} lines (exceeds 500-line limit)")
# Check if file is in correct atomic location
if 'src/uckn/core/' in file_path:
if not any(atomic in file_path for atomic in ['atoms/', 'molecules/', 'organisms/']):
violations.append(f"{file_path}: not in atomic structure (atoms/molecules/organisms)")
if violations:
print("❌ Atomic design violations in changed files:")
for violation in violations:
print(f" {violation}")
sys.exit(1)
else:
print("✅ Changed files comply with atomic design")
EOF
- name: Check imports and dependencies
run: |
echo "🔍 Checking import structure..."
python << 'EOF'
import os
import ast
import sys
def check_imports(file_path):
"""Check for proper import structure"""
violations = []
try:
with open(file_path, 'r') as f:
tree = ast.parse(f.read())
for node in ast.walk(tree):
if isinstance(node, ast.ImportFrom):
if node.module and 'framework.' in node.module:
violations.append(f"Legacy framework import: {node.module}")
except:
pass # Skip files that can't be parsed
return violations
all_violations = []
for root, dirs, files in os.walk("src/uckn"):
for file in files:
if file.endswith(".py"):
file_path = os.path.join(root, file)
violations = check_imports(file_path)
all_violations.extend([f"{file_path}: {v}" for v in violations])
if all_violations:
print("❌ Import violations:")
for violation in all_violations:
print(f" {violation}")
sys.exit(1)
else:
print("✅ Import structure is clean")
EOF
pr-coverage:
name: Coverage Check
runs-on: ubuntu-latest
env:
ENVIRONMENT: ci
PYTHONUNBUFFERED: 1
PIXI_ENV: ci
UCKN_DISABLE_TORCH: "1"
HF_HUB_DISABLE_PROGRESS_BARS: "1"
HF_HUB_DISABLE_TELEMETRY: "1"
if: github.event.pull_request.draft == false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pixi
uses: prefix-dev/[email protected]
with:
pixi-version: v0.50.2
cache: true
- name: Install dependencies (pixi)
run: pixi install
- name: Install dev dependencies
run: pixi run dev
- name: Generate coverage report
env:
CI: "1"
ENVIRONMENT: "ci"
run: |
echo "📊 Generating coverage report (CI optimized)..."
pixi run -e quality test-cov
# Check coverage threshold
python << 'EOF'
import json
import os
if os.path.exists('coverage.json'):
with open('coverage.json', 'r') as f:
coverage_data = json.load(f)
total_coverage = coverage_data['totals']['percent_covered']
print(f"Total coverage: {total_coverage:.1f}%")
if total_coverage < 70:
print(f"❌ Coverage below threshold: {total_coverage:.1f}% < 70%")
exit(1)
else:
print(f"✅ Coverage meets threshold: {total_coverage:.1f}% >= 70%")
else:
print("⚠️ Coverage file not found - coverage may have failed")
exit(1)
EOF
pr-docs:
name: Documentation Check
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check documentation updates
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "📚 Checking documentation..."
# Check if significant changes need doc updates
# Use the PR base branch for comparison (fallback to development)
BASE_BRANCH=$(gh pr view ${{ github.event.pull_request.number }} --json baseRefName --jq '.baseRefName' 2>/dev/null || echo "development")
echo "Using base branch for comparison: $BASE_BRANCH"
# Fetch the base branch
git fetch origin $BASE_BRANCH || echo "Warning: Could not fetch base branch"
CHANGED_FILES=$(git diff --name-only origin/$BASE_BRANCH...HEAD 2>/dev/null || echo "")
SRC_CHANGES=$(echo "$CHANGED_FILES" | grep -E '^src/' | wc -l 2>/dev/null || echo "0")
DOC_CHANGES=$(echo "$CHANGED_FILES" | grep -E '\.(md|rst)$' | wc -l 2>/dev/null || echo "0")
echo "Source file changes: $SRC_CHANGES"
echo "Documentation changes: $DOC_CHANGES"
if [ "$SRC_CHANGES" -gt 5 ] && [ "$DOC_CHANGES" -eq 0 ]; then
echo "⚠️ Significant source changes detected but no documentation updates"
echo "Consider updating documentation for major changes"
else
echo "✅ Documentation status acceptable"
fi
pr-summary:
name: PR Summary
runs-on: ubuntu-latest
needs: [pr-quality-gate, pr-coverage, pr-docs]
if: always()
steps:
- name: Generate PR summary
run: |
echo "## 🎯 Pull Request Quality Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.pr-quality-gate.result }}" == "success" ]; then
echo "✅ **Quality Gate**: Passed" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Quality Gate**: Failed" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.pr-coverage.result }}" == "success" ]; then
echo "✅ **Coverage**: Acceptable" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Coverage**: Below threshold" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.pr-docs.result }}" == "success" ]; then
echo "✅ **Documentation**: Checked" >> $GITHUB_STEP_SUMMARY
else
echo "⚠️ **Documentation**: Needs attention" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### UCKN Framework Standards" >> $GITHUB_STEP_SUMMARY
echo "- Atomic design structure enforced" >> $GITHUB_STEP_SUMMARY
echo "- File size limits validated (≤500 lines)" >> $GITHUB_STEP_SUMMARY
echo "- Import structure verified" >> $GITHUB_STEP_SUMMARY
echo "- Test coverage maintained" >> $GITHUB_STEP_SUMMARY