Create setup.py #4
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: Python Tests & Validation | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| schedule: | |
| - cron: '0 0 * * *' # Daily run | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11"] | |
| os: [ubuntu-latest] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Display Python version | |
| run: python -c "import sys; print(f'Python {sys.version}')" | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential python3-dev | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pytest pytest-cov pytest-asyncio | |
| pip install -r requirements.txt | |
| python -m spacy download en_core_web_sm | |
| python -c "import nltk; nltk.download('punkt'); nltk.download('wordnet')" | |
| - name: Run basic syntax check | |
| run: | | |
| echo "Checking Python syntax..." | |
| python -m py_compile src/truthprobe_v3.py | |
| if [ -f "src/enhanced_detector.py" ]; then | |
| python -m py_compile src/enhanced_detector.py | |
| fi | |
| - name: Run tests with pytest | |
| run: | | |
| python -m pytest tests/ -v --cov=src --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml | |
| env: | |
| PYTHONPATH: ${{ github.workspace }} | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| fail_ci_if_error: true | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: test-results-${{ matrix.python-version }} | |
| path: | | |
| junit/test-results.xml | |
| coverage.xml | |
| htmlcov/ | |
| lint: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: always() | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install linting tools | |
| run: | | |
| pip install flake8 black isort mypy bandit | |
| - name: Check code formatting with Black | |
| run: | | |
| black --check src/ tests/ --diff | |
| - name: Lint with flake8 | |
| run: | | |
| flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics | |
| flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Check import order with isort | |
| run: | | |
| isort --check-only --diff src/ tests/ | |
| - name: Type check with mypy | |
| run: | | |
| mypy src/ --ignore-missing-imports --strict | |
| - name: Security scan with bandit | |
| run: | | |
| bandit -r src/ -f json -o bandit-report.json || true | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| if: always() | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Build package | |
| run: | | |
| python setup.py sdist bdist_wheel | |
| - name: Verify package | |
| run: | | |
| pip install twine | |
| twine check dist/* | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: dist-package | |
| path: dist/ | |
| deploy-docs: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs | |
| keep_files: true | |
| status: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint, build] | |
| if: always() | |
| steps: | |
| - name: Create Status Badge | |
| run: | | |
| echo "All checks passed successfully!" > status.txt | |
| echo "✅ All tests passed" >> status.txt | |
| date >> status.txt | |
| - name: Upload Status | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: status | |
| path: status.txt |