Opti3D CI/CD Pipeline Guide
Opti3D CI/CD Pipeline Guide
This document describes the modern CI/CD pipeline that replaces sys.path manipulation with proper build and deployment automation.
π Overview
The Opti3D project uses GitHub Actions for continuous integration and deployment, providing:
- Automated security testing
- Code quality checks
- Multi-environment deployments
- Container-based builds
- Comprehensive reporting
π Pipeline Structure
GitHub Actions Workflow
Location: .github/workflows/ci-cd.yml
The pipeline includes these jobs:
- Security Tests - Runs vulnerability scans, static analysis, and security compliance tests
- Functional Tests - Runs unit, integration, and application tests
- Build - Creates Python packages and validates them
- Docker Build - Creates container images for deployment
- Deploy Staging - Deploys to staging environment (develop branch)
- Deploy Production - Deploys to production (releases only)
- Documentation - Builds and deploys documentation
- Notifications - Sends status notifications
Package Configuration
Location: pyproject.toml
Modern Python packaging with:
- Proper dependency management
- Development dependencies
- Tool configurations (pytest, black, flake8, etc.)
- Entry points for CLI tools
π οΈ Local Development
Quick Setup
# Clone and setup
git clone https://github.com/wilsonify/Opti3D.git
cd Opti3D
./scripts/setup_dev_env.sh
# Or manually
python -m venv venv
source venv/bin/activate
pip install -e ".[dev,security,test]"
pre-commit install
Development Commands
# Install dependencies
make install-dev
# Run all checks (CI equivalent)
make ci-test
# Run specific test types
make test # All tests
make test-security # Security tests only
make test-functional # Functional tests only
make test-unit # Unit tests only
# Code quality
make lint # Run all linters
make format # Format code
make security # Run security scans
# Build and deployment
make build # Build Python package
make docker # Build Docker image
make clean # Clean artifacts
π Security Testing
Automated Security Checks
The pipeline runs these security tools:
- Safety - Scans dependencies for known vulnerabilities
- Bandit - Static analysis for security issues in Python code
- Custom Security Tests - Application-specific security tests
- Flake8/Pylint - Code quality with security-focused rules
Security Test Markers
Tests are marked with pytest markers:
@pytest.mark.security
def test_sql_injection_protection():
# Security test implementation
pass
Running Security Tests Locally
# Run all security checks
make security
# Or individual tools
bandit -r src/
safety check
python -m pytest tests/ -m security
π¦ Build and Deployment
Package Building
# Build Python package
make build
# Output in dist/
# - opti3d-1.0.0-py3-none-any.whl
# - opti3d-1.0.0.tar.gz
Docker Deployment
# Build Docker image
make docker
# Run locally
make docker-run
# Or manually
docker build -t opti3d:latest .
docker run -p 5000:5000 opti3d:latest
Environment-specific Deployment
Staging (develop branch)
- Triggers on push to
developbranch - Runs after successful tests
- Deploys to staging environment
- Runs smoke tests
Production (releases)
- Triggers on GitHub releases
- Runs full test suite
- Creates Docker images
- Deploys to production
- Runs health checks
π§ͺ Testing Strategy
Test Categories
- Unit Tests - Fast, isolated component tests
- Integration Tests - Component interaction tests
- Security Tests - Security-focused tests
- End-to-End Tests - Full application tests
Test Configuration
[tool.pytest.ini_options]
markers = [
"slow: marks tests as slow",
"integration: marks tests as integration tests",
"security: marks tests as security-related tests",
"unit: marks tests as unit tests",
]
Coverage Reporting
- HTML reports in
htmlcov/ - XML reports for CI integration
- Coverage uploaded to Codecov
π§ Configuration
Required Secrets
Configure these in GitHub repository settings:
DOCKER_USERNAME- Docker Hub usernameDOCKER_PASSWORD- Docker Hub password/tokenGITHUB_TOKEN- Automatically provided by GitHub Actions
Environment-specific Settings
- Staging: Configured via GitHub environments
- Production: Requires approval and additional checks
π Monitoring and Reporting
Artifacts
Each pipeline run generates:
- Security scan reports (JSON)
- Coverage reports (HTML/XML)
- Build packages (wheel/tar.gz)
- Docker images (multi-platform)
Notifications
Configure notifications in the notify job:
- Slack integration
- Email notifications
- Teams webhooks
π¨ Troubleshooting
Common Issues
- Import Errors
# Ensure package is installed in development mode pip install -e . - Permission Issues
# Make setup script executable chmod +x scripts/setup_dev_env.sh - Docker Build Failures
# Check Dockerfile syntax docker build --no-cache -t opti3d:test .
Debug Mode
Run tests with verbose output:
python -m pytest tests/ -v -s --tb=long
π Migration from Old System
Before (sys.path manipulation)
import sys
sys.path.append('src')
from stldeli import optimizer
After (proper package installation)
from stldeli import optimizer
# Package installed via: pip install -e .
Benefits of New System
- β No sys.path manipulation needed
- β Proper dependency management
- β Automated testing and deployment
- β Security scanning
- β Multi-environment support
- β Container-based deployment
- β Comprehensive reporting
π Additional Resources
π€ Contributing
- Fork the repository
- Create a feature branch
- Make changes and run
make ci-test - Submit a pull request
- CI pipeline will run automatically
For questions or issues, please open an issue on GitHub.