kgraph-mcp-agent-platform / CI_WORKFLOW_IMPROVEMENTS.md
BasalGanglia's picture
πŸ› οΈ Fix HuggingFace Space configuration - Remove quotes from frontmatter
64ced8b verified

A newer version of the Gradio SDK is available: 6.2.0

Upgrade

GitHub CI Workflow Improvements

Summary

Fixed both GitHub CI workflows (.github/workflows/ci.yml and .github/workflows/ci-full.yml) to use modern best practices and resolve several issues.

Issues Fixed

ci.yml (Basic CI)

Before:

  • Used uv pip install --system which is not recommended in CI environments
  • Ran tools directly instead of through uv run
  • Used pip install uv instead of the official action
  • Inconsistent Python version handling between jobs
  • Missing error handling for coverage uploads

After:

  • βœ… Uses astral-sh/setup-uv@v4 official action with caching
  • βœ… Creates proper virtual environments with uv venv
  • βœ… All tools run through uv run for consistency
  • βœ… Proper error handling with fail_ci_if_error: false
  • βœ… Optimized artifact uploads (only for Python 3.11)
  • βœ… Better output formatting with --output-format=github for Ruff

ci-full.yml (Full CI with External Dependencies)

Before:

  • Workflow was disabled (manual trigger only)
  • Overcomplicated uv usage with unnecessary uv pip compile steps
  • Hardcoded Python versions ("3.11.8")
  • Redundant dependency installation steps

After:

  • βœ… Enabled for automatic triggering on pushes and PRs
  • βœ… Simplified uv usage - direct installation from requirements files
  • βœ… Uses environment variables for Python version consistency
  • βœ… Improved error handling for missing files
  • βœ… Better structured with proper caching

Key Improvements

1. Modern uv Usage

# Before
- name: Install uv
  run: pip install uv
- name: Install dependencies
  run: |
    uv pip install --system -r requirements.txt

# After
- name: Install uv
  uses: astral-sh/setup-uv@v4
  with:
    version: "latest"
    enable-cache: true
- name: Create virtual environment and install dependencies
  run: |
    uv venv
    uv pip install -r requirements.txt

2. Consistent Tool Execution

# Before
run: ruff check .

# After
run: uv run ruff check . --output-format=github

3. Environment Variables

env:
  PYTHON_VERSION: "3.11"
  FORCE_COLOR: 1

4. Better Error Handling

- name: Upload coverage to Codecov
  uses: codecov/codecov-action@v4
  if: matrix.python-version == env.PYTHON_VERSION
  with:
    fail_ci_if_error: false

Workflow Structure

ci.yml (Basic)

  • lint: Code quality checks (Ruff, Black, MyPy)
  • test: Unit tests with PostgreSQL/Redis services
  • security: Security scans (Bandit, Trivy)
  • docker: Container builds on develop branch

ci-full.yml (Comprehensive)

  • test: Full test suite with matrix strategy
  • integration-tests: E2E and integration testing
  • security: Enhanced security scanning with secrets detection
  • deployment-prep: Validates deployment readiness
  • pr-checks: Enforces PR title and branch naming conventions
  • success: Final status check for all jobs

Benefits

  1. Reliability: Proper virtual environment isolation
  2. Performance: Caching enabled for uv and dependencies
  3. Consistency: All tools run through uv run
  4. Maintainability: Environment variables for version management
  5. Visibility: Better error reporting and GitHub integration
  6. Security: Enhanced security scanning and secrets detection

Recommendations

1. Required Secrets

Ensure these secrets are configured in your repository:

  • CODECOV_TOKEN: For coverage reporting

2. Branch Protection

Configure branch protection rules to require:

  • Status checks from both workflows
  • PR reviews before merging
  • Up-to-date branches

3. Additional Enhancements

Consider adding:

  • Dependabot for dependency updates
  • CodeQL analysis for security
  • Performance regression testing
  • Deployment automation for staging/production

4. Local Development

Ensure developers use the same tools locally:

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Create environment and install dependencies
uv venv
uv pip install -r requirements.txt -r requirements-dev.txt

# Run quality checks
uv run ruff check .
uv run black --check .
uv run mypy .
uv run pytest

Files Modified

  • .github/workflows/ci.yml - Basic CI workflow
  • .github/workflows/ci-full.yml - Full CI workflow with external dependencies

Next Steps

  1. Test the workflows with a sample PR
  2. Verify all required secrets are configured
  3. Update documentation to reflect new CI requirements
  4. Consider enabling automated deployments for successful builds