Fix code styling to pass CI pipeline #2
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 ] | |
| jobs: | |
| test: | |
| name: Test Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| 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 }} | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest pytest-cov black flake8 | |
| - name: Lint with flake8 | |
| run: | | |
| # Stop the build if there are Python syntax errors or undefined names | |
| flake8 src/ app/ scripts/ --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # Exit-zero treats all errors as warnings | |
| flake8 src/ app/ scripts/ --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics | |
| - name: Check code formatting with black | |
| run: | | |
| black --check src/ app/ scripts/ | |
| - name: Run tests with pytest | |
| run: | | |
| pytest tests/ -v --cov=src --cov-report=xml --cov-report=term | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| build: | |
| name: Build and validate | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run data collection | |
| run: | | |
| python scripts/collect_data.py | |
| - name: Validate generated data | |
| run: | | |
| python -c " | |
| import pandas as pd | |
| from pathlib import Path | |
| # Check all required files exist | |
| files = [ | |
| 'data/processed/competitive_overview.csv', | |
| 'data/processed/feature_matrix.csv', | |
| 'data/synthetic/traffic_estimates.csv', | |
| 'data/synthetic/user_reviews.csv' | |
| ] | |
| for f in files: | |
| assert Path(f).exists(), f'Missing: {f}' | |
| df = pd.read_csv(f) | |
| assert len(df) > 0, f'Empty file: {f}' | |
| print('✅ All data files validated') | |
| " | |
| - name: Generate reports | |
| run: | | |
| python scripts/run_full_analysis.py | |
| - name: Validate reports | |
| run: | | |
| python -c " | |
| from pathlib import Path | |
| # Check all reports exist | |
| reports = [ | |
| 'outputs/reports/competitive_analysis_summary.txt', | |
| 'outputs/reports/market_sizing_report.txt', | |
| 'outputs/reports/pricing_strategy_recommendation.txt', | |
| 'outputs/reports/gtm_strategy_report.txt', | |
| 'outputs/reports/financial_model_report.txt' | |
| ] | |
| for r in reports: | |
| assert Path(r).exists(), f'Missing report: {r}' | |
| assert Path(r).stat().st_size > 1000, f'Report too small: {r}' | |
| print('✅ All reports validated') | |
| " | |
| - name: Archive reports | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: gtm-reports | |
| path: outputs/reports/ | |
| retention-days: 30 | |
| - name: Archive dashboards | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: gtm-dashboards | |
| path: outputs/dashboards/ | |
| retention-days: 30 | |
| deploy-docs: | |
| name: Deploy documentation | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs | |
| publish_branch: gh-pages |