Skip to content

Latest commit

 

History

History
198 lines (139 loc) · 5.83 KB

File metadata and controls

198 lines (139 loc) · 5.83 KB

CI/CD and Testing Integration Summary

🎯 Overview

The CF Java Plugin now includes comprehensive CI/CD integration with automated testing, linting, and quality assurance for both Go and Python codebases.

🏗️ CI/CD Pipeline

GitHub Actions Workflows

  1. Build and Snapshot Release (.github/workflows/build-and-snapshot.yml)

    • Triggers: Push to main/master, PRs, weekly schedule, manual dispatch
    • Jobs:
      • Python test suite validation (if available)
      • Multi-platform Go builds (Linux, macOS, Windows)
      • Automated snapshot releases
  2. Pull Request Validation (.github/workflows/pr-validation.yml)

    • Triggers: All pull requests to main/master
    • Validation Steps:
      • Go formatting (go fmt) and linting (go vet)
      • Python code quality (flake8, black, isort)
      • Markdown linting and formatting
      • Python test execution
      • Plugin build verification

Smart Python Detection

The CI automatically detects if the Python test suite exists by checking for:

  • test/requirements.txt
  • test/setup.sh

If found, runs Python linting validation. Note: Python test execution is temporarily disabled in CI.

🔒 Pre-commit Hooks

Installation

./setup-dev-env.sh  # One-time setup

What It Checks

  • ✅ Go code formatting (go fmt)
  • ✅ Go static analysis (go vet)
  • ✅ Python linting (flake8) - if test suite exists
  • ✅ Python formatting (black) - auto-fixes issues
  • ✅ Import sorting (isort) - auto-fixes issues
  • ✅ Python syntax validation
  • ✅ Markdown linting (markdownlint) - checks git-tracked files

Hook Behavior

  • Auto-fixes: Python formatting and import sorting
  • Blocks commits: On critical linting issues
  • Warnings: For non-critical issues or missing Python suite

🧪 Python Test Suite Integration

Linting Standards

  • flake8: Line length 120, ignores E203,W503
  • black: Line length 120, compatible with flake8
  • isort: Black-compatible profile for import sorting
  • markdownlint: Automated markdown formatting (120 char limit, git-tracked files only)

Manual Usage

./scripts/lint-go.sh check         # Check Go code formatting and static analysis
./scripts/lint-go.sh fix           # Auto-fix Go code issues
./scripts/lint-python.sh check     # Check Python code quality
./scripts/lint-python.sh fix       # Auto-fix Python code issues
./scripts/lint-markdown.sh check    # Check formatting
./scripts/lint-markdown.sh fix      # Auto-fix issues
./scripts/lint-all.sh check         # Check all (Go, Python, Markdown)

Test Execution

cd test
./setup.sh               # Setup environment
./test.py all            # Run all tests

CI Status: Python tests are currently disabled in CI workflows but can be run locally.

Coverage Reporting

  • Generated in XML format for Codecov integration
  • Covers the framework module
  • Includes terminal output for local development

🛠️ Development Workflow

First-time Setup

git clone <repository>
cd cf-cli-java-plugin
./setup-dev-env.sh

Daily Development

# Make changes
code cf-java-plugin.code-workspace

# Commit (hooks run automatically)
git add .
git commit -m "Feature: Add new functionality"

# Push (triggers CI)
git push origin feature-branch

# Create PR (triggers validation)

Manual Testing

# Test pre-commit hooks
.git/hooks/pre-commit

# Test VS Code configuration
./test-vscode-config.sh

# Run specific tests
cd test && pytest test_jfr.py -v

📊 Quality Metrics

Go Code Quality

  • Formatting enforcement via go fmt
  • Static analysis via go vet

Python Code Quality

  • Style compliance: flake8 (PEP 8 + custom rules)
  • Formatting: black (consistent style)
  • Import organization: isort (proper import ordering)

Markdown Code Quality

  • Style compliance: markdownlint (120 char limit, git-tracked files only)
  • Automated formatting with relaxed rules for compatibility

🔐 GitHub Secrets Configuration

For running Python tests in CI that require Cloud Foundry credentials, configure these GitHub repository secrets:

Required Secrets

Secret Name Description Example
CF_API Cloud Foundry API endpoint https://api.cf.eu12.hana.ondemand.com
CF_USERNAME Cloud Foundry username your-username
CF_PASSWORD Cloud Foundry password your-password
CF_ORG Cloud Foundry organization sapmachine-testing
CF_SPACE Cloud Foundry space dev

Setting Up Secrets

  1. Navigate to Repository Settings:

    • Go to your GitHub repository
    • Click "Settings" → "Secrets and variables" → "Actions"
  2. Add New Repository Secret:

    • Click "New repository secret"
    • Enter the secret name (e.g., CF_USERNAME)
    • Enter the secret value
    • Click "Add secret"
  3. Repeat for all required secrets

Environment Variable Usage

The Python test framework automatically uses these environment variables:

  • Falls back to test_config.yml if environment variables are not set
  • Supports both file-based and environment-based configuration
  • CI workflows pass secrets as environment variables to test processes

Security Best Practices

  • Never commit credentials to source code
  • Use repository secrets for sensitive data
  • Limit secret access to necessary workflows only
  • Rotate credentials regularly
  • Use organization secrets for shared credentials across repositories