chore: organize project structure and overall update #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| schedule: | |
| # Run tests weekly on Monday at 00:00 UTC | |
| - cron: '0 0 * * 1' | |
| jobs: | |
| test: | |
| name: Test on Python ${{ matrix.python-version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| python-version: ['3.8', '3.9', '3.10', '3.11'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest pytest-cov pytest-xdist pytest-timeout black isort flake8 mypy | |
| - name: Lint with flake8 | |
| run: | | |
| # Stop the build if there are Python syntax errors or undefined names | |
| flake8 src tests --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # Exit-zero treats all errors as warnings | |
| flake8 src tests --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics | |
| - name: Check code formatting with black | |
| run: | | |
| black --check src tests | |
| - name: Check import sorting with isort | |
| run: | | |
| isort --check-only src tests | |
| - name: Type check with mypy | |
| continue-on-error: true | |
| run: | | |
| mypy src --ignore-missing-imports | |
| - name: Run unit tests | |
| run: | | |
| pytest tests/unit -v --cov=src --cov-report=xml --cov-report=term-missing -n auto | |
| - name: Run integration tests | |
| run: | | |
| pytest tests/integration -v -m "not slow and not data and not gpu" --timeout=300 | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| test-gpu: | |
| name: Test on GPU | |
| runs-on: ubuntu-latest | |
| # Only run GPU tests on main branch or when explicitly requested | |
| if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run-gpu-tests') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest pytest-cov | |
| - name: Run GPU tests | |
| run: | | |
| pytest tests -v -m gpu --cov=src --cov-report=xml | |
| # Note: This requires self-hosted runner with GPU or cloud GPU instance | |
| build-docs: | |
| name: Build Documentation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install sphinx sphinx-rtd-theme myst-parser | |
| - name: Check documentation links | |
| run: | | |
| # Check for broken links in markdown files | |
| find docs -name "*.md" -type f -exec grep -l "http" {} \; || true | |
| - name: Validate markdown | |
| run: | | |
| # Basic markdown validation | |
| find . -name "*.md" -type f ! -path "./.git/*" ! -path "./htmlcov/*" -exec cat {} \; > /dev/null | |
| security: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install safety bandit | |
| - name: Run safety check | |
| run: | | |
| pip install -r requirements.txt | |
| safety check --json || true | |
| - name: Run bandit security scan | |
| run: | | |
| bandit -r src -f json -o bandit-report.json || true | |
| - name: Upload security reports | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: security-reports | |
| path: | | |
| bandit-report.json | |
| benchmark: | |
| name: Performance Benchmark | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest pytest-benchmark | |
| - name: Run benchmarks | |
| run: | | |
| pytest tests -v -m "benchmark" --benchmark-only --benchmark-json=benchmark.json || true | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: benchmark-results | |
| path: benchmark.json | |
| code-quality: | |
| name: Code Quality Analysis | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Full history for better analysis | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install radon pylint | |
| - name: Calculate cyclomatic complexity | |
| run: | | |
| radon cc src -a -nb | |
| - name: Calculate maintainability index | |
| run: | | |
| radon mi src -nb | |
| - name: Run pylint | |
| continue-on-error: true | |
| run: | | |
| pylint src --exit-zero --output-format=json > pylint-report.json | |
| - name: Upload quality reports | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: quality-reports | |
| path: pylint-report.json |